embassy-stm32

Crates

git

Versions

stm32h730zb

Flavors

embassy_stm32::cryp

Trait Cipher

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

    // Required methods
    fn key(&self) -> &[u8];
    fn iv(&self) -> &[u8];
    fn set_algomode(&self, p: Cryp);

    // Provided methods
    fn prepare_key(&self, _p: Cryp) { ... }
    fn init_phase_blocking<T: Instance, DmaIn, DmaOut>(
        &self,
        _p: Cryp,
        _cryp: &Cryp<'_, T, DmaIn, DmaOut>,
    ) { ... }
    async fn init_phase<T: Instance, DmaIn, DmaOut>(
        &self,
        _p: Cryp,
        _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>,
    )
       where DmaIn: DmaIn<T>,
             DmaOut: DmaOut<T> { ... }
    fn pre_final(
        &self,
        _p: Cryp,
        _dir: Direction,
        _padding_len: usize,
    ) -> [u32; 4] { ... }
    fn post_final_blocking<T: Instance, DmaIn, DmaOut>(
        &self,
        _p: Cryp,
        _cryp: &Cryp<'_, T, DmaIn, DmaOut>,
        _dir: Direction,
        _int_data: &mut [u8; 16],
        _temp1: [u32; 4],
        _padding_mask: [u8; 16],
    ) { ... }
    async fn post_final<T: Instance, DmaIn, DmaOut>(
        &self,
        _p: Cryp,
        _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>,
        _dir: Direction,
        _int_data: &mut [u8; 16],
        _temp1: [u32; 4],
        _padding_mask: [u8; 16],
    )
       where DmaIn: DmaIn<T>,
             DmaOut: DmaOut<T> { ... }
    fn get_header_block(&self) -> &[u8] { ... }
}
Expand description

This trait encapsulates all cipher-specific behavior/

Required Associated Constants§

Source

const BLOCK_SIZE: usize

Processing block size. Determined by the processor and the algorithm.

Provided Associated Constants§

Source

const REQUIRES_PADDING: bool = false

Indicates whether the cipher requires the application to provide padding. If true, no partial blocks will be accepted (a panic will occur).

Required Methods§

Source

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

Returns the symmetric key.

Source

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

Returns the initialization vector.

Source

fn set_algomode(&self, p: Cryp)

Sets the processor algorithm mode according to the associated cipher.

Provided Methods§

Source

fn prepare_key(&self, _p: Cryp)

Performs any key preparation within the processor, if necessary.

Source

fn init_phase_blocking<T: Instance, DmaIn, DmaOut>( &self, _p: Cryp, _cryp: &Cryp<'_, T, DmaIn, DmaOut>, )

Performs any cipher-specific initialization.

Source

async fn init_phase<T: Instance, DmaIn, DmaOut>( &self, _p: Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>, )
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Performs any cipher-specific initialization.

Source

fn pre_final(&self, _p: Cryp, _dir: Direction, _padding_len: usize) -> [u32; 4]

Called prior to processing the last data block for cipher-specific operations.

Source

fn post_final_blocking<T: Instance, DmaIn, DmaOut>( &self, _p: Cryp, _cryp: &Cryp<'_, T, DmaIn, DmaOut>, _dir: Direction, _int_data: &mut [u8; 16], _temp1: [u32; 4], _padding_mask: [u8; 16], )

Called after processing the last data block for cipher-specific operations.

Source

async fn post_final<T: Instance, DmaIn, DmaOut>( &self, _p: Cryp, _cryp: &mut Cryp<'_, T, DmaIn, DmaOut>, _dir: Direction, _int_data: &mut [u8; 16], _temp1: [u32; 4], _padding_mask: [u8; 16], )
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Called after processing the last data block for cipher-specific operations.

Source

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

Returns the AAD header block as required by the cipher.

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§

const BLOCK_SIZE: usize = 16usize

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§

const BLOCK_SIZE: usize = 16usize

Source§

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

Source§

const BLOCK_SIZE: usize = 16usize

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

const BLOCK_SIZE: usize = 16usize