Function psa_crypto::operations::key_management::generate[][src]

pub fn generate(attributes: Attributes, id: Option<u32>) -> Result<Id>
Expand description

Generate a key or a key pair

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. 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::generate(attributes, None).unwrap();