logo
pub struct PrivateKey { /* private fields */ }
Expand description

SSH private key.

Implementations

This is supported on crate feature alloc only.

Create a new unencrypted private key with the given keypair data and comment.

On no_std platforms, use PrivateKey::from(key_data) instead.

Parse an OpenSSH-formatted PEM private key.

OpenSSH-formatted private keys begin with the following:

-----BEGIN OPENSSH PRIVATE KEY-----

Parse a raw binary SSH private key.

Encode OpenSSH-formatted (PEM) private key.

This is supported on crate feature alloc only.

Encode an OpenSSH-formatted PEM private key, allocating a self-zeroizing String for the result.

This is supported on crate feature alloc only.

Serialize SSH private key as raw bytes.

This is supported on crate feature std only.

Read private key from an OpenSSH-formatted PEM file.

This is supported on crate feature std only.

Write private key as an OpenSSH-formatted PEM file.

This is supported on crate feature encryption only.

Attempt to decrypt an encrypted private key using the provided password to derive an encryption key.

Returns Error::Decrypted if the private key is already decrypted.

This is supported on crate feature encryption only.

Encrypt an unencrypted private key using the provided password to derive an encryption key.

Uses the following algorithms:

Returns Error::Encrypted if the private key is already encrypted.

This is supported on crate feature encryption only.

Encrypt an unencrypted private key using the provided cipher and KDF configuration.

Returns Error::Encrypted if the private key is already encrypted.

Get the digital signature Algorithm used by this key.

Comment on the key (e.g. email address).

Cipher algorithm (a.k.a. ciphername).

This is supported on crate feature fingerprint only.

Compute key fingerprint.

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

Is this key encrypted?

Key Derivation Function (KDF) used to encrypt this key.

Returns Kdf::None if this key is not encrypted.

Keypair data.

Get the PublicKey which corresponds to this private key.

This is supported on crate feature rand_core only.

Generate a random key which uses the given algorithm.

Returns
  • Error::Algorithm if the algorithm is unsupported.
This is supported on crate feature alloc only.

Set the comment on the key.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Determine if two items are equal. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Expected PEM type label for a given document, e.g. "PRIVATE KEY"

Validate that a given label matches the expected label.

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more

Sign the given message and return a digital signature

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more

Sign the given message, update the state, and return a digital signature

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.