#crypto #certificate #key #openssh #ssh

no-std ssh-key

Pure Rust implementation of SSH key file format decoders/encoders as described in RFC4251 and RFC4253 as well as the OpenSSH key formats, certificates (including certificate validation and certificate authority support), and the authorized_keys and known_hosts file formats. Supports a no_std profile for embedded targets.

8 releases (4 breaking)

Uses new Rust 2021

0.5.0-pre.0 Sep 26, 2022
0.4.3 Sep 25, 2022
0.4.2 May 2, 2022
0.4.1 Apr 26, 2022
0.0.0 Nov 18, 2021

#124 in Cryptography

Download history 5769/week @ 2022-06-16 5025/week @ 2022-06-23 5227/week @ 2022-06-30 5289/week @ 2022-07-07 4963/week @ 2022-07-14 5019/week @ 2022-07-21 7111/week @ 2022-07-28 6629/week @ 2022-08-04 8270/week @ 2022-08-11 8054/week @ 2022-08-18 6271/week @ 2022-08-25 4290/week @ 2022-09-01 4588/week @ 2022-09-08 5373/week @ 2022-09-15 5000/week @ 2022-09-22 4923/week @ 2022-09-29

20,042 downloads per month
Used in 6 crates (5 directly)

Apache-2.0 OR MIT

275KB
6K SLoC

RustCrypto: SSH Key and Certificate 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 RFC4251 and RFC4253 as well as OpenSSH's PROTOCOL.key format specification.

Additionally provides support for OpenSSH certificates as specified in PROTOCOL.certkeys including certificate validation and certificate authority (CA) support, as well as FIDO/U2F keys as specified in PROTOCOL.u2f (and certificates thereof), and also the authorized_keys and known_hosts file formats.

Supports a minimal profile which works on heapless no_std targets. See "Supported algorithms" table below for which key formats work on heapless targets and which algorithms require alloc.

When the ed25519, p256, and/or rsa features of this crate are enabled, provides key generation and certificate signing/verification support for that respective SSH key algorithm.

Features

  • Constant-time Base64 decoder/encoder using base64ct/pem-rfc7468 crates
  • OpenSSH-compatible decoder/encoders for the following formats:
    • OpenSSH public keys
    • OpenSSH private keys (i.e. BEGIN OPENSSH PRIVATE KEY)
    • OpenSSH certificates
  • OpenSSH certificates
    • Certificate validation
    • Certificate authority (CA) support i.e. cert builder/signer
  • Private key encryption/decryption (bcrypt-pbkdf + aes256-ctr only)
  • Private key generation support: Ed25519, ECDSA/P-256, and RSA
  • FIDO/U2F key support (sk-*) as specified in PROTOCOL.u2f
  • Fingerprint support
  • no_std support including support for "heapless" (no-alloc) targets
  • Parsing authorized_keys files
  • Parsing known_hosts files
  • serde support
  • zeroize support for private keys

TODO

  • ECDSA/P-384 support
  • ECDSA/P-512 support
  • FIDO/U2F signature support
  • Legacy (pre-OpenSSH) SSH key format support
    • PKCS#1
    • PKCS#8
    • RFC4716 public keys
    • SEC1

Supported algorithms

Name Decode Encode Cert Keygen Sign Verify Feature no_std
ecdsa‑sha2‑nistp256 ✅️ ✅️ ✅️ p256 heapless
ecdsa‑sha2‑nistp384 ⛔️ ⛔️ ⛔️ heapless
ecdsa‑sha2‑nistp521 ⛔️ ⛔ ️ ⛔️ heapless
ssh‑dsa ⛔️ ⛔️ alloc
ssh‑ed25519 ✅️ ✅️ ed25519 heapless
ssh‑rsa ✅️ ✅️ rsa alloc
sk‑ecdsa‑sha2‑nistp256@openssh.com ⛔️ ⛔️ alloc
sk‑ssh‑ed25519@openssh.com ⛔️ ⛔️ alloc

Note: the "Feature" section lists the name of ssh-key crate features which can be enabled to provide full support for the "Keygen", "Sign", and "Verify" functionality for a particular SSH key algorithm.

Minimum Supported Rust Version

This crate requires Rust 1.57 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.

Dependencies

~0.2–1.2MB
~25K SLoC