embassy-stm32

Crates

git

Versions

stm32c562ce

Flavors

Skip to main content

Cipher

Trait Cipher 

Source
pub trait Cipher<'c> {
    const BLOCK_SIZE: usize = AES_BLOCK_SIZE;
    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 uses_gcm_phases(&self) -> bool { ... }
    fn is_ccm_mode(&self) -> bool { ... }
    fn ccm_aad_header(&self) -> ([u8; 10], usize) { ... }
}
Expand description

This trait encapsulates all cipher-specific behavior.

Provided Associated Constants§

Source

const BLOCK_SIZE: usize = AES_BLOCK_SIZE

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.

The drivers use NO_SWAP (0) consistently with big-endian byte conversion (from_be_bytes/to_be_bytes) for direct NIST test-vector compatibility.

Source

fn chmod_bits(&self) -> u8

Returns the raw CHMOD field value for this cipher mode.

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_aad_header(&self) -> ([u8; 10], usize)

CCM only: the encoded associated-data length that precedes the associated data in the first header block (NIST SP 800-38C A.2.2), and its size. Empty for other modes and when there is no associated data.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

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>

Cipher implementation for AesCcm, forwarding to the shared type-erased [CcmOp] implementation so the hardware logic exists only once.

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>