Documentation
¶
Overview ¶
Package envelope implements pure in-memory envelope encryption using a two-tier key hierarchy: system keys (KEKs) protect data encryption keys (DEKs), and DEKs protect application data.
Index ¶
- type Envelope
- func (e *Envelope) ActiveKeyID() string
- func (e *Envelope) Decrypt(systemKeyID string, encryptedDEK []byte, ciphertext string) (string, error)
- func (e *Envelope) Encrypt(systemKeyID string, encryptedDEK []byte, plaintext string) (string, error)
- func (e *Envelope) GenerateDEK() ([]byte, error)
- func (e *Envelope) UnwrapDEK(systemKeyID string, encryptedDEK []byte) ([]byte, error)
- func (e *Envelope) WrapDEK(systemKeyID string, dek []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Envelope ¶ added in v0.0.5
type Envelope struct {
// contains filtered or unexported fields
}
Envelope performs in-memory envelope encrypt/decrypt and DEK wrapping/unwrapping. It is safe for concurrent use and has zero storage or database dependencies.
func (*Envelope) ActiveKeyID ¶ added in v0.0.5
ActiveKeyID returns the active system key ID from the keyring.
func (*Envelope) Decrypt ¶ added in v0.0.5
func (e *Envelope) Decrypt(systemKeyID string, encryptedDEK []byte, ciphertext string) (string, error)
Decrypt unwraps the encrypted DEK using the specified system key, then decrypts the base64-encoded ciphertext using the DEK and returns the plaintext.
func (*Envelope) Encrypt ¶ added in v0.0.5
func (e *Envelope) Encrypt(systemKeyID string, encryptedDEK []byte, plaintext string) (string, error)
Encrypt unwraps the encrypted DEK using the specified system key, then encrypts the plaintext with the DEK and returns base64-encoded ciphertext.
func (*Envelope) GenerateDEK ¶ added in v0.0.5
GenerateDEK generates a new cryptographically secure random DEK matching the cipher's key size. The caller is responsible for scrubbing memory with encryption.ZeroBytes(dek) when done.