logo
pub trait Mac: OutputSizeUser + Sized {
    fn new(key: &Key<Self>) -> Self
   where
        Self: KeyInit
; fn generate_key(rng: impl CryptoRng + RngCore) -> Key<Self>
   where
        Self: KeyInit
; fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
   where
        Self: KeyInit
; fn update(&mut self, data: &[u8]); fn chain_update(self, data: impl AsRef<[u8]>) -> Self; fn finalize(self) -> CtOutput<Self>; fn finalize_reset(&mut self) -> CtOutput<Self>
   where
        Self: FixedOutputReset
; fn reset(&mut self)
   where
        Self: Reset
; fn verify(self, tag: &Output<Self>) -> Result<(), MacError>; fn verify_slice(self, tag: &[u8]) -> Result<(), MacError>; fn verify_truncated_left(self, tag: &[u8]) -> Result<(), MacError>; fn verify_truncated_right(self, tag: &[u8]) -> Result<(), MacError>; }
Available on crate feature mac only.
Expand description

Convinience wrapper trait covering functionality of Message Authentication algorithms.

This trait wraps KeyInit, Update, FixedOutput, and MacMarker traits and provides additional convenience methods.

Required Methods

Create new value from fixed size key.

Available on crate feature rand_core only.

Generate random key using the provided CryptoRng.

Create new value from variable size key.

Update state using the provided data.

Process input data in a chained manner.

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

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

Reset MAC instance to its initial state.

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

Check truncated tag correctness using all bytes of calculated tag.

Returns Error if tag is not valid or not equal in length to MAC’s output.

Check truncated tag correctness using left side bytes (i.e. tag[..n]) of calculated tag.

Returns Error if tag is not valid or empty.

Check truncated tag correctness using right side bytes (i.e. tag[n..]) of calculated tag.

Returns Error if tag is not valid or empty.

Implementors