ssh_key::public

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 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 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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V