pub trait DigestHash<'a, const L: usize> {
    fn run(
        &'a self,
        digest: &'static mut [u8; L]
    ) -> Result<(), (ErrorCode, &'static mut [u8; L])>; fn set_hash_client(&'a self, client: &'a dyn ClientHash<L>) { ... } }
Expand description

Computes a digest (cryptographic hash) over data provided through a separate trait.

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

Required Methods

Compute a digest of all of the data added with add_data and add_data_mut, storing the computed value in digest. The computed value is returned in a hash_done callback. On error the return value will contain a return code and the slice passed in digest. 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 LeasableBuffer has zero size.
  • NOSUPPORT: the currently selected digest algorithm is not supported.

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 ErrorCode::NOSUPPORT.

Provided Methods

Set the client instance which will receive the hash_done() callback. This is not required if using the set_client() fuction from the Digest trait.

Implementors