kms

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudKM

type CloudKM struct {
	// contains filtered or unexported fields
}

CloudKM is used to connect to the 3 major cloud (AWS, GCP, Azure) providers key management solutions.

func (*CloudKM) GetRepositoryKey

func (k *CloudKM) GetRepositoryKey() ([]byte, error)

type Keeper

type Keeper interface {
	Encrypt(ctx context.Context, plaintext []byte) (ciphertext []byte, err error)
	Decrypt(ctx context.Context, ciphertext []byte) (plaintext []byte, err error)
	Close() error
}

func NewCloudKeeper added in v1.1.0

func NewCloudKeeper(opts *Options) (Keeper, error)

NewCloudKeeper connects to the external KMS based on opts.KeyURL and returns a Keeper for direct encrypt/decrypt operations without managing a repository key.

type KeyManager

type KeyManager interface {
	// GetRepositoryKey retrieves the key we will use to envelope the different backup keys. This key should never be
	// written to disk unencrypted.
	GetRepositoryKey() ([]byte, error)
}

KeyManager is a simple interface so that we can switch between different KMS solutions.

func NewCloudKM

func NewCloudKM(opts *Options) (KeyManager, error)

NewCloudKM will connect to the external KM and load the repository and user keys as needed.

type Options

type Options struct {
	// KeyURL is the URL of the user master key (KEK). The scheme selects the provider.
	KeyURL string
	// EncryptedKey is the wrapped repository DEK, base64-encoded. Read from
	// backup-meta.json's encryption_options.encrypted_key field. When empty,
	// NewCloudKM generates a new DEK and populates this field with the wrapped result.
	EncryptedKey string

	// OverrideEndpoint overrides the KMS endpoint (e.g. for localstack).
	OverrideEndpoint string
	// KeyRegion is the AWS region for awskms://.
	KeyRegion string
	// TenantID is the Azure tenant ID for azurekeyvault://.
	TenantID string
	// AccessKeyID is the AWS access key ID, or Azure client/app ID.
	AccessKeyID string
	// SecretAccessKey is the AWS secret access key, Azure client secret, or Vault token.
	SecretAccessKey string
	// RefreshToken is used by AWS credential providers that issue temporary credentials.
	RefreshToken string
	// AuthFile is the path to a service-account JSON file for gcpkms://.
	AuthFile string
	// JSONCreds is the raw GCP service-account JSON for gcpkms://. Takes precedence over AuthFile.
	JSONCreds []byte
	// AuthByInstanceMetaData explicitly enables authentication by instance metadata for AWS KMS.
	AuthByInstanceMetaData bool
}

Options holds the cloud KMS configuration needed to wrap or unwrap a repository data-encryption key. It covers all supported cloud providers (AWS, GCP, Azure, HashiCorp Vault) and is intentionally limited to cloud KMS — passphrase mode is not represented here.

Jump to

Keyboard shortcuts

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