Skip to main content

Encrypt

Trait Encrypt 

Source
pub trait Encrypt {
    // Required method
    fn encrypt(
        &mut self,
        key_stream_buf: &mut [u8; 16],
        block: &mut [u8; 16],
        key: [u8; 16],
    );
}
Expand description

A HAL trait to allow different MCUs with AES hardware acceleration to hook onto the AES-CCM implementation.

§Example

Example usage with the esp_hal crate (compatible with ~1.1.0):

use aesccm::Encrypt;

pub struct AesHal(esp_hall::aes::Aes<'static>);
impl Encrypt for AesHal {
   fn encrypt(&mut self, key_stream_buf: &mut [u8; 16], a_block: &mut [u8; 16], key: [u8; 16]) {
       key_stream_buf.copy_from_slice(a_block);
       self.0.encrypt(key_stream_buf, key);
   }
}

Required Methods§

Source

fn encrypt( &mut self, key_stream_buf: &mut [u8; 16], block: &mut [u8; 16], key: [u8; 16], )

Encrypts the given 16-byte buffer with the given key using the MCU’s AES hardware peripheral.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§