[][src]Trait kernel::hil::digest::Digest

pub trait Digest<'a, T: DigestType> {
    fn set_client(&'a self, client: &'a dyn Client<'a, T>);
fn add_data(
        &self,
        data: LeasableBuffer<'static, u8>
    ) -> Result<usize, (ReturnCode, &'static mut [u8])>;
fn run(
        &'a self,
        digest: &'static mut T
    ) -> Result<(), (ReturnCode, &'static mut T)>;
fn clear_data(&self); }

Computes a digest (cryptographic hash) over data

Required methods

fn set_client(&'a self, client: &'a dyn Client<'a, T>)

Set the client instance which will receive hash_done() and add_data_done() callbacks. This callback is called when the data has been added to the digest engine. The callback should follow the Client add_data_done callback.

fn add_data(
    &self,
    data: LeasableBuffer<'static, u8>
) -> Result<usize, (ReturnCode, &'static mut [u8])>

Add data to the digest block. This is the data that will be used for the hash function. Returns the number of bytes parsed on success There is no guarantee the data has been written until the add_data_done() callback is fired. On error the return value will contain a return code and the original data

fn run(
    &'a self,
    digest: &'static mut T
) -> Result<(), (ReturnCode, &'static mut T)>

Request the hardware block to generate a Digest and stores the returned digest in the memory location specified. This doesn't return any data, instead the client needs to have set a hash_done handler to determine when this is complete. On error the return value will contain a return code and the original data If there is data from the add_data() command asyncrously waiting to be written it will be written before the operation starts.

If an appropriate set_mode*() wasn't called before this function the implementation should try to use a default option. In the case where there is only one digest supported this should be used. If there is no suitable or obvious default option, the implementation can return an error with error code ENOSUPPORT.

fn clear_data(&self)

Clear the keys and any other sensitive data. This won't clear the buffers provided to this API, that is up to the user to clear.

Loading content...

Implementors

Loading content...