Struct optee_utee::crypto_op::DeriveKey [−][src]
pub struct DeriveKey(_);
Expand description
An operation for derive a shared key object.
Implementations
Take one of the Asymmetric Derivation Operation Algorithm that supports this operation as defined in AlgorithmId, and output a key object.
Parameters
params
: For algorithm DhDeriveSharedSecret, DhPublicValue is required as the passed in attribute.object
: An uninitialized transient object to be filled with the derived key.
Example
let attr_prime = AttributeMemref::from_ref(AttributeId::DhPrime, &[23u8]);
let attr_base = AttributeMemref::from_ref(AttributeId::DhBase, &[5u8]);
let mut public_1 = [0u8; 32];
match TransientObject::allocate(TransientObjectType::DhKeypair, 256) {
Ok(key_pair_1) => {
key_pair_1.generate_key(256, &[attr_prime.into(), attr_base.into()])?;
key_pair_1.ref_attribute(aTTRIBUTEiD::DhPublicValue, &mut public_1)?;
}
Err(e) => Err(e),
}
let attr_prime = AttributeMemref::from_ref(AttributeId::DhPrime, &[23u8]);
let attr_base = AttributeMemref::from_ref(AttributeId::DhBase, &[5u8]);
match TransientObject::allocate(TransientObjectType::DhKeypair, 256) {
Ok(key_pair_2) => {
key_pair_2.generate_key(256, &[attr_prime.into(), attr_base.into()])?;
match DeriveKey::allocate(AlgorithmId::DhDeriveSharedSecret, 256) {
Ok(operation) => {
operation.set_key(&key_pair_2)?;
match TransientObject::allocate(TransientObjectType::GenericSecret,
256) {
// Derived key is saved as an transient object
Ok(derived_key) => {
let attr_public = AttributeMemref::from_ref(AttributeId::DhPublicValue, &public_1);
operation.derive(&[attr_public.into()], &mut derived_key);
// ...
Ok(())
}
Err(e) => Err(e),
}
}
Err(e) => Err(e),
}
}
Err(e) => Err(e),
}
Panics
- If the algorithm is not a valid algorithm for
DeriveKey
. - If the
object
is too small for generated value. - If no key is programmed in the operation.
- Hardware or cryptographic algorithm failure.
- If the Implementation detects any other error.
Create a DeriveKey operation without any specific algorithm or other data.
Function usage is similar to Digest::allocate.
Currently only supports DhDeriveSharedSecret as
algo
.
Function usage is similar to Digest::info.
Function usage is similar to Digest::info_multiple.
Function usage is similar to Cipher::set_key.
Function usage is similar to Digest::copy.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DeriveKey
impl !Send for DeriveKey
impl !Sync for DeriveKey
impl Unpin for DeriveKey
impl UnwindSafe for DeriveKey
Blanket Implementations
pub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
pub fn from(t: T) -> T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
pub fn into(self) -> U
Performs the conversion.