pub trait Mac: Sized {
type Key: AsRef<[u8]> + AsMut<[u8]> + Clone + Zeroize;
type Tag: AsRef<[u8]> + AsMut<[u8]> + Clone;
// Required methods
fn new(key: &[u8]) -> Result<Self>;
fn update(&mut self, data: &[u8]) -> Result<&mut Self>;
fn finalize(&mut self) -> Result<Self::Tag>;
fn reset(&mut self) -> Result<()>;
// Provided methods
fn compute_tag(key: &[u8], data: &[u8]) -> Result<Self::Tag> { ... }
fn verify_tag(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool> { ... }
}Expand description
Trait for Message Authentication Code (MAC) algorithms
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn verify_tag(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool>
fn verify_tag(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool>
Verify a MAC tag with equal-length byte comparison that avoids early exit.
Public lengths and errors use ordinary control flow; this is not a whole-operation constant-time guarantee. This reusable-key trait must not be implemented by one-time authenticators such as Poly1305.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".