Skip to main content

Type

Enum Type 

Source
pub enum Type {
Show 14 variants RawData, Hmac, Derive, Aes, Des, Camellia, Arc4, Chacha20, RsaPublicKey, RsaKeyPair, EccKeyPair { curve_family: EccFamily, }, EccPublicKey { curve_family: EccFamily, }, DhKeyPair { group_family: DhFamily, }, DhPublicKey { group_family: DhFamily, },
}
Expand description

Enumeration of key types supported.

Variants§

§

RawData

Not a valid key type for any cryptographic operation but can be used to store arbitrary data in the key store.

§

Hmac

HMAC key.

§

Derive

A secret key for derivation.

§

Aes

Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.

§

Des

Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).

§

Camellia

Key for a cipher, AEAD or MAC algorithm based on the Camellia block cipher.

§

Arc4

Key for the RC4 stream cipher.

§

Chacha20

Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.

§

RsaPublicKey

RSA public key.

§

RsaKeyPair

RSA key pair: both the private and public key.

§

EccKeyPair

Elliptic curve key pair: both the private and public key.

Fields

§curve_family: EccFamily

ECC curve family to use.

§

EccPublicKey

Elliptic curve public key.

Fields

§curve_family: EccFamily

ECC curve family to use.

§

DhKeyPair

Diffie-Hellman key pair: both the private key and public key.

Fields

§group_family: DhFamily

Diffie-Hellman group family to use.

§

DhPublicKey

Diffie-Hellman public key.

Fields

§group_family: DhFamily

Diffie-Hellman group family to use.

Implementations§

Source§

impl Type

Source

pub fn is_ecc_key_pair(self) -> bool

Checks if a key type is ECC key pair with any curve family inside.

Source

pub fn is_ecc_public_key(self) -> bool

Checks if a key type is ECC public key with any curve family inside.

§Example
use psa_crypto::types::key::{Type, EccFamily};

assert!(Type::EccPublicKey { curve_family: EccFamily::SecpK1}.is_ecc_public_key());
Source

pub fn is_rsa_public_key(self) -> bool

Checks if a key type is RSA public key.

Source

pub fn is_dh_public_key(self) -> bool

Checks if a key type is DH public key with any group family inside.

Source

pub fn is_dh_key_pair(self) -> bool

Checks if a key type is DH key pair with any group family inside.

Source

pub fn is_public_key(self) -> bool

Checks if a key type is an asymmetric public key type.

Source

pub fn key_type_public_key_of_key_pair(self) -> Result<Type>

If key is public or key pair, returns the corresponding public key type.

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate 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 Type

Source§

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

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

impl<'de> Deserialize<'de> for Type

Source§

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

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

impl Display for Type

Source§

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

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

impl PartialEq for Type

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Type

Source§

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

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

impl TryFrom<Type> for psa_key_type_t

Available on crate feature interface only.
Source§

type Error = Error

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

fn try_from(key_type: Type) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<u16> for Type

Available on crate feature interface only.
Source§

type Error = Error

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

fn try_from(key_type: psa_key_type_t) -> Result<Self>

Performs the conversion.
Source§

impl Zeroize for Type

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 Type

Source§

impl Eq for Type

Source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnsafeUnpin for Type

§

impl UnwindSafe for Type

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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 T
where T: for<'de> Deserialize<'de>,