Struct openssh_keys::PublicKey [] [src]

pub struct PublicKey { /* fields omitted */ }

PublicKey is the struct representation of an ssh public key.

Methods

impl PublicKey
[src]

[src]

parse takes a string and reads from it an ssh public key it uses the first part of the key to determine the keytype the format it expects is described here https://tools.ietf.org/html/rfc4253#section-6.6

You can parse and output ssh keys like this let rsa_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcMCOEryBa8IkxXacjIawaQPp08hR5h7+4vZePZ7DByTG3tqKgZYRJ86BaR+4fmdikFoQjvLJVUmwniq3wixhkP7VLCbqip3YHzxXrzxkbPC3w3O1Bdmifwn9cb8RcZXfXncCsSu+h5XCtQ5BOi41Iit3d13gIe/rfXVDURmRanV6R7Voljxdjmp/zyReuzc2/w5SI6Boi4tmcUlxAI7sFuP1kA3pABDhPtc3TDgAcPUIBoDCoY8q2egI197UuvbgsW2qraUcuQxbMvJOMSFg2FQrE2bpEqC4CtBn7+HiJrkVOHjV7bvSv7jd1SuX5XqkwMCRtdMuRpJr7CyZoFL5n demos@anduin"; let key = PublicKey::parse(rsa_key).unwrap(); let out = key.to_string(); assert_eq!(rsa_key, out);

parse somewhat attempts to keep track of comments, but it doesn't fully comply with the rfc in that regard.

[src]

get an ssh public key from rsa components

[src]

get an ssh public key from dsa components

[src]

keytype returns the type of key in the format described by rfc4253 The output will be ssh-{type} where type is [rsa,ed25519,ecdsa,dsa]

[src]

data returns the data section of the key in the format described by rfc4253 the contents of the data section depend on the keytype. For RSA keys it contains the keytype, exponent, and modulus in that order. Other types have other data sections. This function doesn't base64 encode the data, that task is left to the consumer of the output.

[src]

[src]

to_string returns a string representation of the ssh key this string output is appropriate to use as a public key file it adheres to the format described in https://tools.ietf.org/html/rfc4253#section-6.6 an ssh key consists of three pieces: ssh-keytype data comment each of those is encoded as big-endian bytes preceeded by four bytes representing their length.

[src]

size returns the size of the stored ssh key for rsa keys this is determined by the number of bits in the modulus for dsa keys it's the number of bits in the prime p see https://github.com/openssh/openssh-portable/blob/master/sshkey.c#L261

[src]

fingerprint returns a string representing the fingerprint of the ssh key the format of the fingerprint is described tersely in https://tools.ietf.org/html/rfc4716#page-6. This uses the ssh-keygen defaults of a base64 encoded SHA256 hash.

[src]

to_fingerprint_string prints out the fingerprint in the same format used by ssh-keygen -l -f key, specifically the implementation here - https://github.com/openssh/openssh-portable/blob/master/ssh-keygen.c#L842 right now it just sticks with the defaults of a base64 encoded SHA256 hash.

Trait Implementations

impl Clone for PublicKey
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for PublicKey
[src]

[src]

Formats the value using the given formatter.

impl Display for PublicKey
[src]

[src]

Formats the value using the given formatter. Read more