crypto_mac

Trait NewMac

Source
pub trait NewMac: Sized {
    type KeySize: ArrayLength<u8>;

    // Required method
    fn new(key: &Key<Self>) -> Self;

    // Provided method
    fn new_from_slice(key: &[u8]) -> Result<Self, InvalidKeyLength> { ... }
}
Expand description

Instantiate a Mac algorithm.

Required Associated Types§

Source

type KeySize: ArrayLength<u8>

Key size in bytes with which cipher guaranteed to be initialized.

Required Methods§

Source

fn new(key: &Key<Self>) -> Self

Initialize new MAC instance from key with fixed size.

Provided Methods§

Source

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidKeyLength>

Initialize new MAC instance from key with variable size.

Default implementation will accept only keys with length equal to KeySize, but some MACs can accept range of key lengths.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> NewMac for T

Available on crate feature cipher only.