gcpkms

package
v0.0.0-...-cb937e8 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0, MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialJSON

type CredentialJSON []byte

CredentialJSON is the service account keys used for authentication towards GCP KMS.

func (CredentialJSON) ApplyToMasterKey

func (c CredentialJSON) ApplyToMasterKey(key *MasterKey)

ApplyToMasterKey configures the CredentialJSON on the provided key.

type MasterKey

type MasterKey struct {
	// ResourceID is the resource id used to refer to the gcp kms key.
	// It can be retrieved using the `gcloud` command.
	ResourceID string
	// EncryptedKey is the string returned after encrypting with GCP KMS.
	EncryptedKey string
	// CreationDate is the creation timestamp of the MasterKey. Used
	// for NeedsRotation.
	CreationDate time.Time
	// contains filtered or unexported fields
}

MasterKey is a GCP KMS key used to encrypt and decrypt the SOPS data key. Adapted from https://github.com/mozilla/sops/blob/v3.7.2/gcpkms/keysource.go to be able to have fine-grain control over the credentials used to authenticate towards GCP KMS.

func MasterKeyFromResourceID

func MasterKeyFromResourceID(resourceID string) *MasterKey

MasterKeyFromResourceID creates a new MasterKey with the provided resource ID.

func (*MasterKey) Decrypt

func (key *MasterKey) Decrypt() ([]byte, error)

Decrypt decrypts the EncryptedKey field with GCP KMS and returns the result.

func (*MasterKey) Encrypt

func (key *MasterKey) Encrypt(datakey []byte) error

Encrypt takes a SOPS data key, encrypts it with GCP KMS, and stores the result in the EncryptedKey field.

func (*MasterKey) EncryptIfNeeded

func (key *MasterKey) EncryptIfNeeded(dataKey []byte) error

EncryptIfNeeded encrypts the provided SOPS data key, if it has not been encrypted yet.

func (*MasterKey) EncryptedDataKey

func (key *MasterKey) EncryptedDataKey() []byte

EncryptedDataKey returns the encrypted data key this master key holds.

func (*MasterKey) NeedsRotation

func (key *MasterKey) NeedsRotation() bool

NeedsRotation returns whether the data key needs to be rotated or not.

func (*MasterKey) SetEncryptedDataKey

func (key *MasterKey) SetEncryptedDataKey(enc []byte)

SetEncryptedDataKey sets the encrypted data key for this master key.

func (MasterKey) ToMap

func (key MasterKey) ToMap() map[string]interface{}

ToMap converts the MasterKey to a map for serialization purposes.

func (*MasterKey) ToString

func (key *MasterKey) ToString() string

ToString converts the key to a string representation.

Jump to

Keyboard shortcuts

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