pub struct HmacSha256 { /* private fields */ }Available on (crate features
mac-hmac or mac-blake3) and crate feature mac-hmac only.Expand description
Streaming HMAC-SHA256 for inputs that don’t fit in memory.
Construct with HmacSha256::new, absorb data with
update, finalise with finalize
(returns the 32-byte tag) or verify (constant-time
compare against an expected tag).
§Example
use crypt_io::mac::HmacSha256;
let mut m = HmacSha256::new(b"shared key")?;
m.update(b"first chunk ");
m.update(b"second chunk");
let tag = m.finalize();
assert_eq!(tag.len(), 32);Implementations§
Source§impl HmacSha256
impl HmacSha256
Sourcepub fn new(key: &[u8]) -> Result<Self>
pub fn new(key: &[u8]) -> Result<Self>
Construct a fresh hasher under key.
§Errors
Returns Error::Mac if the upstream hmac crate refuses the key.
Unreachable in practice (HMAC accepts any key length).
Sourcepub fn update(&mut self, data: &[u8]) -> &mut Self
pub fn update(&mut self, data: &[u8]) -> &mut Self
Absorb data into the running MAC. Returns &mut Self so calls
can chain.
Trait Implementations§
Source§impl Clone for HmacSha256
impl Clone for HmacSha256
Source§fn clone(&self) -> HmacSha256
fn clone(&self) -> HmacSha256
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HmacSha256
impl RefUnwindSafe for HmacSha256
impl Send for HmacSha256
impl Sync for HmacSha256
impl Unpin for HmacSha256
impl UnsafeUnpin for HmacSha256
impl UnwindSafe for HmacSha256
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