embassy-stm32

Crates

git

Versions

stm32f217ve

Flavors

Struct Cryp

Source
pub struct Cryp<'d, T: Instance, M: Mode> { /* private fields */ }
Expand description

Crypto Accelerator Driver

Implementations§

Source§

impl<'d, T: Instance> Cryp<'d, T, Blocking>

Source

pub fn new_blocking( peri: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Self

Create a new CRYP driver in blocking mode.

Source§

impl<'d, T: Instance, M: Mode> Cryp<'d, T, M>

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 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§

impl<'d, T: Instance> Cryp<'d, T, Async>

Source

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

Create a new CRYP driver.

Source

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

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

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, )

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.

Auto Trait Implementations§

§

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

§

impl<'d, T, M> RefUnwindSafe for Cryp<'d, T, M>

§

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

§

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

§

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

§

impl<'d, T, M> !UnwindSafe for Cryp<'d, T, M>

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.