Skip to main content

Kmac256

Struct Kmac256 

Source
pub struct Kmac256 { /* private fields */ }
Expand description

KMAC256 message authentication code (SP 800-185).

Variable-length output; the default output length is 64 bytes. Uses a customization string (may be empty) for domain separation.

Implementations§

Source§

impl Kmac256

Source

pub fn new(custom: &[u8], output_len: usize) -> Result<Self, CryptoError>

Create a new KMAC256 with the given customization string and output length.

Returns CryptoError::BadInput if output_len is 0.

Trait Implementations§

Source§

impl Debug for Kmac256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mac for Kmac256

Source§

fn name(&self) -> &'static str

Human-readable algorithm identifier (e.g. "HMAC-SHA-256").
Source§

fn key_len(&self) -> usize

Required key length (minimum acceptable length; MACs are often variable).
Source§

fn output_len(&self) -> usize

Output tag length in bytes.
Source§

fn mac(&self, key: &[u8], msg: &[u8], out: &mut [u8]) -> Result<(), CryptoError>

Compute a MAC tag for msg under key and write it into out.
Source§

fn verify(&self, key: &[u8], msg: &[u8], tag: &[u8]) -> Result<(), CryptoError>

Verify a MAC tag in constant time. Read more
Source§

fn mac_to_vec(&self, key: &[u8], msg: &[u8]) -> Result<Vec<u8>, CryptoError>

Convenience: compute MAC and return the tag as a Vec<u8>.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.