encryption

package
v0.0.0-...-06015ec Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAndEncodeEncryptionKey

func GenerateAndEncodeEncryptionKey(t *testing.T) (rawKey []byte, base64Key string)

GenerateAndEncodeEncryptionKey generates a 256-bit AES encryption key and returns both the raw bytes and base64-encoded string. This is a utility function for providers using UNKNOWN_KEY_TYPE (file-based encryption) to generate and encode keys consistently.

func SetupEncryptionSecretsWithName

func SetupEncryptionSecretsWithName(t *testing.T, provider Provider, kubectlOptions *k8s.KubectlOptions, clusterRegion string, secretName string) error

SetupEncryptionSecretsWithName dispatches to the appropriate setup path based on platform type. CMEK providers (GCP_CLOUD_KMS, AWS_KMS) go through KMS encryption; file-based (UNKNOWN_KEY_TYPE) writes raw key bytes directly.

Types

type PlatformConfig

type PlatformConfig struct {
	// Platform is the KMS platform type: "AWS_KMS", "GCP_CLOUD_KMS", or "UNKNOWN_KEY_TYPE"
	Platform string

	// RequiresCredentialsSecret indicates if cmekCredentialsSecretName is required
	// True for AWS_KMS and GCP_KMS, false for UNKNOWN_KEY_TYPE (file-based)
	RequiresCredentialsSecret bool

	// DefaultCredentialsSecretName is the default name for the credentials secret
	// Used when RequiresCredentialsSecret is true
	DefaultCredentialsSecretName string
}

type Provider

type Provider interface {
	// SetupEncryptionInfrastructure creates cloud KMS resources (keys, roles, policies)
	// Returns a cleanup function that should be deferred to ensure proper resource cleanup
	// Called once during test setup, before any encryption secrets are created
	SetupEncryptionInfrastructure(t *testing.T) (cleanup func(), err error)

	// GetEncryptionPlatformConfig returns provider-specific encryption platform configuration
	GetEncryptionPlatformConfig() *PlatformConfig

	// EncryptKey encrypts a plaintext key using the provider's KMS
	// Takes raw key bytes, returns base64-encoded encrypted data
	EncryptKey(plaintextKey []byte, clusterRegion string) (encryptedKeyBase64 string, err error)

	// CreateKeySecret creates the Kubernetes secret with encrypted key data and provider metadata
	// (AuthPrincipal, URI, Region, Type, ExternalID, etc.)
	CreateKeySecret(kubectlOptions *k8s.KubectlOptions, secretName string, encryptedKeyData string, clusterRegion string) error

	// CreateCredentialsSecret creates the Kubernetes secret with cloud credentials
	// Returns the secret name and any error
	CreateCredentialsSecret(kubectlOptions *k8s.KubectlOptions) (string, error)
}

Provider defines the encryption-related methods that cloud providers must implement for encryption-at-rest testing. Providers return configuration, not implementation.

Jump to

Keyboard shortcuts

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