Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ssh-key/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::{
base64::{self, Decode},
public, Algorithm, CipherAlg, Error, KdfAlg, KdfOptions, Result,
};
use core::str::FromStr;

#[cfg(feature = "alloc")]
use alloc::string::String;
Expand Down Expand Up @@ -126,6 +127,14 @@ impl PrivateKey {
}
}

impl FromStr for PrivateKey {
type Err = Error;

fn from_str(s: &str) -> Result<Self> {
Self::from_openssh(s)
}
}

/// Private key data.
#[derive(Clone, Debug)]
#[non_exhaustive]
Expand Down
9 changes: 9 additions & 0 deletions ssh-key/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
base64::{self, Decode},
Algorithm, Error, Result,
};
use core::str::FromStr;

#[cfg(feature = "alloc")]
use alloc::{borrow::ToOwned, string::String};
Expand Down Expand Up @@ -72,6 +73,14 @@ impl PublicKey {
}
}

impl FromStr for PublicKey {
type Err = Error;

fn from_str(s: &str) -> Result<Self> {
Self::from_openssh(s)
}
}

/// Public key data.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
Expand Down