pub struct PublicKey { /* private fields */ }Expand description
SSH public key.
Implementations
sourceimpl PublicKey
impl PublicKey
sourcepub fn new(key_data: KeyData, comment: impl Into<String>) -> Self
This is supported on crate feature alloc only.
pub fn new(key_data: KeyData, comment: impl Into<String>) -> Self
alloc only.Create a new public key with the given comment.
On no_std platforms, use PublicKey::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 public key.
OpenSSH-formatted public keys look like the following:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILM+rvN+ot98qgEN796jTiQfZfG1KaT0PtFDJ/XFSqti foo@bar.comsourcepub fn encode_openssh<'o>(&self, out: &'o mut [u8]) -> Result<&'o str>
pub fn encode_openssh<'o>(&self, out: &'o mut [u8]) -> Result<&'o str>
Encode OpenSSH-formatted public key.
sourcepub fn to_openssh(&self) -> Result<String>
This is supported on crate feature alloc only.
pub fn to_openssh(&self) -> Result<String>
alloc only.Encode an OpenSSH-formatted public key, allocating a 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 public key from an OpenSSH-formatted file.
sourcepub fn write_openssh_file(&self, path: &Path) -> Result<()>
This is supported on crate feature std only.
pub fn write_openssh_file(&self, path: &Path) -> Result<()>
std only.Write public key as an OpenSSH-formatted file.
sourcepub fn fingerprint(&self, hash_alg: HashAlg) -> Fingerprint
This is supported on crate feature fingerprint only.
pub fn fingerprint(&self, hash_alg: HashAlg) -> Fingerprint
fingerprint only.Compute key fingerprint.
Use Default::default() to use the default hash function (SHA-256).
Trait Implementations
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<PrivateKey> for PublicKey
impl From<PrivateKey> for PublicKey
sourcefn from(private_key: PrivateKey) -> PublicKey
fn from(private_key: PrivateKey) -> PublicKey
Performs the conversion.
sourceimpl Ord for PublicKey
impl Ord for PublicKey
sourceimpl PartialOrd<PublicKey> for PublicKey
impl PartialOrd<PublicKey> for PublicKey
sourcefn partial_cmp(&self, other: &PublicKey) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKey) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl TryFrom<&'_ PublicKey> for Sha256Fingerprint
impl TryFrom<&'_ PublicKey> for Sha256Fingerprint
sourceimpl TryFrom<PublicKey> for Sha256Fingerprint
impl TryFrom<PublicKey> for Sha256Fingerprint
impl Eq for PublicKey
impl StructuralEq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
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