Trait crypto_mac::Mac [−][src]
pub trait Mac: Sized { type OutputSize: ArrayLength<u8>; fn new(key: &[u8]) -> Result<Self, InvalidKeyLength>; fn input(&mut self, data: &[u8]); fn result(self) -> MacResult<Self::OutputSize>; fn verify(self, code: &[u8]) -> Result<(), MacError> { ... } }
The Mac
trait defines methods for a Message Authentication algorithm.
Associated Types
type OutputSize: ArrayLength<u8>
Required Methods
fn new(key: &[u8]) -> Result<Self, InvalidKeyLength>
Create new MAC instance. DO NOT USE low-entropy keys (e.g. passwords)!
For low-entropy keys first use an appropriate key derivation function (KDF), e.g. argon2, scrypt or PBKDF2
fn input(&mut self, data: &[u8])
Process input data.
fn result(self) -> MacResult<Self::OutputSize>
Obtain the result of a Mac
computation as a MacResult
.
Provided Methods
fn verify(self, code: &[u8]) -> Result<(), MacError>
Check if code is correct for the processed input