Trait kernel::hil::digest::DigestData

source ·
pub trait DigestData<'a, const L: usize> {
    // Required methods
    fn set_data_client(&'a self, client: &'a dyn ClientData<L>);
    fn add_data(
        &self,
        data: SubSlice<'static, u8>,
    ) -> Result<(), (ErrorCode, SubSlice<'static, u8>)>;
    fn add_mut_data(
        &self,
        data: SubSliceMut<'static, u8>,
    ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>)>;
    fn clear_data(&self);
}
Expand description

Adding data (mutable or immutable) to a digest. There are two separate methods, add_data for immutable data (e.g., flash) and add_mut_data for mutable data (e.g., RAM). Each has its own callback, but only one operation may be in flight at any time.

‘L’ is the length of the ‘u8’ array to store the digest output.

Required Methods§

source

fn set_data_client(&'a self, client: &'a dyn ClientData<L>)

Set the client instance which will handle the add_data_done and add_mut_data_done callbacks.

source

fn add_data( &self, data: SubSlice<'static, u8>, ) -> Result<(), (ErrorCode, SubSlice<'static, u8>)>

Add data to the input of the hash function/digest. Ok indicates all of the active bytes in data will be added. There is no guarantee the data has been added to the digest until the add_data_done() callback is called. On error the cause of the error is returned along with the SubSlice unchanged (it has the same range of active bytes as the call). Valid ErrorCode values are:

  • OFF: the underlying digest engine is powered down and cannot be used.
  • BUSY: there is an outstanding add_data, add_data_mut, run, or verify operation, so the digest engine is busy and cannot accept more data.
  • SIZE: the active slice of the SubSlice has zero size.
source

fn add_mut_data( &self, data: SubSliceMut<'static, u8>, ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>)>

Add data to the input of the hash function/digest. Ok indicates all of the active bytes in data will be added. There is no guarantee the data has been added to the digest until the add_mut_data_done() callback is called. On error the cause of the error is returned along with the SubSlice unchanged (it has the same range of active bytes as the call). Valid ErrorCode values are:

  • OFF: the underlying digest engine is powered down and cannot be used.
  • BUSY: there is an outstanding add_data, add_data_mut, run, or verify operation, so the digest engine is busy and cannot accept more data.
  • SIZE: the active slice of the SubSlice has zero size.
source

fn clear_data(&self)

Clear the keys and any other internal state. Any pending operations terminate and issue a callback with an ErrorCode::CANCEL. This call does not clear buffers passed through add_mut_data, those are up to the client clear.

Implementors§