pub fn derive_key<H: Hasher, const N: usize>(
ikm: &[u8],
info: &[u8],
salt: Option<&[u8]>,
) -> Result<[u8; N], HkdfError>Expand description
One-shot HKDF: extract-then-expand in a single call.
H::OUTPUT_SIZE must be smaller than or equal to
MAX_HASH_OUTPUT_SIZE; this bound is checked
at compile time.
§Example
ⓘ
use crypto::hkdf;
use crypto::sha2::Sha256;
let okm: [u8; 32] = hkdf::derive_key::<Sha256, 32>(
b"input key material",
b"context info",
Some(b"salt"),
).unwrap();§Error
Returns an error if N > 255 * H::OUTPUT_SIZE.