keys

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package keys provides RSA key management for the Transaction Token Service. It handles key generation, rotation, and serving public keys via a JWKS endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWKSet

type JWKSet struct {
	Keys []PublicKey `json:"keys"`
}

JWKSet is a JSON Web Key Set (RFC 7517).

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles RSA key lifecycle: generation, rotation, and public key serving. It maintains a current signing key and optionally a previous key for graceful rotation.

func NewManager

func NewManager(keySize int, rotationInterval time.Duration) (*Manager, error)

NewManager creates a new key manager with an initial RSA key pair.

func (*Manager) JWKSHandler

func (m *Manager) JWKSHandler() http.Handler

JWKSHandler returns an HTTP handler that serves the JWKS endpoint.

func (*Manager) PublicKeys

func (m *Manager) PublicKeys() []PublicKey

PublicKeys returns the public keys (current + previous if present) for JWKS serving.

func (*Manager) Rotate

func (m *Manager) Rotate() error

Rotate generates a new key pair, making the current key the previous one. The previous key is kept for one rotation cycle to allow in-flight token verification.

func (*Manager) SigningKey

func (m *Manager) SigningKey() (*rsa.PrivateKey, string)

SigningKey returns the current RSA private key and its key ID.

type PublicKey

type PublicKey struct {
	Kty string `json:"kty"`
	Use string `json:"use"`
	Alg string `json:"alg"`
	Kid string `json:"kid"`
	N   string `json:"n"`
	E   string `json:"e"`
}

PublicKey represents an RSA public key in JWK format (RFC 7517).

func (*PublicKey) RSAPublicKey

func (pk *PublicKey) RSAPublicKey() (*rsa.PublicKey, error)

RSAPublicKey converts the JWK PublicKey back to an *rsa.PublicKey.

Jump to

Keyboard shortcuts

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