Documentation
¶
Overview ¶
Package keymaterial checks the key material the security API stores: that the private and public halves of an RSA or GPG key pair belong together, and that a client certificate bundle carries its own private key.
Index ¶
- Constants
- Variables
- func CheckPair(pairType, privateKey, publicKey, passphrase string) error
- func Ed25519PrivateKey(privateKey, passphrase string) (ed25519.PrivateKey, error)
- func Ed25519PublicKey(publicKey string) (ed25519.PublicKey, error)
- func RSAPrivateKey(privateKey, passphrase string) (*rsa.PrivateKey, error)
- type Bundle
Constants ¶
const ( RSA = "RSA" GPG = "GPG" )
Key pair types the security API accepts.
const Ed25519 = "Ed25519"
Ed25519 is the signing key type used by Nix binary caches.
Variables ¶
var ErrInvalid = errors.New("keymaterial: invalid key material")
ErrInvalid reports key material that does not parse, does not match, or cannot be unlocked. Its message is safe to show the caller.
Functions ¶
func CheckPair ¶
CheckPair verifies that privateKey and publicKey are the two halves of one key of pairType, unlocking privateKey with passphrase when it is encrypted.
func Ed25519PrivateKey ¶
func Ed25519PrivateKey(privateKey, passphrase string) (ed25519.PrivateKey, error)
func RSAPrivateKey ¶
func RSAPrivateKey(privateKey, passphrase string) (*rsa.PrivateKey, error)
RSAPrivateKey opens a validated RSA key pair for format metadata signing. It accepts the same PEM and legacy PEM passphrase forms as CheckPair.
Types ¶
type Bundle ¶
type Bundle struct {
// Certificates is the PEM of every certificate in the bundle, the leaf
// first; PrivateKey the PEM of its key.
Certificates string
PrivateKey string
IssuedTo string
IssuedBy string
IssuedOn time.Time
ValidUntil time.Time
// Fingerprint is the leaf's SHA-256 in colon-separated upper-case hex,
// as Java's keytool prints it.
Fingerprint string
}
Bundle is a parsed client certificate bundle.
func ParseBundle ¶
ParseBundle reads a PEM bundle of a certificate (optionally followed by its chain) and the certificate's private key, and checks the key belongs to the first certificate.