Skip to main content

HMAC

Struct HMAC 

Source
pub struct HMAC<HASH: Hash + Default> { /* private fields */ }

Trait Implementations§

Source§

impl<HASH: Clone + Hash + Default> Clone for HMAC<HASH>

Source§

fn clone(&self) -> HMAC<HASH>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<HASH: Hash + Default> MAC for HMAC<HASH>

Source§

fn new(key: &impl KeyMaterial) -> Result<Self, MACError>

Create a new MAC instance with the given key. Read more
Source§

fn new_allow_weak_key(key: &impl KeyMaterial) -> Result<Self, MACError>

Create a new HMAC instance with the given key. Read more
Source§

fn output_len(&self) -> usize

The size of the output in bytes.
Source§

fn mac(self, data: &[u8]) -> Vec<u8>

One-shot API that computes a MAC for the provided data. data can be of any length, including zero bytes. Read more
Source§

fn mac_out(self, data: &[u8], out: &mut [u8]) -> Result<usize, MACError>

One-shot API that computes a MAC for the provided data and writes it into the provided output slice. data can be of any length, including zero bytes. Read more
Source§

fn verify(self, data: &[u8], mac: &[u8]) -> bool

One-shot API that verifies a MAC for the provided data. data can be of any length, including zero bytes. Read more
Source§

fn do_update(&mut self, data: &[u8])

Provide a chunk of data to be absorbed into the MAC. data can be of any length, including zero bytes. do_update() is intended to be used as part of a streaming interface, and so may by called multiple times.
Source§

fn do_final(self) -> Vec<u8>

Source§

fn do_final_out(self, out: &mut [u8]) -> Result<usize, MACError>

Depending on the underlying MAC implementation, NIST may require that the library enforce a minimum length on the mac output value. See documentation for the underlying implementation to see conditions under which it throws MACError::InvalidLength.
Source§

fn do_verify_final(self, mac: &[u8]) -> bool

Internally, this will re-compute the MAC value and then compare it to the provided mac value using constant-time comparison. It is highly encouraged to use this utility function instead of comparing mac values for equality yourself. Read more
Source§

fn max_security_strength(&self) -> SecurityStrength

Returns the maximum security strength that this KDF is capable of supporting, based on the underlying primitives.

Auto Trait Implementations§

§

impl<HASH> Freeze for HMAC<HASH>
where HASH: Freeze,

§

impl<HASH> RefUnwindSafe for HMAC<HASH>
where HASH: RefUnwindSafe,

§

impl<HASH> Send for HMAC<HASH>
where HASH: Send,

§

impl<HASH> Sync for HMAC<HASH>
where HASH: Sync,

§

impl<HASH> Unpin for HMAC<HASH>
where HASH: Unpin,

§

impl<HASH> UnwindSafe for HMAC<HASH>
where HASH: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.