encryption

package
v0.0.0-...-9d23cf2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const KMSKeySizeInBytes int64 = 64

KMSKeySizeInBytes is the key size that is fetched from KMS. 64 bytes key is split into two halves. First half 32 bytes key is used by agent for encryption and second half 32 bytes by clients like cli/console

Variables

View Source
var NewEncrypter = func(log log.T, kmsKeyId string, context map[string]*string, KMSService kmsiface.KMSAPI) (*Encrypter, error) {
	encrypter := Encrypter{kmsKeyId: kmsKeyId, KMSService: KMSService}
	err := encrypter.generateEncryptionKey(log, kmsKeyId, context)
	return &encrypter, err
}

Functions

func KMSDecrypt

func KMSDecrypt(log log.T, svc kmsiface.KMSAPI, ciptherTextBlob []byte, encryptionContext map[string]*string) (plainText []byte, err error)

func KMSGenerateDataKey

func KMSGenerateDataKey(kmsKeyId string, svc kmsiface.KMSAPI, context map[string]*string) (cipherTextKey []byte, plainTextKey []byte, err error)

GenerateDataKey gets cipher text and plain text keys from KMS service

func NewKMSService

func NewKMSService(log log.T) (kmsService *kms.KMS, err error)

Types

type Encrypter

type Encrypter struct {
	KMSService kmsiface.KMSAPI
	// contains filtered or unexported fields
}

func (*Encrypter) Decrypt

func (encrypter *Encrypter) Decrypt(log log.T, cipherText []byte) (plainText []byte, err error)

Decrypt decrypts a byte slice and returns the decrypted slice

func (*Encrypter) Encrypt

func (encrypter *Encrypter) Encrypt(log log.T, plainText []byte) (cipherText []byte, err error)

Encrypt encrypts a byte slice and returns the encrypted slice

func (*Encrypter) GetEncryptedDataKey

func (encrypter *Encrypter) GetEncryptedDataKey() (ciptherTextBlob []byte)

GetEncryptedDataKey returns the cipherText that was pulled from KMS

func (*Encrypter) GetKMSKeyId

func (encrypter *Encrypter) GetKMSKeyId() (kmsKey string)

GetKMSKeyId gets the KMS key id that is used to generate the encryption key

type IEncrypter

type IEncrypter interface {
	Encrypt(log log.T, plainText []byte) (cipherText []byte, err error)
	Decrypt(log log.T, cipherText []byte) (plainText []byte, err error)
	GetEncryptedDataKey() (ciptherTextBlob []byte)
}

type KMSKeyProvider

type KMSKeyProvider interface {
	GenerateDataKey()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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