Function psa_crypto::operations::key_derivation::output_key [−][src]
Expand description
This function calculates output bytes from a key derivation algorithm and uses those bytes to generate a key deterministically. The key’s location, usage policy, type and size are taken from attributes.
Example
use psa_crypto::operations::{key_derivation, key_management};
use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags};
use psa_crypto::types::algorithm::{Hash, KeyDerivation};
use psa_crypto::types::key_derivation::{Operation, Inputs, Input, InputSecret};
psa_crypto::init().unwrap();
let my_key = key_management::import(attributes, None, &KEY_DATA).unwrap();
let info = vec![20; 0x3f];
let mut operation = Operation {
inputs: Inputs::Hkdf {
hash_alg: Hash::Sha256,
salt: None,
secret: InputSecret::Input(Input::Key(my_key)),
info: Input::Bytes(&info),
},
capacity: None,
};
let _new_key = key_derivation::output_key(operation, derived_key_attributes, None).unwrap();