pub struct Shake256;Expand description
SHAKE256 single-stage KDF (KDF id 0x0011), as specified in
draft-ietf-hpke-pq-05
Section 5.
SHAKE256 is a single-stage KDF with an output size of 64 bytes. It derives
the key schedule with a single Kdf::labeled_derive call instead of the
two-stage LabeledExtract/LabeledExpand construction, and is a natural
pairing with the hybrid post-quantum KEMs defined in the same draft.
§Example
use hpke::kdf::{Kdf, Shake256};
let suite_id = b"HPKE\x64\x7a\x00\x11\x00\x03";
let mut output_keying_material = [0u8; 32];
Shake256::labeled_derive(&mut output_keying_material, &[b"ikm"], suite_id, b"label", &[b"info"]).unwrap();Trait Implementations§
impl Copy for Shake256
impl Eq for Shake256
Source§impl Kdf for Shake256
impl Kdf for Shake256
Source§const HPKE_KDF_ID: u16 = 0x0011
const HPKE_KDF_ID: u16 = 0x0011
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
const SINGLE_STAGE: bool = true
Whether this is a single-stage KDF (
draft-ietf-hpke-hpke-05 Section 4). Read moreSource§fn labeled_derive(
out: &mut [u8],
input_keying_material: &[&[u8]],
suite_id: &[u8],
label: &[u8],
context: &[&[u8]],
) -> Result<(), HpkeError>
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 moreSource§const OUTPUT_SIZE: usize = <Self::Hash as crypto::Hasher>::OUTPUT_SIZE
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
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 moreSource§fn labeled_expand(
out: &mut [u8],
pseudorandom_key: &[u8],
suite_id: &[u8],
label: &[u8],
info: &[u8],
) -> Result<(), HpkeError>
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 moreimpl StructuralPartialEq for Shake256
Auto Trait Implementations§
impl Freeze for Shake256
impl RefUnwindSafe for Shake256
impl Send for Shake256
impl Sync for Shake256
impl Unpin for Shake256
impl UnsafeUnpin for Shake256
impl UnwindSafe for Shake256
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more