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 pre-computed outer keyed-state (SM3 after absorbing
K' XOR opad) holds key-derived material. HmacSm3::finalize
and HmacSm3::verify consume self and zeroize it before
returning. If the caller drops the HmacSm3 without calling
either method, the Drop impl wipes the state.
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.
The outer keyed-state and the inner final state are both
dropped after consuming self; Sm3’s Drop impl is the
one we rely on here. To be defensive against a future change
where Sm3 is no longer ZeroizeOnDrop, both fields are
explicitly wiped via clone-then-drop would be safer — but
Sm3 does not currently implement Zeroize directly. The
state is consumed by outer.finalize() which produces the
public output and discards the rest.
Trait Implementations§
Source§impl FixedOutput for HmacSm3
impl FixedOutput for HmacSm3
Source§fn finalize_into(self, out: &mut Output<Self>)
fn finalize_into(self, out: &mut Output<Self>)
Source§fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
Source§impl KeyInit for HmacSm3
impl KeyInit for HmacSm3
Source§fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Source§impl KeySizeUser for HmacSm3
impl KeySizeUser for HmacSm3
Source§impl OutputSizeUser for HmacSm3
impl OutputSizeUser for HmacSm3
impl MacMarker for HmacSm3
Auto Trait Implementations§
impl Freeze for HmacSm3
impl RefUnwindSafe for HmacSm3
impl Send for HmacSm3
impl Sync for HmacSm3
impl Unpin for HmacSm3
impl UnsafeUnpin for HmacSm3
impl UnwindSafe for HmacSm3
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
Source§impl<T> Mac for T
impl<T> Mac for T
Source§fn new(key: &GenericArray<u8, <T as KeySizeUser>::KeySize>) -> Twhere
T: KeyInit,
fn new(key: &GenericArray<u8, <T as KeySizeUser>::KeySize>) -> Twhere
T: KeyInit,
Source§fn new_from_slice(key: &[u8]) -> Result<T, InvalidLength>where
T: KeyInit,
fn new_from_slice(key: &[u8]) -> Result<T, InvalidLength>where
T: KeyInit,
Source§fn chain_update(self, data: impl AsRef<[u8]>) -> T
fn chain_update(self, data: impl AsRef<[u8]>) -> T
Source§fn finalize_reset(&mut self) -> CtOutput<T>where
T: FixedOutputReset,
fn finalize_reset(&mut self) -> CtOutput<T>where
T: FixedOutputReset,
Source§fn verify(
self,
tag: &GenericArray<u8, <T as OutputSizeUser>::OutputSize>,
) -> Result<(), MacError>
fn verify( self, tag: &GenericArray<u8, <T as OutputSizeUser>::OutputSize>, ) -> Result<(), MacError>
Source§fn verify_reset(
&mut self,
tag: &GenericArray<u8, <T as OutputSizeUser>::OutputSize>,
) -> Result<(), MacError>where
T: FixedOutputReset,
fn verify_reset(
&mut self,
tag: &GenericArray<u8, <T as OutputSizeUser>::OutputSize>,
) -> Result<(), MacError>where
T: FixedOutputReset,
Mac instance.