Trait crypto_mac::Mac
source · [−]pub trait Mac: Clone {
type OutputSize: ArrayLength<u8>;
type KeySize: ArrayLength<u8>;
fn new(key: &GenericArray<u8, Self::KeySize>) -> Self;
fn input(&mut self, data: &[u8]);
fn reset(&mut self);
fn result(self) -> MacResult<Self::OutputSize>;
fn new_varkey(key: &[u8]) -> Result<Self, InvalidKeyLength> { ... }
fn result_reset(&mut self) -> MacResult<Self::OutputSize> { ... }
fn verify(self, code: &[u8]) -> Result<(), MacError> { ... }
}Expand description
The Mac trait defines methods for a Message Authentication algorithm.
Associated Types
type OutputSize: ArrayLength<u8>
type KeySize: ArrayLength<u8>
Required methods
fn new(key: &GenericArray<u8, Self::KeySize>) -> Self
fn new(key: &GenericArray<u8, Self::KeySize>) -> Self
Create new MAC instance from key with fixed size.
fn result(self) -> MacResult<Self::OutputSize>
fn result(self) -> MacResult<Self::OutputSize>
Obtain the result of a Mac computation as a MacResult and consume
Mac instance.
Provided methods
fn new_varkey(key: &[u8]) -> Result<Self, InvalidKeyLength>
fn new_varkey(key: &[u8]) -> Result<Self, InvalidKeyLength>
Create new MAC instance from key with variable size.
Default implementation will accept only keys with length equal to
KeySize, but some MACs can accept range of key lengths.
fn result_reset(&mut self) -> MacResult<Self::OutputSize>
fn result_reset(&mut self) -> MacResult<Self::OutputSize>
Obtain the result of a Mac computation as a MacResult and reset
Mac instance.
