Enum makiko::pubkey::Pubkey

source ·
#[non_exhaustive]
pub enum Pubkey { Ed25519(Ed25519Pubkey), Rsa(RsaPubkey), EcdsaP256(EcdsaPubkey<NistP256>), EcdsaP384(EcdsaPubkey<NistP384>), }
Expand description

Public key in one of supported formats.

This enum is marked as #[non_exhaustive], so we might add new variants without breaking backwards compatibility.

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.
§

Ed25519(Ed25519Pubkey)

Ed25519 public key.

§

Rsa(RsaPubkey)

RSA public key.

§

EcdsaP256(EcdsaPubkey<NistP256>)

ECDSA public key on NIST P-256 curve.

§

EcdsaP384(EcdsaPubkey<NistP384>)

ECDSA public key on NIST P-384 curve.

Implementations§

source§

impl Pubkey

source

pub fn algos(&self) -> &'static [&'static PubkeyAlgo]

Get all public key algorithms that work with this key.

Most key types work with just a single public key algorithm, but with RSA keys (Pubkey::Rsa), there are multiple algorithms that differ in the hash function. This method returns all supported algorithms for this key.

source

pub fn algos_secure(&self) -> &'static [&'static PubkeyAlgo]

👎Deprecated since 0.2.1: Disabling public key algorithms for authentication on the client does not increase security, the older, less secure algorithms must be disabled on the server. Please use Pubkey::algos() instead.

Get best public key algorithms that work with this key.

Most key types work with just a single public key algorithm, but with RSA keys (Pubkey::Rsa), there are multiple algorithms that differ in the hash function. This method returns only highly secure algorithms, but older servers may not support them.

source

pub fn algos_compatible_less_secure(&self) -> &'static [&'static PubkeyAlgo]

👎Deprecated since 0.2.1: Please use Pubkey::algos() instead.

Get all public key algorithms that work with this key.

Most key types work with just a single public key algorithm, but with RSA keys (Pubkey::Rsa), there are multiple algorithms that differ in the hash function. This method returns all supported algorithms for maximum compatibility.

source

pub fn decode(blob: Bytes) -> Result<Self>

Decode a public key from SSH wire encoding.

This is the encoding initially defined by RFC 4253. For keys other than RSA, the encoding is defined in the RFC that introduces the key type.

source

pub fn encode(&self) -> Bytes

Encode a public key into SSH encoding.

This is the encoding initially defined by RFC 4253. For keys other than RSA, the encoding is defined in the RFC that introduces the key type.

You can use this method to calculate a digest of the public key.

source

pub fn type_str(&self) -> String

Get the type of the key as a string.

Returns a string like "ssh-rsa" or "ssh-ed25519", which is used in OpenSSH files like authorized_keys or known_hosts as a human-readable description of the key type. It corresponds to the string identifier of the key format that is present in the SSH encoding of the key.

source

pub fn fingerprint(&self) -> String

Compute a fingerprint of the public key.

The fingerprint is in the SHA-256 digest of the public key encoded with base64 (not padded with = characters) and prefixed with SHA256: (e.g. "SHA256:eaBPG/rqx+IPa0Lc9KHypkG3UxjmUwerwq9CZ/xpPWM"). If you need another format, use encode() to encode the key into bytes and apply a digest of your choice.

Trait Implementations§

source§

impl Clone for Pubkey

source§

fn clone(&self) -> Pubkey

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 Pubkey

source§

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

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

impl Display for Pubkey

source§

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

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

impl PartialEq<Pubkey> for Pubkey

source§

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

source§

impl StructuralEq for Pubkey

source§

impl StructuralPartialEq for Pubkey

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

§

type Output = T

Should always be Self
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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
§

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

§

fn vzip(self) -> V