pub struct HmacSm3 { /* private fields */ }Expand description
Streaming HMAC-SM3 (v0.3 W5).
Construct with new(&key), feed message chunks via update,
finalize with finalize (32-byte tag) or verify (constant-
time compare against an expected tag).
Equivalent to hmac_sm3 for the same (key, message) byte
sequence — chunking does not affect the output.
§Zeroization
The keyed inner / outer Sm3 states (the SM3 compression
state after absorbing K' XOR ipad / K' XOR opad) hold
key-derived material. They are wiped at the field layer by
Sm3’s own Drop impl (v0.23): whenever an HmacSm3 — or the
Sm3 values moved out of it by HmacSm3::finalize — is dropped,
the compression state + input buffer are scrubbed. There is no
impl Drop for HmacSm3 (and there must not be: finalize(self)
moves the inner/outer fields out of self, which a Drop impl
would forbid). Construction-time intermediates (K', K' XOR ipad,
K' XOR opad) are zeroized inside HmacSm3::new after they are
folded into the keyed states. The 32-byte tag returned by
HmacSm3::finalize is the public output and is not wiped.
Implementations§
Source§impl HmacSm3
impl HmacSm3
Sourcepub fn new(key: &[u8]) -> Self
pub fn new(key: &[u8]) -> Self
Construct a new keyed HMAC-SM3 instance.
key may be any length; the standard RFC 2104 hash-first
reduction applies for key.len() > 64. Both intermediate
K' / K' XOR ipad / K' XOR opad buffers are zeroized
after the inner/outer SM3 instances absorb them.
Sourcepub fn finalize(self) -> [u8; 32]
pub fn finalize(self) -> [u8; 32]
Consume the instance and produce the 32-byte MAC tag.
self.inner is finalized (by value) into the inner digest and
self.outer is moved out, fed the inner digest, and finalized.
Both keyed Sm3 values are scrubbed by Sm3’s Drop impl
(v0.23) when they go out of scope here; the returned tag is the
public output.