[−][src]Struct parsec_interface::operations::psa_key_attributes::Attributes
Native definition of the attributes needed to fully describe a cryptographic key.
Fields
lifetime: Lifetime
Lifetime of the key
key_type: Type
Intrinsic category and type of the key
bits: usize
Size of the key in bits
policy: Policy
Policy 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<(), Error>
[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<(), Error>
[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<(), Error>
[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<(), Error>
[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<(), Error>
[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<(), Error>
[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<(), Error>
[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<(), Error>
[src]
Check if alg is compatible in a fallible way
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<Attributes, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<Attributes, <__D as Deserializer<'de>>::Error> where
__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 as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl StructuralPartialEq for Attributes
[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>,