KeyData

Enum KeyData 

Source
#[non_exhaustive]
pub enum KeyData { Dsa(DsaPublicKey), Ecdsa(EcdsaPublicKey), Ed25519(Ed25519PublicKey), Rsa(RsaPublicKey), SkEcdsaSha2NistP256(SkEcdsaSha2NistP256), SkEd25519(SkEd25519), Other(OpaquePublicKey), }
Expand description

Public key data.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Dsa(DsaPublicKey)

Available on crate feature alloc only.

Digital Signature Algorithm (DSA) public key data.

§

Ecdsa(EcdsaPublicKey)

Available on crate feature ecdsa only.

Elliptic Curve Digital Signature Algorithm (ECDSA) public key data.

§

Ed25519(Ed25519PublicKey)

Ed25519 public key data.

§

Rsa(RsaPublicKey)

Available on crate feature alloc only.

RSA public key data.

§

SkEcdsaSha2NistP256(SkEcdsaSha2NistP256)

Available on crate feature ecdsa only.

Security Key (FIDO/U2F) using ECDSA/NIST P-256 as specified in PROTOCOL.u2f.

§

SkEd25519(SkEd25519)

Security Key (FIDO/U2F) using Ed25519 as specified in PROTOCOL.u2f.

§

Other(OpaquePublicKey)

Available on crate feature alloc only.

Opaque public key data.

Implementations§

Source§

impl KeyData

Source

pub fn algorithm(&self) -> Algorithm

Get the Algorithm for this public key.

Source

pub fn dsa(&self) -> Option<&DsaPublicKey>

Available on crate feature alloc only.

Get DSA public key if this key is the correct type.

Source

pub fn ecdsa(&self) -> Option<&EcdsaPublicKey>

Available on crate feature ecdsa only.

Get ECDSA public key if this key is the correct type.

Source

pub fn ed25519(&self) -> Option<&Ed25519PublicKey>

Get Ed25519 public key if this key is the correct type.

Source

pub fn fingerprint(&self, hash_alg: HashAlg) -> Fingerprint

Compute key fingerprint.

Use Default::default() to use the default hash function (SHA-256).

Source

pub fn rsa(&self) -> Option<&RsaPublicKey>

Available on crate feature alloc only.

Get RSA public key if this key is the correct type.

Source

pub fn sk_ecdsa_p256(&self) -> Option<&SkEcdsaSha2NistP256>

Available on crate feature ecdsa only.

Get FIDO/U2F ECDSA/NIST P-256 public key if this key is the correct type.

Source

pub fn sk_ed25519(&self) -> Option<&SkEd25519>

Get FIDO/U2F Ed25519 public key if this key is the correct type.

Source

pub fn other(&self) -> Option<&OpaquePublicKey>

Available on crate feature alloc only.

Get the custom, opaque public key if this key is the correct type.

Source

pub fn is_dsa(&self) -> bool

Available on crate feature alloc only.

Is this key a DSA key?

Source

pub fn is_ecdsa(&self) -> bool

Available on crate feature ecdsa only.

Is this key an ECDSA key?

Source

pub fn is_ed25519(&self) -> bool

Is this key an Ed25519 key?

Source

pub fn is_rsa(&self) -> bool

Available on crate feature alloc only.

Is this key an RSA key?

Source

pub fn is_sk_ecdsa_p256(&self) -> bool

Available on crate feature ecdsa only.

Is this key a FIDO/U2F ECDSA/NIST P-256 key?

Source

pub fn is_sk_ed25519(&self) -> bool

Is this key a FIDO/U2F Ed25519 key?

Source

pub fn is_other(&self) -> bool

Available on crate feature alloc only.

Is this a key with a custom algorithm?

Trait Implementations§

Source§

impl Clone for KeyData

Source§

fn clone(&self) -> KeyData

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 KeyData

Source§

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

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

impl Decode for KeyData

Source§

type Error = Error

Type returned in the event of a decoding error.
Source§

fn decode(reader: &mut impl Reader) -> Result<Self>

Attempt to decode a value of this type using the provided Reader.
Source§

impl Encode for KeyData

Source§

fn encoded_len(&self) -> Result<usize>

Get the length of this type encoded in bytes, prior to Base64 encoding.
Source§

fn encode(&self, writer: &mut impl Writer) -> Result<()>

Encode this value using the provided Writer.
Source§

fn encoded_len_prefixed(&self) -> Result<usize, Error>

Return the length of this type after encoding when prepended with a uint32 length prefix.
Source§

fn encode_prefixed(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode this value, first prepending a uint32 length prefix set to Encode::encoded_len.
Source§

impl From<&PrivateKey> for KeyData

Source§

fn from(private_key: &PrivateKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<&PublicKey> for KeyData

Source§

fn from(public_key: &PublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<DsaPublicKey> for KeyData

Available on crate feature alloc only.
Source§

fn from(public_key: DsaPublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<EcdsaPublicKey> for KeyData

Available on crate feature ecdsa only.
Source§

fn from(public_key: EcdsaPublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<Ed25519PublicKey> for KeyData

Source§

fn from(public_key: Ed25519PublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<KeyData> for PublicKey

Source§

fn from(key_data: KeyData) -> PublicKey

Converts to this type from the input type.
Source§

impl From<PrivateKey> for KeyData

Source§

fn from(private_key: PrivateKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<PublicKey> for KeyData

Source§

fn from(public_key: PublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<RsaPublicKey> for KeyData

Available on crate feature alloc only.
Source§

fn from(public_key: RsaPublicKey) -> KeyData

Converts to this type from the input type.
Source§

impl From<SkEcdsaSha2NistP256> for KeyData

Available on crate feature ecdsa only.
Source§

fn from(public_key: SkEcdsaSha2NistP256) -> KeyData

Converts to this type from the input type.
Source§

impl From<SkEd25519> for KeyData

Source§

fn from(public_key: SkEd25519) -> KeyData

Converts to this type from the input type.
Source§

impl Hash for KeyData

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for KeyData

Source§

fn cmp(&self, other: &KeyData) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for KeyData

Source§

fn eq(&self, other: &KeyData) -> 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 PartialOrd for KeyData

Source§

fn partial_cmp(&self, other: &KeyData) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<&KeypairData> for KeyData

Source§

type Error = Error

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

fn try_from(keypair_data: &KeypairData) -> Result<KeyData>

Performs the conversion.
Source§

impl Verifier<Signature> for KeyData

Available on crate feature alloc only.
Source§

fn verify(&self, message: &[u8], signature: &Signature) -> Result<()>

Use Self to verify that the provided signature for a given message bytestring is authentic. Read more
Source§

impl Eq for KeyData

Source§

impl StructuralPartialEq for KeyData

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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, 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 136 bytes

Size for each variant:

  • Dsa: 71 bytes
  • Ecdsa: 134 bytes
  • Ed25519: 32 bytes
  • Rsa: 39 bytes
  • SkEcdsaSha2NistP256: 103 bytes
  • SkEd25519: 63 bytes
  • Other: 55 bytes