Skip to main content

AESCCM

Struct AESCCM 

Source
pub struct AESCCM<E>
where E: Encrypt,
{ /* private fields */ }
Expand description

The primary AES-CCM engine context carrying encryption keys, active nonces, and the peripheral driver.

Implementations§

Source§

impl<E> AESCCM<E>
where E: Encrypt,

Source

pub fn new(aes: E, key: [u8; 16]) -> Self

Creates a new AES-CCM peripheral engine using a key and an hardware peripheral implementation.

Source

pub fn encrypt<T>( &mut self, packet_data: &PacketData<T>, ) -> Result<Frame, Error>

Encrypts packet data into a lightweight, authenticated over-the-air AES-CCM format.

+-----------------------------------------------------------------------+
|                        OVER-THE-AIR FRAME                             |
+--------------------------+--------------------+-----------------------+
|       dst (6 Bytes)      |   flags (1 Byte)   |      ctr (5 Bytes)    | -> HEADER (12 Bytes)
+--------------------------+--------------------+-----------------------+
| Ciphertext (N Bytes)                                                  | -> PAYLOAD
+-----------------------------------------------------------------------+
| Tag (16 Bytes)                                                         | -> MAC/TAG
+-----------------------------------------------------------------------+
§Errors

Returns Err(PacketError::BufferOverflow) if serialization fails or Err(PacketError::AESCounterOverflow) if the nonce limits are exceeded.

Source

pub fn decrypt<T>(&mut self, bytes: &mut [u8]) -> Result<PacketData<T>, Error>

Decrypts and authenticates an incoming packet from a mutable slice buffer in-place.

§Errors

Returns:

  • PacketError::InvalidFormat if parsing fails.
  • PacketError::Duplicate if a potential replay attack is intercepted.
  • PacketError::Corrupted if the tag verification fails.

Auto Trait Implementations§

§

impl<E> Freeze for AESCCM<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for AESCCM<E>
where E: RefUnwindSafe,

§

impl<E> Send for AESCCM<E>
where E: Send,

§

impl<E> Sync for AESCCM<E>
where E: Sync,

§

impl<E> Unpin for AESCCM<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for AESCCM<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for AESCCM<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.