encrypt

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAll

func ApplyAll(cfg *config.Config, cmd *cli.Command)

ApplyAll calls Apply on all registered plugins that define one.

func Names

func Names() []string

Names returns all registered provider names.

func PluginFlags

func PluginFlags(cfg *config.Config) []cli.Flag

PluginFlags returns CLI flags contributed by all registered encryption plugins.

func Register

func Register(p Plugin)

Register adds an encryption provider plugin.

Types

type FieldProvider added in v0.0.4

type FieldProvider interface {
	EncryptField(plaintext []byte, domain, identity string) ([]byte, error)
	DecryptField(ciphertext []byte, domain, identity string) ([]byte, error)
}

FieldProvider is the optional provider extension for MSEH v4 persisted-field encryption.

type Header struct {
	Version    uint32
	ProviderID string
	Nonce      []byte
}

Header is passed to DecryptStream after DataEncryptionService has parsed the MSEH envelope. Keeping it here avoids an import cycle with dataencryption.

type Plugin

type Plugin struct {
	Name   string
	Loader func(ctx context.Context, cfg *config.Config) (Provider, error)
	Flags  func(cfg *config.Config) []cli.Flag
	Apply  func(cfg *config.Config, cmd *cli.Command)
}

Plugin bundles a provider name with its loader function.

func Select

func Select(name string) (Plugin, error)

Select returns the Plugin for the given name.

type Provider

type Provider interface {
	// ID returns the provider identifier written into the MSEH header (e.g. "plain", "dek", "vault").
	ID() string

	// Encrypt returns MSEH-wrapped ciphertext (or plaintext for the plain provider).
	Encrypt(plaintext []byte) ([]byte, error)

	// Decrypt accepts MSEH-wrapped ciphertext, legacy bare nonce||ciphertext, or plaintext.
	Decrypt(ciphertext []byte) ([]byte, error)

	// EncryptStream writes the MSEH header to dst then returns a WriteCloser that
	// encrypts written bytes for streaming storage.
	EncryptStream(dst io.Writer) (io.WriteCloser, error)

	// DecryptStream returns a Reader that decrypts bytes from src.
	// header is the already-parsed MSEH header (read by DataEncryptionService).
	DecryptStream(src io.Reader, header *Header) (io.Reader, error)

	// AttachmentSigningKeys returns the ordered set of HMAC keys for attachment
	// download URL signing (primary first, legacy rotation keys after).
	// Returns nil if this provider does not support signed URLs.
	AttachmentSigningKeys(ctx context.Context) ([][]byte, error)
}

Provider is the SPI for pluggable encryption providers. Each provider handles its own MSEH envelope writing on encrypt and accepts MSEH, legacy bare, or plaintext formats on decrypt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL