Help us shape the future of Go! Take the 2026 Go Developer Survey

keymaterial

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

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

View Source
const (
	RSA = "RSA"
	GPG = "GPG"
)

Key pair types the security API accepts.

Variables

View Source
var ErrInvalid = errors.New("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

func CheckPair(pairType, privateKey, publicKey, passphrase string) error

CheckPair verifies that privateKey and publicKey are the two halves of one key of pairType, unlocking privateKey with passphrase when it is encrypted.

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

func ParseBundle(data []byte) (Bundle, error)

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.

Jump to

Keyboard shortcuts

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