2024-02-17 17:12:16 +01:00
|
|
|
use crate::canonicalization::canonicalize;
|
2024-02-17 16:29:54 +01:00
|
|
|
use crate::ikm::InputKeyMaterial;
|
|
|
|
|
|
|
|
pub(crate) type KdfFunction = dyn Fn(&str, &[u8]) -> Vec<u8>;
|
|
|
|
|
|
|
|
pub(crate) fn derive_key(ikm: &InputKeyMaterial, key_context: &[&str]) -> Vec<u8> {
|
|
|
|
let key_context = canonicalize(key_context);
|
|
|
|
let kdf = ikm.scheme.get_kdf();
|
|
|
|
kdf(&key_context, &ikm.content)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn blake3_derive(context: &str, ikm: &[u8]) -> Vec<u8> {
|
|
|
|
blake3::derive_key(context, ikm).to_vec()
|
|
|
|
}
|