Skip to main content

HkdfProvider

Trait HkdfProvider 

Source
pub trait HkdfProvider: HmacProvider {
    // Required methods
    fn hkdf_extract(
        &mut self,
        alg: <Self as HmacProvider>::Algorithm,
        salt: Option<&[u8]>,
        ikm: &[u8],
    ) -> Result<impl AsRef<[u8]> + use<Self>, HkdfError>;
    fn hkdf_expand(
        &mut self,
        alg: <Self as HmacProvider>::Algorithm,
        prk: &[u8],
        info: &[u8],
        okm: &mut [u8],
    ) -> Result<(), HkdfError>;

    // Provided method
    fn hkdf(
        &mut self,
        alg: <Self as HmacProvider>::Algorithm,
        salt: Option<&[u8]>,
        ikm: &[u8],
        info: &[u8],
        okm: &mut [u8],
    ) -> Result<(), HkdfError> { ... }
}
Expand description

An interface for using HKDF (defined in RFC5869).

§Current status and roadmap

This interface is currently provided by a single blanket implementation, as none of the compoenents initially considered (hardware accelerators) do anything special about it.

This will be revisited when extending work on inextractable secrets to HKDF extraction output.

Until then, this interface uses no associated types; after that, it will at least have a type for the extract step’s output. It will likely not grow a dedicated Algorithm type, as HKDF is based on HMAC algorithms.

Required Methods§

Source

fn hkdf_extract( &mut self, alg: <Self as HmacProvider>::Algorithm, salt: Option<&[u8]>, ikm: &[u8], ) -> Result<impl AsRef<[u8]> + use<Self>, HkdfError>

HKDF-Extract (RFC 5869): returns a pseudorandom key.

When salt is None, a zero-filled byte string of HashLen bytes is used as the HMAC key (RFC 5869).

Source

fn hkdf_expand( &mut self, alg: <Self as HmacProvider>::Algorithm, prk: &[u8], info: &[u8], okm: &mut [u8], ) -> Result<(), HkdfError>

HKDF-Expand (RFC 5869): fills okm with derived key material.

Provided Methods§

Source

fn hkdf( &mut self, alg: <Self as HmacProvider>::Algorithm, salt: Option<&[u8]>, ikm: &[u8], info: &[u8], okm: &mut [u8], ) -> Result<(), HkdfError>

Extract then expand in one call.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§