pub struct HMAC<HASH: Hash + Default> { /* private fields */ }Trait Implementations§
Source§impl<HASH: Hash + Default> MAC for HMAC<HASH>
impl<HASH: Hash + Default> MAC for HMAC<HASH>
Source§fn new(key: &impl KeyMaterial) -> Result<Self, MACError>
fn new(key: &impl KeyMaterial) -> Result<Self, MACError>
Create a new MAC instance with the given key. Read more
Source§fn new_allow_weak_key(key: &impl KeyMaterial) -> Result<Self, MACError>
fn new_allow_weak_key(key: &impl KeyMaterial) -> Result<Self, MACError>
Create a new HMAC instance with the given key. Read more
Source§fn output_len(&self) -> usize
fn output_len(&self) -> usize
The size of the output in bytes.
Source§fn mac(self, data: &[u8]) -> Vec<u8> ⓘ
fn mac(self, data: &[u8]) -> Vec<u8> ⓘ
One-shot API that computes a MAC for the provided data.
data can be of any length, including zero bytes. Read moreSource§fn mac_out(self, data: &[u8], out: &mut [u8]) -> Result<usize, MACError>
fn mac_out(self, data: &[u8], out: &mut [u8]) -> Result<usize, MACError>
One-shot API that computes a MAC for the provided data and writes it into the provided output slice.
data can be of any length, including zero bytes. Read moreSource§fn verify(self, data: &[u8], mac: &[u8]) -> bool
fn verify(self, data: &[u8], mac: &[u8]) -> bool
One-shot API that verifies a MAC for the provided data.
data can be of any length, including zero bytes. Read moreSource§fn do_update(&mut self, data: &[u8])
fn do_update(&mut self, data: &[u8])
Provide a chunk of data to be absorbed into the MAC.
data can be of any length, including zero bytes.
do_update() is intended to be used as part of a streaming interface, and so may by called multiple times.fn do_final(self) -> Vec<u8> ⓘ
Source§fn do_final_out(self, out: &mut [u8]) -> Result<usize, MACError>
fn do_final_out(self, out: &mut [u8]) -> Result<usize, MACError>
Depending on the underlying MAC implementation, NIST may require that the library enforce
a minimum length on the mac output value. See documentation for the underlying implementation
to see conditions under which it throws MACError::InvalidLength.
Source§fn do_verify_final(self, mac: &[u8]) -> bool
fn do_verify_final(self, mac: &[u8]) -> bool
Internally, this will re-compute the MAC value and then compare it to the provided mac value
using constant-time comparison. It is highly encouraged to use this utility function instead of
comparing mac values for equality yourself. Read more
Source§fn max_security_strength(&self) -> SecurityStrength
fn max_security_strength(&self) -> SecurityStrength
Returns the maximum security strength that this KDF is capable of supporting, based on the underlying primitives.
Auto Trait Implementations§
impl<HASH> Freeze for HMAC<HASH>where
HASH: Freeze,
impl<HASH> RefUnwindSafe for HMAC<HASH>where
HASH: RefUnwindSafe,
impl<HASH> Send for HMAC<HASH>where
HASH: Send,
impl<HASH> Sync for HMAC<HASH>where
HASH: Sync,
impl<HASH> Unpin for HMAC<HASH>where
HASH: Unpin,
impl<HASH> UnwindSafe for HMAC<HASH>where
HASH: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more