pub struct Context { /* private fields */ }Expand description
A context for multi-step (Init-Update-Finish) CMAC signing.
Use sign for single-step CMAC signing.
Implementations§
Source§impl Context
impl Context
Sourcepub fn update(&mut self, data: &[u8]) -> Result<(), Unspecified>
pub fn update(&mut self, data: &[u8]) -> Result<(), Unspecified>
Updates the CMAC with all the data in data. update may be called
zero or more times until sign is called.
§Errors
error::Unspecified if the CMAC cannot be updated.
Sourcepub fn sign(self) -> Result<Tag, Unspecified>
pub fn sign(self) -> Result<Tag, Unspecified>
Finalizes the CMAC calculation and returns the CMAC value. sign
consumes the context so it cannot be (mis-)used after sign has been
called.
It is generally not safe to implement CMAC verification by comparing
the return value of sign to a tag. Use verify for verification
instead.
§Errors
error::Unspecified if the CMAC calculation cannot be finalized.
§Panics
Panics if the CMAC tag length exceeds the maximum allowed length, indicating memory corruption.
Sourcepub fn verify(self, tag: &[u8]) -> Result<(), Unspecified>
pub fn verify(self, tag: &[u8]) -> Result<(), Unspecified>
Finalizes the CMAC calculation and verifies whether the resulting value
equals the provided tag.
verify consumes the context so it cannot be (mis-)used after verify
has been called.
The verification is done in constant time to prevent timing attacks.
§Errors
error::Unspecified if the tag does not match or if CMAC calculation fails.