Documentation
¶
Overview ¶
Package crypto encrypts vendor LLM keys at rest with AES-256-GCM.
The keyring is parsed from KTMS_ENCRYPTION_KEYS ("1:<base64 32B>,2:..."). Every ciphertext records the key version that sealed it, so rotation is: add a higher version to the env, redeploy, re-encrypt all rows, drop the old version. Direct GCM rather than envelope encryption — this guards a few dozen rows, and a KMS round trip per read would buy nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoKeys = errors.New("crypto: no encryption keys configured") ErrUnknownVersion = errors.New("crypto: unknown key version") )
Functions ¶
func EncodeVersioned ¶
EncodeVersioned encodes a version and ciphertext blob as "v:<base64>".
func Fingerprint ¶ added in v1.2.0
Fingerprint names a credential without revealing it: the first 8 bytes of its SHA-256 in hex. Clients compute the same to tell whether a stored vendor key equals the one they hold, since the key itself is never returned.
Types ¶
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Keyring holds every key version the service can decrypt with, plus the active version used for new writes.
func ParseKeyring ¶
ParseKeyring reads "version:base64key[,version:base64key]". The highest version becomes active. Versions must be positive and keys exactly 32 bytes.
func (*Keyring) ActiveVersion ¶
ActiveVersion is the key version Encrypt seals with.
func (*Keyring) DecodeVersioned ¶
DecodeVersioned decodes an encoded string and decrypts it with the keyring.