Function psa_crypto::operations::key_management::import
source · pub fn import(
attributes: Attributes,
id: Option<u32>,
data: &[u8]
) -> Result<Id>
Expand description
Import a key in binary format
id
can be set to None
when creating a volatile key. Setting the id
to something will
override the lifetime
field of the attributes to Lifetime::Persistent
.
When generating a persistent key with a specific ID, the Id
structure can be created after
reset with the from_persistent_key_id
constructor on Id
. Please check the PSA Crypto API
for a more complete description on the format expected in data
. The Id
structure returned
can be used for cryptographic operations using that key.
Example
use psa_crypto::operations::key_management;
use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags};
use psa_crypto::types::algorithm::{AsymmetricSignature, Hash};
psa_crypto::init().unwrap();
let _my_key = key_management::import(attributes, None, &KEY_DATA).unwrap();