Function derive_key
Source 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.
§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.