crypto_mac

Trait Mac

Source
pub trait Mac: Clone {
    type OutputSize: ArrayLength<u8>;

    // Required methods
    fn update(&mut self, data: &[u8]);
    fn reset(&mut self);
    fn finalize(self) -> Output<Self>;

    // Provided methods
    fn finalize_reset(&mut self) -> Output<Self> { ... }
    fn verify(self, tag: &[u8]) -> Result<(), MacError> { ... }
}
Expand description

The Mac trait defines methods for a Message Authentication algorithm.

Required Associated Types§

Source

type OutputSize: ArrayLength<u8>

Output size of the [Mac]

Required Methods§

Source

fn update(&mut self, data: &[u8])

Update MAC state with the given data.

Source

fn reset(&mut self)

Reset Mac instance.

Source

fn finalize(self) -> Output<Self>

Obtain the result of a Mac computation as a Output and consume Mac instance.

Provided Methods§

Source

fn finalize_reset(&mut self) -> Output<Self>

Obtain the result of a Mac computation as a Output and reset Mac instance.

Source

fn verify(self, tag: &[u8]) -> Result<(), MacError>

Check if tag/code value is correct for the processed input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§