pub struct Hash<'d, T: Instance, D = NoDma> { /* private fields */ }
Expand description
HASH driver.
Implementations§
Source§impl<'d, T: Instance, D> Hash<'d, T, D>
impl<'d, T: Instance, D> Hash<'d, T, D>
Sourcepub fn new(
peripheral: impl Peripheral<P = T> + 'd,
dma: impl Peripheral<P = D> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
) -> Self
pub fn new( peripheral: impl Peripheral<P = T> + 'd, dma: impl Peripheral<P = D> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Self
Instantiates, resets, and enables the HASH peripheral.
Sourcepub fn start<'c>(
&mut self,
algorithm: Algorithm,
format: DataType,
key: Option<&'c [u8]>,
) -> Context<'c>
pub fn start<'c>( &mut self, algorithm: Algorithm, format: DataType, key: Option<&'c [u8]>, ) -> Context<'c>
Starts computation of a new hash and returns the saved peripheral state.
Sourcepub fn update_blocking<'c>(&mut self, ctx: &mut Context<'c>, input: &[u8])
pub fn update_blocking<'c>(&mut self, ctx: &mut Context<'c>, input: &[u8])
Restores the peripheral state using the given context, then updates the state with the provided data. Peripheral state is saved upon return.
Sourcepub async fn update<'c>(&mut self, ctx: &mut Context<'c>, input: &[u8])where
D: Dma<T>,
pub async fn update<'c>(&mut self, ctx: &mut Context<'c>, input: &[u8])where
D: Dma<T>,
Restores the peripheral state using the given context, then updates the state with the provided data. Peripheral state is saved upon return.
Sourcepub fn finish_blocking<'c>(
&mut self,
ctx: Context<'c>,
digest: &mut [u8],
) -> usize
pub fn finish_blocking<'c>( &mut self, ctx: Context<'c>, digest: &mut [u8], ) -> usize
Computes a digest for the given context. The digest buffer must be large enough to accomodate a digest for the selected algorithm. The largest returned digest size is 128 bytes for SHA-512. Panics if the supplied digest buffer is too short.
Sourcepub async fn finish<'c>(&mut self, ctx: Context<'c>, digest: &mut [u8]) -> usizewhere
D: Dma<T>,
pub async fn finish<'c>(&mut self, ctx: Context<'c>, digest: &mut [u8]) -> usizewhere
D: Dma<T>,
Computes a digest for the given context. The digest buffer must be large enough to accomodate a digest for the selected algorithm. The largest returned digest size is 128 bytes for SHA-512. Panics if the supplied digest buffer is too short.