hmac

Trait Mac

Source
pub trait Mac: Sized + OutputSizeUser {
Show 13 methods // Required methods fn new(key: &GenericArray<u8, Self::KeySize>) -> 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: &GenericArray<u8, Self::OutputSize>, ) -> Result<(), MacError>; fn verify_reset( &mut self, tag: &GenericArray<u8, Self::OutputSize>, ) -> Result<(), MacError> where Self: FixedOutputReset; fn verify_slice(self, tag: &[u8]) -> Result<(), MacError>; fn verify_slice_reset(&mut self, tag: &[u8]) -> Result<(), MacError> where Self: FixedOutputReset; fn verify_truncated_left(self, tag: &[u8]) -> Result<(), MacError>; fn verify_truncated_right(self, tag: &[u8]) -> Result<(), MacError>;
}
Expand description

Convenience wrapper trait covering functionality of Message Authentication algorithms.

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

Required Methods§

Source

fn new(key: &GenericArray<u8, Self::KeySize>) -> Self
where Self: KeyInit,

Create new value from fixed size key.

Source

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
where Self: KeyInit,

Create new value from variable size key.

Source

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

Update state using the provided data.

Source

fn chain_update(self, data: impl AsRef<[u8]>) -> Self

Process input data in a chained manner.

Source

fn finalize(self) -> CtOutput<Self>

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

Source

fn finalize_reset(&mut self) -> CtOutput<Self>
where Self: FixedOutputReset,

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

Source

fn reset(&mut self)
where Self: Reset,

Reset MAC instance to its initial state.

Source

fn verify( self, tag: &GenericArray<u8, Self::OutputSize>, ) -> Result<(), MacError>

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

Source

fn verify_reset( &mut self, tag: &GenericArray<u8, Self::OutputSize>, ) -> Result<(), MacError>
where Self: FixedOutputReset,

Check if tag/code value is correct for the processed input and reset Mac instance.

Source

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

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.

Source

fn verify_slice_reset(&mut self, tag: &[u8]) -> Result<(), MacError>
where Self: FixedOutputReset,

Check truncated tag correctness using all bytes of calculated tag and reset Mac instance.

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

Source

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

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

Returns Error if tag is not valid or empty.

Source

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

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

Returns Error if tag is not valid or empty.

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§

Source§

impl<T> Mac for T