Documentation
¶
Overview ¶
Package crypto provides AES-256-GCM encryption with versioned keys for rotation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encryptor encrypts and decrypts data using AES-256-GCM with stable key IDs.
func New ¶
New creates an Encryptor. currentKey is the active encryption key (32 bytes for AES-256). oldKeys are previous keys that can still decrypt but won't be used for new encryptions. Panics if any key is not exactly 32 bytes.
func (*Encryptor) DecryptWithAAD ¶ added in v0.4.0
DecryptWithAAD decrypts ciphertext produced by EncryptWithAAD. It returns an error when aad doesn't match the value used at encryption time (the GCM auth tag fails to verify) — that mismatch is the binding guarantee.
func (*Encryptor) EncryptWithAAD ¶ added in v0.4.0
EncryptWithAAD encrypts plaintext into a key-ID envelope containing a nonce and authenticated ciphertext. The aad is authenticated but NOT encrypted; decryption only succeeds when DecryptWithAAD is given the identical aad. Used to bind ciphertext to a context so it cannot be decrypted under another one.
func (*Encryptor) NeedsRewrap ¶ added in v0.4.0
NeedsRewrap reports whether encoded uses a non-current key. It validates only the envelope; Rewrap callers still authenticate it by decrypting before replacing persisted data.