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
impl MACFactory
pub fn default(key: &impl KeyMaterial) -> Result<Self, FactoryError>
pub fn default_128_bit(key: &impl KeyMaterial) -> Result<Self, FactoryError>
pub fn default_256_bit(key: &impl KeyMaterial) -> Result<Self, FactoryError>
pub fn new(alg_name: &str, key: &impl KeyMaterial) -> Result<Self, FactoryError>
Trait Implementations§
Source§impl MAC for MACFactory
impl MAC for MACFactory
Source§fn new(_key: &impl KeyMaterial) -> Result<Self, MACError>
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>
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
fn output_len(&self) -> usize
The size of the output in bytes.
Source§fn mac(self, data: &[u8]) -> Vec<u8> ⓘ
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 moreSource§fn mac_out(self, data: &[u8], out: &mut [u8]) -> Result<usize, MACError>
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 moreSource§fn verify(self, data: &[u8], mac: &[u8]) -> bool
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 moreSource§fn do_update(&mut self, data: &[u8])
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.fn do_final(self) -> Vec<u8> ⓘ
Source§fn do_final_out(self, out: &mut [u8]) -> Result<usize, MACError>
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
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
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 Freeze for MACFactory
impl RefUnwindSafe for MACFactory
impl Send for MACFactory
impl Sync for MACFactory
impl Unpin for MACFactory
impl UnwindSafe for MACFactory
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