pub enum Algorithm {
    None,
    Hash(Hash),
    Mac(Mac),
    Cipher(Cipher),
    Aead(Aead),
    AsymmetricSignature(AsymmetricSignature),
    AsymmetricEncryption(AsymmetricEncryption),
    KeyAgreement(KeyAgreement),
    KeyDerivation(KeyDerivation),
}
Expand description

Enumeration of possible algorithm definitions. Each variant of the enum contains a main algorithm type (which is required for that variant).

Variants§

§

None

An invalid algorithm identifier value. None does not allow any cryptographic operation with the key. The key can still be used for non-cryptographic actions such as exporting, if permitted by the usage flags.

§

Hash(Hash)

Hash algorithm.

§

Mac(Mac)

MAC algorithm.

§

Cipher(Cipher)

Symmetric Cipher algorithm.

§

Aead(Aead)

Authenticated Encryption with Associated Data (AEAD) algorithm.

§

AsymmetricSignature(AsymmetricSignature)

Public-key signature algorithm.

§

AsymmetricEncryption(AsymmetricEncryption)

Public-key encryption algorithm.

§

KeyAgreement(KeyAgreement)

Key agreement algorithm.

§

KeyDerivation(KeyDerivation)

Key derivation algorithm.

Implementations§

source§

impl Algorithm

source

pub fn is_hmac(self) -> bool

Check if the algorithm is a HMAC algorithm, truncated or not

Example
use psa_crypto::types::algorithm::{Algorithm, Mac, FullLengthMac, Hash};
let hmac = Algorithm::Mac(Mac::Truncated {
    mac_alg: FullLengthMac::Hmac { hash_alg: Hash::Sha256 },
    mac_length: 30,
});
assert!(hmac.is_hmac());

Trait Implementations§

source§

impl Clone for Algorithm

source§

fn clone(&self) -> Algorithm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Algorithm

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Algorithm

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<Algorithm, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Aead> for Algorithm

source§

fn from(alg: Aead) -> Algorithm

Converts to this type from the input type.
source§

impl From<AsymmetricEncryption> for Algorithm

source§

fn from(alg: AsymmetricEncryption) -> Algorithm

Converts to this type from the input type.
source§

impl From<AsymmetricSignature> for Algorithm

source§

fn from(alg: AsymmetricSignature) -> Algorithm

Converts to this type from the input type.
source§

impl From<Cipher> for Algorithm

source§

fn from(alg: Cipher) -> Algorithm

Converts to this type from the input type.
source§

impl From<Hash> for Algorithm

source§

fn from(alg: Hash) -> Algorithm

Converts to this type from the input type.
source§

impl From<KeyAgreement> for Algorithm

source§

fn from(alg: KeyAgreement) -> Algorithm

Converts to this type from the input type.
source§

impl From<KeyDerivation> for Algorithm

source§

fn from(alg: KeyDerivation) -> Algorithm

Converts to this type from the input type.
source§

impl From<Mac> for Algorithm

source§

fn from(alg: Mac) -> Algorithm

Converts to this type from the input type.
source§

impl PartialEq for Algorithm

source§

fn eq(&self, other: &Algorithm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Algorithm

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Zeroize for Algorithm

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
source§

impl Copy for Algorithm

source§

impl Eq for Algorithm

source§

impl StructuralEq for Algorithm

source§

impl StructuralPartialEq for Algorithm

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,