Skip to main content

HmacProvider

Trait HmacProvider 

Source
pub trait HmacProvider {
    type Algorithm: HmacAlgorithm;
    type Key: Clone + Sized;
    type State: Sized;
    type Output: AsRef<[u8]>;

    // Required methods
    fn load_from_keydata(
        &mut self,
        algorithm: Self::Algorithm,
        key: &[u8],
    ) -> Self::Key;
    fn init(&mut self, key: Self::Key) -> Self::State;
    fn update(&mut self, state: &mut Self::State, data: &[u8]);
    fn finalize(&mut self, state: Self::State) -> Self::Output;

    // Provided methods
    fn init_with_keydata(
        &mut self,
        algorithm: Self::Algorithm,
        key: &[u8],
    ) -> Self::State { ... }
    fn hmac_with_keydata(
        &mut self,
        algorithm: Self::Algorithm,
        key: &[u8],
        data: &[u8],
    ) -> Self::Output { ... }
}
Expand description

Message authentication based on hashes.

Required Associated Types§

Source

type Algorithm: HmacAlgorithm

Source

type Key: Clone + Sized

A nascent state that has only received a key as input.

Source

type State: Sized

State carried between rounds of feeding data into the HMAC.

Source

type Output: AsRef<[u8]>

Output of an HMAC operation.

Required Methods§

Source

fn load_from_keydata( &mut self, algorithm: Self::Algorithm, key: &[u8], ) -> Self::Key

Initializes a key from raw bytes.

Source

fn init(&mut self, key: Self::Key) -> Self::State

Starts an HMAC operation.

Source

fn update(&mut self, state: &mut Self::State, data: &[u8])

Source

fn finalize(&mut self, state: Self::State) -> Self::Output

Provided Methods§

Source

fn init_with_keydata( &mut self, algorithm: Self::Algorithm, key: &[u8], ) -> Self::State

Starts an HMAC operation based on a key that is entered as raw bytes.

This is a convenience wrapper for Self::init(Self::load_from_keydatra(algorithm, key)).

Source

fn hmac_with_keydata( &mut self, algorithm: Self::Algorithm, key: &[u8], data: &[u8], ) -> Self::Output

Compute HMAC over contiguous in-memory data in a single pass, based on a key directly entered as bytes.

This is a shortcut for self.init_with_keydata(…) / self.update(…) / self.finalize(…).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§