[][src]Struct parsec_interface::operations::psa_key_attributes::Attributes

pub struct Attributes {
    pub lifetime: Lifetime,
    pub key_type: Type,
    pub bits: usize,
    pub policy: Policy,
}

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]

impl Copy for Attributes[src]

impl Debug for Attributes[src]

impl<'de> Deserialize<'de> for Attributes[src]

impl PartialEq<Attributes> for Attributes[src]

impl Serialize for Attributes[src]

impl StructuralPartialEq for Attributes[src]

impl Zeroize for Attributes[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.