Skip to main content

Hkdf

Struct Hkdf 

Source
pub struct Hkdf<MD: Algorithm>(/* private fields */);
Expand description

HKDF for any of the implemented hash functions. The aliases HkdfSha256 and HkdfSha512 are provided for the most common cases.

Implementations§

Source§

impl<MD: Algorithm> Hkdf<MD>

Source

pub const MAX_OUTPUT_LEN: usize

The maximum number of bytes of key material that can be produced.

Source

pub fn derive<const N: usize>( secret: &[u8], salt: Salt<'_>, info: &[u8], ) -> [u8; N]

Derive key material from the given secret, salt, and info. Attempting to derive more than 255 bytes is a compile-time error, see derive_into for longer outputs.

The semantics of the arguments are complex. See https://datatracker.ietf.org/doc/html/rfc5869#section-3.

Source

pub fn derive_into( secret: &[u8], salt: Salt<'_>, info: &[u8], out: &mut [u8], ) -> Result<(), TooLong>

Derive key material from the given secret, salt, and info. Attempting to derive more than MAX_OUTPUT_LEN bytes is a run-time error.

The semantics of the arguments are complex. See https://datatracker.ietf.org/doc/html/rfc5869#section-3.

Source

pub fn extract(secret: &[u8], salt: Salt<'_>) -> Prk

Extract a pseudo-random key from the given secret and salt. This can be used to avoid redoing computation when computing several keys that vary only in the info parameter.

Auto Trait Implementations§

§

impl<MD> Freeze for Hkdf<MD>

§

impl<MD> RefUnwindSafe for Hkdf<MD>
where MD: RefUnwindSafe,

§

impl<MD> Send for Hkdf<MD>
where MD: Send,

§

impl<MD> Sync for Hkdf<MD>
where MD: Sync,

§

impl<MD> Unpin for Hkdf<MD>
where MD: Unpin,

§

impl<MD> UnsafeUnpin for Hkdf<MD>

§

impl<MD> UnwindSafe for Hkdf<MD>
where MD: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.