sshkey

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 9 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

The sshkey package provides simple ways to generate and parse SSH private keys. ECDSA, Ed25519 and RSA keys are supported.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncryptedKey       = errors.New("private key is passphrase protected")
	ErrRSAKeyTooSmall     = fmt.Errorf("RSA key is smaller than the minimum of %d bits", minRSAKeyBits)
	ErrUnsupportedKeyType = errors.New("unsupported private key type")
)

Functions

func GeneratePrivateKey added in v0.21.0

func GeneratePrivateKey(keyType KeyType, curve elliptic.Curve) (crypto.Signer, error)

GeneratePrivateKey generates a new private key of the given type. The curve is used for ECDSA keys and ignored otherwise. RSA keys are 3072 bits.

func ParsePrivateKey added in v0.21.0

func ParsePrivateKey(pemBytes []byte) (crypto.Signer, error)

ParsePrivateKey parses an unencrypted PEM encoded private key in OpenSSH, PKCS#1, SEC1 or PKCS#8 format and returns it as a crypto.Signer.

The returned key is an *ecdsa.PrivateKey, an ed25519.PrivateKey or an *rsa.PrivateKey. Other key types, passphrase protected keys and RSA keys smaller than 2048 bits are rejected.

Types

type KeyType added in v0.21.0

type KeyType string

KeyType is a supported type of SSH private key

const (
	KeyTypeECDSA   KeyType = "ecdsa"
	KeyTypeEd25519 KeyType = "ed25519"
	KeyTypeRSA     KeyType = "rsa"
)

Jump to

Keyboard shortcuts

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