[−][src]Struct psa_crypto::types::key::Attributes
Native definition of the attributes needed to fully describe a cryptographic key.
Fields
lifetime: LifetimeLifetime of the key
key_type: TypeIntrinsic category and type of the key
bits: usizeSize of the key in bits
policy: PolicyPolicy restricting the permitted usage of the key
Implementations
impl Attributes[src]
pub fn is_exportable(self) -> bool[src]
Check if a key has permission to be exported
pub fn can_export(self) -> Result<()>[src]
Check export in a fallible way
Example
use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags}; use psa_crypto::types::algorithm::{Algorithm, AsymmetricSignature, Hash}; let mut attributes = Attributes { key_type: Type::RsaKeyPair, bits: 1024, lifetime: Lifetime::Volatile, policy: Policy { usage_flags: UsageFlags { export: false, copy: false, cache: false, encrypt: false, decrypt: false, sign_message: false, verify_message: false, sign_hash: false, verify_hash: false, derive: false, }, permitted_algorithms: Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign { hash_alg: Hash::Sha256.into(), }), }, }; // Can not export because the export flag is set to false. attributes.can_export().unwrap_err();
pub fn is_hash_signable(self) -> bool[src]
Check if a key has permission to sign a message hash
pub fn can_sign_hash(self) -> Result<()>[src]
Check hash signing permission in a fallible way
pub fn is_hash_verifiable(self) -> bool[src]
Check if a key has permission to verify a message hash
pub fn can_verify_hash(self) -> Result<()>[src]
Check hash signing permission in a fallible way
pub fn is_encrypt_permitted(self) -> bool[src]
Check if a key has permissions to encrypt a message
pub fn can_encrypt_message(self) -> Result<()>[src]
Check encrypt permission in a fallible way
pub fn is_decrypt_permitted(self) -> bool[src]
Check if a key has permissions to decrypt a message
pub fn can_decrypt_message(self) -> Result<()>[src]
Check decrypt permission in a fallible way
pub fn is_derivable(self) -> bool[src]
Check if a key has permissions to be derived from
pub fn can_derive_from(self) -> Result<()>[src]
Check derive permission of a fallible way
pub fn is_alg_permitted(self, alg: Algorithm) -> bool[src]
Check if the alg given for a cryptographic operation is permitted to be used with the key
pub fn permits_alg(self, alg: Algorithm) -> Result<()>[src]
Check if alg is permitted in a fallible way
pub fn is_compatible_with_alg(self, alg: Algorithm) -> bool[src]
Check if the alg given for a cryptographic operation is compatible with the type of the key
Example
use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags}; use psa_crypto::types::algorithm::{Algorithm, AsymmetricSignature, Hash}; let permitted_alg = Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign { hash_alg: Hash::Sha256.into(), }); let alg = Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign { hash_alg: Hash::Sha256.into(), }); let mut attributes = Attributes { key_type: Type::RsaKeyPair, bits: 1024, lifetime: Lifetime::Volatile, policy: Policy { usage_flags: UsageFlags { export: false, copy: false, cache: false, encrypt: false, decrypt: false, sign_message: false, verify_message: false, sign_hash: false, verify_hash: false, derive: false, }, permitted_algorithms: permitted_alg, }, }; assert!(attributes.is_compatible_with_alg(alg)); attributes.key_type = Type::RsaPublicKey; assert!(attributes.is_compatible_with_alg(alg));
pub fn compatible_with_alg(self, alg: Algorithm) -> Result<()>[src]
Check if alg is compatible in a fallible way
pub fn from_key_id(key_id: Id) -> Result<Self>[src]
Gets the attributes for a given key ID
The Id structure can be created with the from_persistent_key_id constructor on Id.
Example
psa_crypto::init().unwrap(); let my_key_id = key_management::generate(attributes, None).unwrap(); //... let key_attributes = Attributes::from_key_id(my_key_id);
pub fn export_key_output_size(self) -> Result<usize>[src]
Sufficient size for a buffer to export the key, if supported
pub fn export_public_key_output_size(self) -> Result<usize>[src]
Sufficient size for a buffer to export the public key, if supported
pub fn sign_output_size(self, alg: AsymmetricSignature) -> Result<usize>[src]
Sufficient buffer size for a signature using the given key, if the key is supported
pub fn asymmetric_encrypt_output_size(
self,
alg: AsymmetricEncryption
) -> Result<usize>[src]
self,
alg: AsymmetricEncryption
) -> Result<usize>
Sufficient buffer size for an encrypted message using the given asymmetric encryption algorithm
pub fn asymmetric_decrypt_output_size(
self,
alg: AsymmetricEncryption
) -> Result<usize>[src]
self,
alg: AsymmetricEncryption
) -> Result<usize>
Sufficient buffer size for a decrypted message using the given asymmetric encryption algorithm
pub fn mac_length(self, mac_alg: Mac) -> Result<usize>[src]
Sufficient buffer size for the MAC of the specified algorithm, if compatible
pub fn aead_encrypt_output_size(
self,
alg: Aead,
plaintext_len: usize
) -> Result<usize>[src]
self,
alg: Aead,
plaintext_len: usize
) -> Result<usize>
Sufficient buffer size for an encrypted message using the given aead algorithm
pub fn aead_decrypt_output_size(
self,
alg: Aead,
ciphertext_len: usize
) -> Result<usize>[src]
self,
alg: Aead,
ciphertext_len: usize
) -> Result<usize>
Sufficient buffer size for an encrypted message using the given aead algorithm
pub fn aead_tag_length(self, alg: Aead) -> Result<usize>[src]
The length of a tag for an AEAD algorithm
pub fn raw_key_agreement_output_size(
self,
alg: RawKeyAgreement
) -> Result<usize>[src]
self,
alg: RawKeyAgreement
) -> Result<usize>
Sufficient buffer size for the resulting shared secret from a raw key agreement
Trait Implementations
impl Clone for Attributes[src]
pub fn clone(&self) -> Attributes[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for Attributes[src]
impl Debug for Attributes[src]
impl<'de> Deserialize<'de> for Attributes[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<Attributes> for Attributes[src]
pub fn eq(&self, other: &Attributes) -> bool[src]
pub fn ne(&self, other: &Attributes) -> bool[src]
impl Serialize for Attributes[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for Attributes[src]
impl TryFrom<psa_key_attributes_s> for Attributes[src]
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(attributes: psa_key_attributes_t) -> Result<Self>[src]
impl Zeroize for Attributes[src]
Auto Trait Implementations
impl RefUnwindSafe for Attributes[src]
impl Send for Attributes[src]
impl Sync for Attributes[src]
impl Unpin for Attributes[src]
impl UnwindSafe for Attributes[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,