Documentation
¶
Overview ¶
Package encrypt provides AES-256-GCM encryption middleware for Trove. It encrypts data on write and decrypts on read, using a KeyProvider interface for key management and rotation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encrypt ¶
type Encrypt struct {
// contains filtered or unexported fields
}
Encrypt provides AES-256-GCM encryption middleware.
func (*Encrypt) Direction ¶
func (e *Encrypt) Direction() middleware.Direction
Direction returns ReadWrite since encryption participates in both paths.
func (*Encrypt) WrapReader ¶
func (e *Encrypt) WrapReader(ctx context.Context, r io.ReadCloser, _ *driver.ObjectInfo) (io.ReadCloser, error)
WrapReader wraps a reader to decrypt data from the driver.
func (*Encrypt) WrapWriter ¶
func (e *Encrypt) WrapWriter(ctx context.Context, w io.WriteCloser, _ string) (io.WriteCloser, error)
WrapWriter wraps a writer to encrypt data before it reaches the driver. The encrypted format is: [12-byte nonce][encrypted data + GCM tag]. Since GCM requires knowing the full plaintext, this implementation buffers the data, encrypts, then writes. For large files, use chunked encryption at the stream level.
type KeyProvider ¶
type KeyProvider interface {
// Key returns the current encryption key (must be 32 bytes for AES-256).
Key(ctx context.Context) ([]byte, error)
}
KeyProvider supplies encryption keys. Implementations can fetch keys from Vault, environment variables, or any other source.
type Option ¶
type Option func(*Encrypt)
Option configures the Encrypt middleware.
func WithKeyProvider ¶
func WithKeyProvider(kp KeyProvider) Option
WithKeyProvider sets the key provider.
type StaticKeyProvider ¶
type StaticKeyProvider struct {
// contains filtered or unexported fields
}
StaticKeyProvider is a KeyProvider that returns a fixed key.
func NewStaticKeyProvider ¶
func NewStaticKeyProvider(key []byte) *StaticKeyProvider
NewStaticKeyProvider creates a key provider from a fixed 32-byte key.