Skip to main content

HkdfBuilder

Struct HkdfBuilder 

Source
pub struct HkdfBuilder<'a> { /* private fields */ }
Expand description

HKDF key-derivation builder (RFC 5869).

let okm = HkdfBuilder::new(&sha256)
    .key(ikm)
    .salt(salt)
    .info(info)
    .derive_to_vec(32)?;

Implementations§

Source§

impl<'a> HkdfBuilder<'a>

Source

pub fn new(digest: &'a DigestAlg) -> Self

Create an HKDF builder bound to digest.

The mode defaults to ExtractAndExpand.

Source

pub fn key(self, key: &'a [u8]) -> Self

Set the input keying material (IKM).

Source

pub fn salt(self, salt: &'a [u8]) -> Self

Set the salt (optional; defaults to zero-length within OpenSSL).

Source

pub fn info(self, info: &'a [u8]) -> Self

Set the context/application-specific information bytes.

Source

pub fn mode(self, mode: HkdfMode) -> Self

Override the default extract-and-expand mode.

Source

pub fn derive(self, out: &mut [u8]) -> Result<(), ErrorStack>

Derive key material, writing into out.

§Errors
Source

pub fn derive_to_vec(self, len: usize) -> Result<Vec<u8>, ErrorStack>

Derive len bytes of key material, returning them in a freshly allocated Vec<u8>.

§Errors

Auto Trait Implementations§

§

impl<'a> Freeze for HkdfBuilder<'a>

§

impl<'a> RefUnwindSafe for HkdfBuilder<'a>

§

impl<'a> Send for HkdfBuilder<'a>

§

impl<'a> Sync for HkdfBuilder<'a>

§

impl<'a> Unpin for HkdfBuilder<'a>

§

impl<'a> UnsafeUnpin for HkdfBuilder<'a>

§

impl<'a> UnwindSafe for HkdfBuilder<'a>

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.