Skip to main content

Blake3

Struct Blake3 

Source
pub struct Blake3;
Expand description

BLAKE3 single-stage KDF (unofficial KDF id 0xFF01).

BLAKE3 is an extendable-output function, so it is used exactly like Shake256: the key schedule is built from a single Kdf::labeled_derive call whose Derive primitive is the BLAKE3 XOF. The output size is 32 bytes.

§Interoperability

BLAKE3 is not registered in the IANA “HPKE KDF Identifiers” registry and is not specified by any HPKE standard. The identifier 0xFF01 is an stdx-private, unofficial value chosen to stay clear of the low IDs IANA is likely to assign to future official KDFs; ciphersuites using this KDF only interoperate with implementations that adopt the same convention.

§Example

use hpke::kdf::{Blake3, Kdf};

let suite_id = b"HPKE\x64\x7a\xff\x01\x00\x03";
let mut output_keying_material = [0u8; 32];
Blake3::labeled_derive(&mut output_keying_material, &[b"ikm"], suite_id, b"label", &[b"info"]).unwrap();

Trait Implementations§

Source§

impl Clone for Blake3

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Blake3

Source§

impl Debug for Blake3

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Blake3

Source§

impl Kdf for Blake3

Source§

const HPKE_KDF_ID: u16 = 0xFF01

The HPKE KDF identifier (draft-ietf-hpke-hpke-05 Section 7.2, IANA “HPKE KDF Identifiers”), used to build the ciphersuite suite_id.
Source§

const SINGLE_STAGE: bool = true

Whether this is a single-stage KDF (draft-ietf-hpke-hpke-05 Section 4). Read more
Source§

type Hash = Blake3

The hash function underlying the default HKDF construction.
Source§

fn labeled_derive( out: &mut [u8], input_keying_material: &[&[u8]], suite_id: &[u8], label: &[u8], context: &[&[u8]], ) -> Result<(), HpkeError>

draft-ietf-hpke-hpke-05 Section 4.4 LabeledDerive(input_keying_material, label, context, L): Derive(input_keying_material || "HPKE-v1" || suite_id || I2OSP(len(label), 2) || label || I2OSP(L, 2) || context, L), where L == out.len() and the elements of input_keying_material and context are absorbed in order. Read more
Source§

const OUTPUT_SIZE: usize = <Self::Hash as crypto::Hasher>::OUTPUT_SIZE

Output size of the extract step (the hash output size). Read more
Source§

fn labeled_extract( salt: &[u8], suite_id: &[u8], label: &[u8], input_keying_material: &[u8], ) -> Hash

draft-ietf-hpke-hpke-05 Section 4.4 LabeledExtract(salt, label, input_keying_material): Extract(salt, "HPKE-v1" || suite_id || label || input_keying_material). Read more
Source§

fn labeled_expand( out: &mut [u8], pseudorandom_key: &[u8], suite_id: &[u8], label: &[u8], info: &[u8], ) -> Result<(), HpkeError>

draft-ietf-hpke-hpke-05 Section 4.4 LabeledExpand(pseudorandom_key, label, info, L): Expand(pseudorandom_key, I2OSP(L, 2) || "HPKE-v1" || suite_id || label || info, L), where L == out.len(). The info string is absorbed incrementally, so it may be arbitrarily long. Read more
Source§

impl PartialEq for Blake3

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Blake3

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.