pub struct HmacSha256(/* private fields */);Expand description
HMAC-SHA256.
Implementations§
Source§impl HmacSha256
impl HmacSha256
Sourcepub fn mac(key: &[u8], data: &[u8]) -> [u8; 32]
pub fn mac(key: &[u8], data: &[u8]) -> [u8; 32]
Computes the HMAC-SHA256 of data as a one-shot operation.
Sourcepub fn new(key: &[u8; 32]) -> Self
pub fn new(key: &[u8; 32]) -> Self
Creates a new HMAC-SHA256 operation from a fixed-length key.
Sourcepub fn new_from_slice(key: &[u8]) -> Self
pub fn new_from_slice(key: &[u8]) -> Self
Creates a new HMAC-SHA256 operation from a variable-length key.
Sourcepub fn verify_slice(self, tag: &[u8]) -> Result<(), InvalidSignatureError>
pub fn verify_slice(self, tag: &[u8]) -> Result<(), InvalidSignatureError>
Checks that the provided tag value matches the computed HMAC value.
Sourcepub fn verify(self, tag: &[u8; 32]) -> Result<(), InvalidSignatureError>
pub fn verify(self, tag: &[u8; 32]) -> Result<(), InvalidSignatureError>
Checks that the provided tag value matches the computed HMAC value.
Sourcepub fn verify_truncated_left(
self,
tag: &[u8],
) -> Result<(), InvalidSignatureError>
pub fn verify_truncated_left( self, tag: &[u8], ) -> Result<(), InvalidSignatureError>
Checks that the provided tag value matches the computed HMAC, truncated to the input tag’s length.
Truncating an HMAC reduces the security of the construction. Callers must ensure tag’s
length matches the desired HMAC length and security level.
Trait Implementations§
Auto 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