Crate ssh_key[][src]

Expand description

RustCrypto: SSH Key Formats

crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat

Documentation

About

Pure Rust implementation of SSH key file format decoders/encoders as described in RFC4253 and RFC4716 as well as OpenSSH’s PROTOCOL.key format specification.

Supports “heapless” no_std embedded targets with an optional alloc feature (Ed25519 and ECDSA only).

Minimum Supported Rust Version

This crate requires Rust 1.56 at a minimum.

We may change the MSRV in the future, but it will be accompanied by a minor version bump.

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Usage

OpenSSH Public Keys

use ssh_key::PublicKey;

let encoded_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILM+rvN+ot98qgEN796jTiQfZfG1KaT0PtFDJ/XFSqti foo@bar.com";
let key = PublicKey::from_openssh(encoded_key)?;

// Key attributes
assert_eq!(key.algorithm(), ssh_key::Algorithm::Ed25519);
assert_eq!(key.comment, "foo@bar.com");

// Key data
if let Some(ed25519_key) = key.data.ed25519() {
    assert_eq!(
        ed25519_key.as_ref(),
        [
            0xb3, 0x3e, 0xae, 0xf3, 0x7e, 0xa2, 0xdf, 0x7c, 0xaa, 0x1, 0xd, 0xef, 0xde, 0xa3,
            0x4e, 0x24, 0x1f, 0x65, 0xf1, 0xb5, 0x29, 0xa4, 0xf4, 0x3e, 0xd1, 0x43, 0x27, 0xf5,
            0xc5, 0x4a, 0xab, 0x62
        ].as_ref()
    );
}

Re-exports

pub use crate::public::PublicKey;
pub use sec1;

Modules

SSH public key support.

Structs

MPIntalloc

Multiple precision integer, a.k.a. “mpint”.

Enums

SSH key algorithms.

Elliptic curves supported for use with ECDSA.

Error type.

Type Definitions

Result type with ssh-key’s Error as the error type.