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§
type Algorithm: HmacAlgorithm
Required Methods§
Sourcefn load_from_keydata(
&mut self,
algorithm: Self::Algorithm,
key: &[u8],
) -> Self::Key
fn load_from_keydata( &mut self, algorithm: Self::Algorithm, key: &[u8], ) -> Self::Key
Initializes a key from raw bytes.
fn update(&mut self, state: &mut Self::State, data: &[u8])
fn finalize(&mut self, state: Self::State) -> Self::Output
Provided Methods§
Sourcefn init_with_keydata(
&mut self,
algorithm: Self::Algorithm,
key: &[u8],
) -> Self::State
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)).
Sourcefn hmac_with_keydata(
&mut self,
algorithm: Self::Algorithm,
key: &[u8],
data: &[u8],
) -> Self::Output
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".