kmsClient

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSKMS

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

AWSKMS is the implementation of the KeyManagement interface for AWS KMS

func (*AWSKMS) Decrypt

func (a *AWSKMS) Decrypt(ctx context.Context, keyID string, version string, input []byte) (result []byte, _ error)

Decrypt decrypts the input using the AWS KMS client

func (*AWSKMS) Encrypt

func (a *AWSKMS) Encrypt(ctx context.Context, input []byte) (keyID string, version string, result []byte, _ error)

Encrypt encrypts the input using the AWS KMS client

type AWSKMSConfig

type AWSKMSConfig struct {
	// Log is the logger to use for this implementation
	Log *zap.Logger
	// KeyID is the ID of the key to use for encryption and decryption
	AccessKey string
	// Region is the AWS region to use for the KMS client
	Region string
	// SecretKey is the secret key to use for the KMS client
	SecretKey string
	// Endpoint is the endpoint to use for the KMS client
	Endpoint *string
	// KmsKeyID is the ID of the key to use for encryption and decryption
	KmsKeyID string
}

AWSKMSConfig is the configuration for the AWS KMS implementation of the KeyManagement interface

func (*AWSKMSConfig) Validate

func (c *AWSKMSConfig) Validate() error

`func (c *AWSKMSConfig) Validate() error` is a method defined on the `AWSKMSConfig` struct. It validates that all the required fields in the `AWSKMSConfig` struct are present and returns an error if any of them are missing. This method is called when creating a new instance of the `AWSKMS` struct to ensure that the configuration is valid.

type KeyManagement

type KeyManagement interface {
	Encrypt(ctx context.Context, input []byte) (keyID, version string, result []byte, _ error)
	Decrypt(ctx context.Context, keyID, version string, input []byte) (result []byte, _ error)
}

KeyManagement is the interface that defines the methods for encrypting and decrypting data

func NewAWSKMS

func NewAWSKMS(config AWSKMSConfig) (KeyManagement, error)

NewAWSKMS creates a new AWS KMS implementation of the KeyManagement interface

func NewMockAwsKms

func NewMockAwsKms() (KeyManagement, error)

type MockKeyManagement

type MockKeyManagement struct{}

func (*MockKeyManagement) Decrypt

func (*MockKeyManagement) Decrypt(ctx context.Context, keyID string, version string, input []byte) (result []byte, _ error)

Decrypt implements KeyManagement

func (*MockKeyManagement) Encrypt

func (*MockKeyManagement) Encrypt(ctx context.Context, input []byte) (keyID string, version string, result []byte, _ error)

Encrypt implements KeyManagement

Jump to

Keyboard shortcuts

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