Crate hkdf[][src]

An implementation of HKDF, the HMAC-based Extract-and-Expand Key Derivation Function.

Usage


let ikm = hex::decode("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap();
let salt = hex::decode("000102030405060708090a0b0c").unwrap();
let info = hex::decode("f0f1f2f3f4f5f6f7f8f9").unwrap();

let hk = Hkdf::<Sha256>::extract(Some(&salt[..]), &ikm);
let mut okm = [0u8; 42];
hk.expand(&info, &mut okm).unwrap();
println!("PRK is {}", hex::encode(hk.prk));
println!("OKM is {}", hex::encode(&okm[..]));

Structs

Hkdf

Structure representing the HKDF, capable of HKDF-Expand and HKDF-extract operations.

InvalidLength

Structure for InvalidLength, used for output error handling.