Documentation
¶
Overview ¶
Package encryption provides envelope encryption for Go systems.
Architecture ¶
The library uses envelope encryption: data is encrypted with a Data Encryption Key (DEK), and the DEK is encrypted with a system Key Encryption Key (KEK).
- cipher/: pluggable symmetric encryption interface and implementations (AES-256-GCM)
- systemkey/: system key (KEK) management abstractions and filesystem loaders
- envelope/: pure in-memory envelope encryption engine
- postgres/: stateless PostgreSQL keystore and key lifecycle management
- postgres/migrations: PostgreSQL migration SQL generator
- hash/: deterministic HMAC-SHA256 blind indexing
Package encryption provides envelope encryption for Go systems.
This package defines shared sentinel errors used across all sub-packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("encryption key not found") ErrKeyExists = errors.New("encryption key already exists") ErrEncryption = errors.New("encryption failed") ErrDecryption = errors.New("decryption failed") ErrInvalidKeySize = errors.New("invalid key size") ErrKeyRevoked = errors.New("encryption key has been revoked") ErrKeyDestroyed = errors.New("encryption key has been destroyed") ErrSessionClosed = errors.New("encryption session is closed") ErrInvalidConfig = errors.New("invalid encryption configuration") )
Sentinel errors used across the encryption library.
Functions ¶
Types ¶
type EncryptedKey ¶ added in v0.0.6
type EncryptedKey struct {
Scope string
ScopeID string
KeyVersion int
EncryptedDEK []byte
KEKID string
CreatedAt time.Time
RevokedAt *time.Time
}
EncryptedKey represents a wrapped DEK and its lifecycle metadata.
func (*EncryptedKey) KeyScope ¶ added in v0.0.6
func (k *EncryptedKey) KeyScope() KeyScope
KeyScope returns the key's identifying scope tuple.
type KeyScope ¶ added in v0.0.6
KeyScope uniquely identifies a versioned DEK within a logical namespace.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cipher defines the authenticated symmetric encryption interface (AEAD) used throughout the encryption library.
|
Package cipher defines the authenticated symmetric encryption interface (AEAD) used throughout the encryption library. |
|
aesgcm
Package aesgcm provides an AES-256-GCM implementation of the cipher.Cipher interface.
|
Package aesgcm provides an AES-256-GCM implementation of the cipher.Cipher interface. |
|
cmd
|
|
|
migrate-gen
command
Command migrate-gen generates SQL migration files for the PostgreSQL keystore.
|
Command migrate-gen generates SQL migration files for the PostgreSQL keystore. |
|
Package envelope implements KMS-native envelope encryption using a two-tier key hierarchy: Key Encryption Keys (KEKs) protect per-scope Data Encryption Keys (DEKs), and DEKs protect application data via local AEAD.
|
Package envelope implements KMS-native envelope encryption using a two-tier key hierarchy: Key Encryption Keys (KEKs) protect per-scope Data Encryption Keys (DEKs), and DEKs protect application data via local AEAD. |
|
examples
|
|
|
basic
command
Example: envelope encryption with envelope.Envelope and envelope.Session.
|
Example: envelope encryption with envelope.Envelope and envelope.Session. |
|
pii
command
Example: GDPR PII encryption and crypto-shredding lifecycle with PostgreSQL.
|
Example: GDPR PII encryption and crypto-shredding lifecycle with PostgreSQL. |
|
secrets
command
Example: Secret encryption with key rotation and historical audit retention.
|
Example: Secret encryption with key rotation and historical audit retention. |
|
Package kek defines Key Encryption Key (KEK) abstractions for wrapping, unwrapping, and rewrapping Data Encryption Keys (DEKs).
|
Package kek defines Key Encryption Key (KEK) abstractions for wrapping, unwrapping, and rewrapping Data Encryption Keys (DEKs). |
|
local
Package local implements an in-process symmetric kek.Wrapper using a cipher.Cipher (AES-256-GCM by default) and provides in-memory and file-based KEK loaders.
|
Package local implements an in-process symmetric kek.Wrapper using a cipher.Cipher (AES-256-GCM by default) and provides in-memory and file-based KEK loaders. |
|
migrations
Package migrations exposes the embedded PostgreSQL keystore migration.
|
Package migrations exposes the embedded PostgreSQL keystore migration. |
|
Package testutil provides test helpers for encryption testing.
|
Package testutil provides test helpers for encryption testing. |
Click to show internal directories.
Click to hide internal directories.