embassy-stm32

Crates

git

Versions

stm32n657b0

Flavors

Cipher

Trait Cipher 

Source
pub trait Cipher<'c> {
    const BLOCK_SIZE: usize = 16usize;
    const REQUIRES_PADDING: bool = false;

    // Required methods
    fn key(&self) -> &[u8];
    fn iv(&self) -> &[u8];

    // Provided methods
    fn key_size(&self) -> KeySize { ... }
    fn datatype(&self) -> u8 { ... }
    fn chmod_bits(&self) -> u8 { ... }
    fn get_header_block(&self) -> &[u8] { ... }
    fn uses_gcm_phases(&self) -> bool { ... }
    fn is_ccm_mode(&self) -> bool { ... }
    fn ccm_b0(&self) -> Option<&[u8; 16]> { ... }
    fn ccm_format_aad_header(&self, aad_len: usize) -> ([u8; 10], usize) { ... }
}
Expand description

This trait encapsulates all cipher-specific behavior.

Provided Associated Constants§

Source

const BLOCK_SIZE: usize = 16usize

Processing block size (always 16 bytes for AES).

Source

const REQUIRES_PADDING: bool = false

Indicates whether the cipher requires the application to provide padding.

Required Methods§

Source

fn key(&self) -> &[u8]

Returns the symmetric key.

Source

fn iv(&self) -> &[u8]

Returns the initialization vector.

Provided Methods§

Source

fn key_size(&self) -> KeySize

Returns the key size.

Source

fn datatype(&self) -> u8

Returns the data type setting for this cipher mode.

Source

fn chmod_bits(&self) -> u8

Returns the raw CHMOD field value for this cipher mode.

Source

fn get_header_block(&self) -> &[u8]

Returns the AAD header block as required by the cipher (for authenticated modes).

Source

fn uses_gcm_phases(&self) -> bool

Indicates whether this cipher mode uses GCM/CCM phases (init, header, payload, final).

Source

fn is_ccm_mode(&self) -> bool

Indicates whether this is CCM mode (which has different final phase handling).

Source

fn ccm_b0(&self) -> Option<&[u8; 16]>

Returns the pre-computed B0 block for CCM mode (None for other modes).

Source

fn ccm_format_aad_header(&self, aad_len: usize) -> ([u8; 10], usize)

Returns the formatted AAD length prefix for CCM mode.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesCbc<'c, KEY_SIZE>

Source§

impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesCtr<'c, KEY_SIZE>

Source§

impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesEcb<'c, KEY_SIZE>

Source§

impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGcm<'c, KEY_SIZE>

Source§

impl<'c, const KEY_SIZE: usize> Cipher<'c> for AesGmac<'c, KEY_SIZE>

Source§

impl<'c, const KEY_SIZE: usize, const IV_SIZE: usize, const TAG_SIZE: usize> Cipher<'c> for AesCcm<'c, KEY_SIZE, IV_SIZE, TAG_SIZE>