kms

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package kms provides an AWS KMS encryption provider for field-level encryption. It uses KMS for envelope encryption: GenerateDataKey creates DEKs via KMS, and Decrypt unwraps them. Field-level encryption uses the plaintext DEK locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KMSClient

type KMSClient interface {
	Encrypt(ctx context.Context, params *kms.EncryptInput, optFns ...func(*kms.Options)) (*kms.EncryptOutput, error)
	Decrypt(ctx context.Context, params *kms.DecryptInput, optFns ...func(*kms.Options)) (*kms.DecryptOutput, error)
	GenerateDataKey(ctx context.Context, params *kms.GenerateDataKeyInput, optFns ...func(*kms.Options)) (*kms.GenerateDataKeyOutput, error)
}

KMSClient defines the subset of the KMS API used by the provider.

type Option

type Option func(*Provider)

Option configures a KMS Provider.

func WithKMSClient

func WithKMSClient(client KMSClient) Option

WithKMSClient sets the KMS client.

type Provider

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

Provider implements encryption.Provider using AWS KMS.

func New

func New(opts ...Option) *Provider

New creates a new KMS encryption provider.

func (*Provider) Close

func (p *Provider) Close() error

Close marks the provider as closed.

func (*Provider) Decrypt

func (p *Provider) Decrypt(ctx context.Context, keyID string, ciphertext []byte) ([]byte, error)

Decrypt decrypts ciphertext using the KMS key.

func (*Provider) DecryptDataKey

func (p *Provider) DecryptDataKey(ctx context.Context, keyID string, encryptedKey []byte) ([]byte, error)

DecryptDataKey decrypts an encrypted DEK using the KMS Decrypt API.

func (*Provider) Encrypt

func (p *Provider) Encrypt(ctx context.Context, keyID string, plaintext []byte) ([]byte, error)

Encrypt encrypts plaintext using the KMS key.

func (*Provider) GenerateDataKey

func (p *Provider) GenerateDataKey(ctx context.Context, keyID string) (*encryption.DataKey, error)

GenerateDataKey creates a new DEK using KMS GenerateDataKey API. Returns a 256-bit (32-byte) AES key.

Jump to

Keyboard shortcuts

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