Documentation
¶
Overview ¶
Package sshkey parses SSH private keys, checks their strength and derives their public metadata. It depends on nothing else in OpenWatch, so both the dial layer (internal/ssh) and the credential store (internal/credential) can use the one parser: a key accepted by the store is the key the dial layer loads, and the metadata the store records is computed from that same key (bugs/OW-123).
Spec system-credential-store C-08; system-ssh-connectivity C-02.
Index ¶
Constants ¶
const ECDSAMinBits = 256
ECDSAMinBits is the lower bound for ECDSA curves. P-256 = 256 bits.
const RSAMinBits = 2048
RSAMinBits is the lower bound for RSA keys per NIST SP 800-57 (good through 2030). Keys below this size are rejected.
Variables ¶
var ( ErrWeakKey = errors.New("ssh: key below NIST SP 800-57 minimum strength") ErrInvalidKey = errors.New("ssh: private key is unparseable or malformed") )
Key errors.
Functions ¶
func CheckStrength ¶
CheckStrength applies the NIST SP 800-57 minimums to pub: RSA at least RSAMinBits, ECDSA at least ECDSAMinBits, Ed25519 always, DSA never, any other type refused.
Types ¶
type Metadata ¶
type Metadata struct {
// Fingerprint is ssh.FingerprintSHA256 of the public key, as
// "SHA256:<base64>".
Fingerprint string
// Type is the public key's SSH algorithm name, e.g. "ssh-ed25519".
Type string
// Bits is the key size: the RSA modulus length, the ECDSA curve size,
// or 256 for Ed25519.
Bits int
// Comment is always empty: golang.org/x/crypto/ssh does not expose the
// comment an OpenSSH private key carries, and inventing one would be
// worse than saying nothing.
Comment string
}
Metadata is the public description of a private key, derived from the key itself.