embassy-stm32

Crates

git

Versions

stm32h7s7a8

Flavors

๐Ÿ“ฃ We want to hear from you! Fill the Rust Embedded 2024 micro-survey.

Struct embassy_stm32::cryp::Cryp

source ยท
pub struct Cryp<'d, T: Instance, DmaIn = NoDma, DmaOut = NoDma> { /* private fields */ }
Expand description

Crypto Accelerator Driver

Implementationsยง

sourceยง

impl<'d, T: Instance, DmaIn, DmaOut> Cryp<'d, T, DmaIn, DmaOut>

source

pub fn new( peri: impl Peripheral<P = T> + 'd, indma: impl Peripheral<P = DmaIn> + 'd, outdma: impl Peripheral<P = DmaOut> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Self

Create a new CRYP driver.

source

pub fn start_blocking<'c, C: Cipher<'c> + CipherSized + IVSized>( &self, cipher: &'c C, dir: Direction, ) -> Context<'c, C>

Start a new encrypt or decrypt operation for the given cipher.

source

pub async fn start<'c, C: Cipher<'c> + CipherSized + IVSized>( &mut self, cipher: &'c C, dir: Direction, ) -> Context<'c, C>
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Start a new encrypt or decrypt operation for the given cipher.

source

pub fn aad_blocking<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>( &self, ctx: &mut Context<'c, C>, aad: &[u8], last_aad_block: bool, )

Controls the header phase of cipher processing. This function is only valid for authenticated ciphers including GCM, CCM, and GMAC. All additional associated data (AAD) must be supplied to this function prior to starting the payload phase with payload_blocking. The AAD must be supplied in multiples of the block size (128-bits for AES, 64-bits for DES), except when supplying the last block. When supplying the last block of AAD, last_aad_block must be true.

source

pub async fn aad<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>( &mut self, ctx: &mut Context<'c, C>, aad: &[u8], last_aad_block: bool, )
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Controls the header phase of cipher processing. This function is only valid for authenticated ciphers including GCM, CCM, and GMAC. All additional associated data (AAD) must be supplied to this function prior to starting the payload phase with payload. The AAD must be supplied in multiples of the block size (128-bits for AES, 64-bits for DES), except when supplying the last block. When supplying the last block of AAD, last_aad_block must be true.

source

pub fn payload_blocking<'c, C: Cipher<'c> + CipherSized + IVSized>( &self, ctx: &mut Context<'c, C>, input: &[u8], output: &mut [u8], last_block: bool, )

Performs encryption/decryption on the provided context. The context determines algorithm, mode, and state of the crypto accelerator. When the last piece of data is supplied, last_block should be true. This function panics under various mismatches of parameters. Output buffer must be at least as long as the input buffer. Data must be a multiple of block size (128-bits for AES, 64-bits for DES) for CBC and ECB modes. Padding or ciphertext stealing must be managed by the application for these modes. Data must also be a multiple of block size unless last_block is true.

source

pub async fn payload<'c, C: Cipher<'c> + CipherSized + IVSized>( &mut self, ctx: &mut Context<'c, C>, input: &[u8], output: &mut [u8], last_block: bool, )
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Performs encryption/decryption on the provided context. The context determines algorithm, mode, and state of the crypto accelerator. When the last piece of data is supplied, last_block should be true. This function panics under various mismatches of parameters. Output buffer must be at least as long as the input buffer. Data must be a multiple of block size (128-bits for AES, 64-bits for DES) for CBC and ECB modes. Padding or ciphertext stealing must be managed by the application for these modes. Data must also be a multiple of block size unless last_block is true.

source

pub fn finish_blocking<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>( &self, ctx: Context<'c, C>, ) -> [u8; TAG_SIZE]

Generates an authentication tag for authenticated ciphers including GCM, CCM, and GMAC. Called after the all data has been encrypted/decrypted by payload.

source

pub async fn finish<'c, const TAG_SIZE: usize, C: Cipher<'c> + CipherSized + IVSized + CipherAuthenticated<TAG_SIZE>>( &mut self, ctx: Context<'c, C>, ) -> [u8; TAG_SIZE]
where DmaIn: DmaIn<T>, DmaOut: DmaOut<T>,

Called after the all data has been encrypted/decrypted by payload.

Auto Trait Implementationsยง

ยง

impl<'d, T, DmaIn, DmaOut> Freeze for Cryp<'d, T, DmaIn, DmaOut>
where T: Freeze, DmaIn: Freeze, DmaOut: Freeze,

ยง

impl<'d, T, DmaIn, DmaOut> RefUnwindSafe for Cryp<'d, T, DmaIn, DmaOut>
where T: RefUnwindSafe, DmaIn: RefUnwindSafe, DmaOut: RefUnwindSafe,

ยง

impl<'d, T, DmaIn, DmaOut> Send for Cryp<'d, T, DmaIn, DmaOut>
where DmaIn: Send, DmaOut: Send,

ยง

impl<'d, T, DmaIn, DmaOut> Sync for Cryp<'d, T, DmaIn, DmaOut>
where T: Sync, DmaIn: Sync, DmaOut: Sync,

ยง

impl<'d, T, DmaIn, DmaOut> Unpin for Cryp<'d, T, DmaIn, DmaOut>
where T: Unpin, DmaIn: Unpin, DmaOut: Unpin,

ยง

impl<'d, T, DmaIn = NoDma, DmaOut = NoDma> !UnwindSafe for Cryp<'d, T, DmaIn, DmaOut>

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.