Skip to main content

MACFactory

Enum MACFactory 

Source
pub enum MACFactory {
    HMAC_SHA224(HMAC<SHA224>),
    HMAC_SHA256(HMAC<SHA256>),
    HMAC_SHA384(HMAC<SHA384>),
    HMAC_SHA512(HMAC<SHA512>),
    HMAC_SHA3_224(HMAC<SHA3_224>),
    HMAC_SHA3_256(HMAC<SHA3_256>),
    HMAC_SHA3_384(HMAC<SHA3_384>),
    HMAC_SHA3_512(HMAC<SHA3_512>),
}
Expand description

MACFactory deviates from the usual AlgorithmFactory trait because MAC objects do not have a no-arg constructor; instead they have a constructor that takes a KeyMaterial and can return an error.

Variants§

§

HMAC_SHA224(HMAC<SHA224>)

§

HMAC_SHA256(HMAC<SHA256>)

§

HMAC_SHA384(HMAC<SHA384>)

§

HMAC_SHA512(HMAC<SHA512>)

§

HMAC_SHA3_224(HMAC<SHA3_224>)

§

HMAC_SHA3_256(HMAC<SHA3_256>)

§

HMAC_SHA3_384(HMAC<SHA3_384>)

§

HMAC_SHA3_512(HMAC<SHA3_512>)

Implementations§

Source§

impl MACFactory

Source

pub fn default(key: &impl KeyMaterial) -> Result<Self, FactoryError>

Source

pub fn default_128_bit(key: &impl KeyMaterial) -> Result<Self, FactoryError>

Source

pub fn default_256_bit(key: &impl KeyMaterial) -> Result<Self, FactoryError>

Source

pub fn new(alg_name: &str, key: &impl KeyMaterial) -> Result<Self, FactoryError>

Trait Implementations§

Source§

impl MAC for MACFactory

Source§

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

This is a dummy function, required by the MAC trait. Don’t call it, it doesn’t do anything.

Source§

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

This is a dummy function, required by the MAC trait. Don’t call it, it doesn’t do anything.

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§

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, 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.