Struct ssh_key::private::PrivateKey
source · [−]pub struct PrivateKey { /* private fields */ }Expand description
SSH private key.
Implementations
sourceimpl PrivateKey
impl PrivateKey
sourcepub fn new(key_data: KeypairData, comment: impl Into<String>) -> Self
This is supported on crate feature alloc only.
pub fn new(key_data: KeypairData, comment: impl Into<String>) -> Self
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.
sourcepub fn from_openssh(input: impl AsRef<[u8]>) -> Result<Self>
pub fn from_openssh(input: impl AsRef<[u8]>) -> Result<Self>
Parse an OpenSSH-formatted PEM private key.
OpenSSH-formatted private keys begin with the following:
-----BEGIN OPENSSH PRIVATE KEY-----sourcepub fn encode_openssh<'o>(
&self,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<&'o str>
pub fn encode_openssh<'o>(
&self,
line_ending: LineEnding,
out: &'o mut [u8]
) -> Result<&'o str>
Encode OpenSSH-formatted (PEM) private key.
sourcepub fn to_openssh(&self, line_ending: LineEnding) -> Result<Zeroizing<String>>
This is supported on crate feature alloc only.
pub fn to_openssh(&self, line_ending: LineEnding) -> Result<Zeroizing<String>>
alloc only.Encode an OpenSSH-formatted PEM private key, allocating a
self-zeroizing String for the result.
sourcepub fn read_openssh_file(path: &Path) -> Result<Self>
This is supported on crate feature std only.
pub fn read_openssh_file(path: &Path) -> Result<Self>
std only.Read private key from an OpenSSH-formatted PEM file.
sourcepub fn write_openssh_file(
&self,
path: &Path,
line_ending: LineEnding
) -> Result<()>
This is supported on crate feature std only.
pub fn write_openssh_file(
&self,
path: &Path,
line_ending: LineEnding
) -> Result<()>
std only.Write private key as an OpenSSH-formatted PEM file.
sourcepub fn cipher_alg(&self) -> CipherAlg
pub fn cipher_alg(&self) -> CipherAlg
Cipher algorithm (a.k.a. ciphername).
sourcepub fn key_data(&self) -> &KeypairData
pub fn key_data(&self) -> &KeypairData
Keypair data.
sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Get the PublicKey which corresponds to this private key.
Trait Implementations
sourceimpl Clone for PrivateKey
impl Clone for PrivateKey
sourcefn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl ConstantTimeEq for PrivateKey
This is supported on crate feature subtle only.
impl ConstantTimeEq for PrivateKey
subtle only.sourceimpl Debug for PrivateKey
impl Debug for PrivateKey
sourceimpl From<&'_ PrivateKey> for PublicKey
impl From<&'_ PrivateKey> for PublicKey
sourcefn from(private_key: &PrivateKey) -> PublicKey
fn from(private_key: &PrivateKey) -> PublicKey
Performs the conversion.
sourceimpl From<KeypairData> for PrivateKey
impl From<KeypairData> for PrivateKey
sourcefn from(key_data: KeypairData) -> PrivateKey
fn from(key_data: KeypairData) -> PrivateKey
Performs the conversion.
sourceimpl From<PrivateKey> for PublicKey
impl From<PrivateKey> for PublicKey
sourcefn from(private_key: PrivateKey) -> PublicKey
fn from(private_key: PrivateKey) -> PublicKey
Performs the conversion.
sourceimpl FromStr for PrivateKey
impl FromStr for PrivateKey
sourceimpl PartialEq<PrivateKey> for PrivateKey
This is supported on crate feature subtle only.
impl PartialEq<PrivateKey> for PrivateKey
subtle only.sourceimpl PemLabel for PrivateKey
impl PemLabel for PrivateKey
sourceconst TYPE_LABEL: &'static str
const TYPE_LABEL: &'static str
Expected PEM type label for a given document, e.g. "PRIVATE KEY"
impl Eq for PrivateKey
subtle only.Auto Trait Implementations
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more