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

approvalcrypto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package approvalcrypto encrypts host-owned approval checkpoints without knowing their plaintext schema or persistence backend.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKeyProvider = errors.New("invalid approval key provider")
	ErrInvalidKeyMaterial = errors.New("invalid approval key material")
	ErrInvalidEnvelope    = errors.New("invalid approval ciphertext envelope")
	// ErrKeyMaterialChanged reports that the key stored under the envelope's
	// key id is not the key that encrypted it, for example because a deleted
	// keychain item was regenerated. The checkpoint cannot be recovered.
	ErrKeyMaterialChanged = errors.New("approval key was replaced since the checkpoint was encrypted")
)
View Source
var (
	ErrKeyMaterialUnavailable = errors.New("approval key material unavailable")
)

Functions

func OpenMacOSKeychainKeyProvider

func OpenMacOSKeychainKeyProvider(serviceName, activeKeyID string) (*keychainKeyProvider, error)

OpenMacOSKeychainKeyProvider is unavailable outside a local macOS host.

Types

type AESGCMCipher

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

AESGCMCipher encrypts versioned checkpoint envelopes with AES-256-GCM.

func NewAESGCMCipher

func NewAESGCMCipher(keys KeyProvider) (*AESGCMCipher, error)

func (*AESGCMCipher) Decrypt

func (c *AESGCMCipher) Decrypt(ctx context.Context, encoded, aad []byte) ([]byte, error)

Decrypt validates the envelope and associated data before returning plaintext.

func (*AESGCMCipher) Encrypt

func (c *AESGCMCipher) Encrypt(ctx context.Context, plaintext, aad []byte) ([]byte, error)

Encrypt protects plaintext and authenticates aad without storing aad itself.

type KeyMaterial

type KeyMaterial struct {
	ID    string
	Bytes []byte
}

KeyMaterial is a host-owned data encryption key. Bytes must contain exactly 32 random bytes for AES-256-GCM and must never be persisted with ciphertext.

type KeyProvider

type KeyProvider interface {
	Active(ctx context.Context) (KeyMaterial, error)
	Resolve(ctx context.Context, keyID string) (KeyMaterial, error)
}

KeyProvider returns the active key for new checkpoints and resolves keys named by older ciphertext envelopes during a key-rotation window.

Jump to

Keyboard shortcuts

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