pub trait DigestData<'a, const L: usize> {
fn add_data(
&self,
data: LeasableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableBuffer<'static, u8>)>;
fn add_mut_data(
&self,
data: LeasableMutableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableMutableBuffer<'static, u8>)>;
fn clear_data(&self);
fn set_data_client(&'a self, client: &'a dyn ClientData<L>) { ... }
}
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
fn add_data(
&self,
data: LeasableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableBuffer<'static, u8>)>
fn add_data(
&self,
data: LeasableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableBuffer<'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 LeasableBuffer
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
, orverify
operation, so the digest engine is busy and cannot accept more data. - SIZE: the active slice of the LeasableBuffer has zero size.
fn add_mut_data(
&self,
data: LeasableMutableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableMutableBuffer<'static, u8>)>
fn add_mut_data(
&self,
data: LeasableMutableBuffer<'static, u8>
) -> Result<(), (ErrorCode, LeasableMutableBuffer<'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
LeasableBuffer 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
, orverify
operation, so the digest engine is busy and cannot accept more data. - SIZE: the active slice of the LeasableBuffer has zero size.
fn clear_data(&self)
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.
Provided Methods
fn set_data_client(&'a self, client: &'a dyn ClientData<L>)
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. This is not required if
using the set_client()
fuction from the Digest
trait.