pub struct Hmac<H: HashFunction + Clone + Zeroize> { /* private fields */ }Expand description
HMAC implementation with constant-time tag-byte comparison.
Implementations§
Source§impl<H> Hmac<H>
impl<H> Hmac<H>
Sourcepub fn finalize(&mut self) -> Result<ZeroizingBytes>
pub fn finalize(&mut self) -> Result<ZeroizingBytes>
Finalise and return the tag.
Sourcepub fn verify(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool>
pub fn verify(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool>
Fixed-width verification of tag against key / data.
Tag bytes are accumulated without an early exit. Public lengths, hash errors, allocation, and the returned boolean still have ordinary control flow, so this is not a whole-operation constant-time guarantee.
Trait Implementations§
Source§impl<H> SecureZeroingType for Hmac<H>
impl<H> SecureZeroingType for Hmac<H>
impl<H: HashFunction + Clone + Zeroize> ZeroizeOnDrop for Hmac<H>
Auto Trait Implementations§
impl<H> Freeze for Hmac<H>where
H: Freeze,
impl<H> RefUnwindSafe for Hmac<H>where
H: RefUnwindSafe,
impl<H> Send for Hmac<H>where
H: Send,
impl<H> Sync for Hmac<H>where
H: Sync,
impl<H> Unpin for Hmac<H>where
H: Unpin,
impl<H> UnsafeUnpin for Hmac<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for Hmac<H>where
H: 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