sshkey

package
v0.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const ECDSAMinBits = 256

ECDSAMinBits is the lower bound for ECDSA curves. P-256 = 256 bits.

View Source
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

View Source
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

func CheckStrength(pub ssh.PublicKey) error

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.

func ParseSigner

func ParseSigner(pem []byte, passphrase string) (ssh.Signer, error)

ParseSigner returns an ssh.Signer for the PEM-encoded private key, decrypting it with passphrase when one is given.

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.

func Inspect

func Inspect(pem []byte, passphrase string) (Metadata, error)

Inspect parses the private key with passphrase, applies CheckStrength, and returns the metadata of the key it actually parsed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL