pub fn export_public(key: Id, data: &mut [u8]) -> Result<usize>
Expand description

Export a public key or the public part of a key pair in binary format

The key is written in data. The functions returns the number of bytes written. Please check the PSA Crypto API for a more complete description on the format of data.

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 buffer_size = attributes.export_public_key_output_size().unwrap();
let mut data = vec![0; buffer_size];
let my_key = key_management::generate(attributes, None).unwrap();
let size = key_management::export_public(my_key, &mut data).unwrap();
data.resize(size, 0);