pub fn export(key: Id, data: &mut [u8]) -> Result<usize> {
    initialized()?;
    let mut data_length = 0;

    Status::from(unsafe {
        psa_crypto_sys::psa_export_key(key.0, data.as_mut_ptr(), data.len(), &mut data_length)
    })
    .to_result()?;
    Ok(data_length)
}
/// Export a key pair in binary format
///
/// The key is written in `data`. The function 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};
/// # let mut usage_flags: UsageFlags = Default::default();
/// # usage_flags.set_sign_hash().set_verify_hash().set_export();
/// # let mut attributes = Attributes {
/// #     key_type: Type::RsaKeyPair,
/// #     bits: 1024,
/// #     lifetime: Lifetime::Volatile,
/// #     policy: Policy {
/// #         usage_flags,
/// #         permitted_algorithms: AsymmetricSignature::RsaPkcs1v15Sign {
/// #             hash_alg: Hash::Sha256.into(),
/// #         }.into(),
/// #     },
/// # };
/// psa_crypto::init().unwrap();
/// let buffer_size = attributes.export_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(my_key, &mut data).unwrap();
/// data.resize(size, 0);
/// ```
Export a key pair in binary format
The key is written in `data`. The function returns the number of bytes written.
Please check the PSA Crypto API for a more complete description on the format of `data`.
Export a key pair in binary format The key is written in ` data ` . The function returns the number of bytes written . Please check the PSA Crypto API for a more complete description on the format of ` data ` .
pub fn export(key: Id, data: &mut [u8]) -> Result<usize> {
    initialized()?;
    let mut data_length = 0;
    Status::from(unsafe {
        psa_crypto_sys::psa_export_key(key.0, data.as_mut_ptr(), data.len(), &mut data_length)
    })
    .to_result()?;
    Ok(data_length)
}
pub fn export ( key : Id , data : & mut [ u8 ] ) -> Result < usize > { initialized ( ) ? ; let mut data_length = 0 ; Status :: from ( unsafe { psa_crypto_sys :: psa_export_key ( key . 0 , data . as_mut_ptr ( ) , data . len ( ) , & mut data_length ) } ) . to_result ( ) ? ; Ok ( data_length ) }
Export a key pair in binary format
The key is written in `data`.
Export a key pair in binary format The key is written in ` data ` .
key
Id
data
&mut [u8]
key
Id
data
&mut [u8]
example
```
use psa_crypto::operations::key_management;
use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags};
use psa_crypto::types::algorithm::{AsymmetricSignature, Hash}.
` ` ` use psa_crypto :: operations :: key_management ; use psa_crypto :: types :: key :: { Attributes Type Lifetime Policy UsageFlags } ; use psa_crypto :: types :: algorithm :: { AsymmetricSignature Hash } .
let mut usage_flags: usageflags = default::default();
None
usage_flags.set_sign_hash().set_verify_hash().set_export();
None
let mut attributes = attributes {
None
key_type: type::rsakeypair,
None
bits: 1024,
None
lifetime: lifetime::volatile,
None
policy: policy {
None
usage_flags,
None
permitted_algorithms: asymmetricsignature::rsapkcs1v15sign {
None
hash_alg: hash::sha256.into(),
None
}.into(),
None
},
None
};
:init().unwrap();
let buffer_size = attributes.export_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(my_key, &mut data).unwrap();
data.resize(size, 0);
```
: init () . unwrap () ; let buffer_size = attributes . export_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 ( my_key &mut data ) . unwrap () ; data . resize ( size 0 ) ; ` ` `