kms

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 43 Imported by: 0

README

KMS

Parity grade: A · SDK aws-sdk-go-v2/service/kms@v1.54.0 · last audited 2026-07-12 (db25aeabef5bf3f7a33c8ed328247641b3ffcc15)

Coverage

Metric Value
Operations audited 54 (54 ok)
Feature families 4 (4 ok)
Known gaps 5
Deferred items 2
Resource leaks found
Known gaps
  • GrantConstraints has no SourceArn field (real SDK: GrantConstraints.SourceArn); no operation in this mock threads a caller/resource ARN through crypto calls to check against it, and no other service adapter currently supplies one either — deferred, needs cross-cutting request-context plumbing, not a KMS-local fix (bd: gopherstack-w3k)
  • CreateGrantInput has no GrantTokens field (real SDK: authorizes the CreateGrant call itself via an existing not-yet-consistent grant). No IAM/authorization layer exists anywhere in this mock, so this field would currently be a no-op; deferred, consistent with the rest of the codebase's scope
  • GranteeServicePrincipal / RetiringServicePrincipal (AWS-service grantees) not modeled on CreateGrantInput; same no-IAM-layer scope reasoning as above
  • RESOLVED 2026-07-12: DescribeKeyInput was missing the GrantTokens field -- added + wired validateGrantTokenPresence (see the DescribeKey op row and describe_key_grant_tokens_test.go). Unlike the CreateGrant/CreateGrantInput GrantTokens gap above (which authorizes the CreateGrant call itself and has nothing to validate without an IAM layer), DescribeKey's GrantTokens resolve to real existing grants, so validation is meaningful and AWS-accurate here (DescribeKey declares InvalidGrantTokenException).
  • RESOLVED 2026-07-12: the region-scoped KeyId resolution inconsistency (GetKeyPolicy/PutKeyPolicy/CreateGrant/ListGrants/RevokeGrant/RetireGrant indexed their policiesStore/grantsRegion using the request region instead of an ARN's embedded region). Root cause was two-fold and both fixed at source: (1) these ops discarded the region resolveKeyID returned and re-used getRegion(ctx) -- fixed by adding a shared resolveKeyAndRegion helper (lookupKey now delegates to it too) that returns the key's actual region, and routing all six ops through it; (2) resolveKeyID's resolution cache stored only the resolved UUID and returned the REQUEST region on every cache hit, so even the region resolveKeyID returned was wrong for any ARN resolved more than once -- fixed by caching a {keyID, region} pair (region="" sentinel for aliases means 'derive from request context', so alias behavior is unchanged; ARN caches its own embedded region, which is safe because the region is part of the ARN cache key). Verified by region_scoped_resolution_test.go (cross-region ReplicateKey -> replica-ARN Put/GetKeyPolicy round-trip + full grant lifecycle by ARN, all while ctx defaults to the primary's region).
Deferred
  • Custom key store cryptographic connection/HSM simulation (ConnectCustomKeyStore is a pure state-machine transition; no CloudHSM cluster or XKS proxy is modeled, matching pre-existing scope)
  • GetKeyLastUsage (not a real AWS KMS operation; left as-is from a prior pass, out of scope for this sweep)

More

Documentation

Overview

Package kms provides a mock AWS Key Management Service (KMS) implementation.

Index

Constants

View Source
const (

	// MockAccountID is the mock AWS account ID.
	MockAccountID = config.DefaultAccountID
	// MockRegion is the mock AWS region.
	MockRegion = config.DefaultRegion
)
View Source
const ConnectionStateConnected = "CONNECTED"

ConnectionStateConnected indicates a custom key store is connected.

View Source
const ConnectionStateDisconnected = "DISCONNECTED"

ConnectionStateDisconnected indicates a custom key store is disconnected.

View Source
const KeyOriginAWSKMS = "AWS_KMS"

KeyOriginAWSKMS is the origin for keys whose material is generated by AWS KMS.

View Source
const KeyOriginExternal = "EXTERNAL"

KeyOriginExternal is the origin for keys whose material is imported by the customer.

View Source
const KeyStateDisabled = "Disabled"

KeyStateDisabled is the string constant for a disabled key.

View Source
const KeyStateEnabled = "Enabled"

KeyStateEnabled is the string constant for an enabled key.

View Source
const KeyStatePendingDeletion = "PendingDeletion"

KeyStatePendingDeletion is the string constant for a key pending deletion.

View Source
const KeyStatePendingImport = "PendingImport"

KeyStatePendingImport is the string constant for a key awaiting imported key material.

View Source
const KeyUsageEncryptDecrypt = "ENCRYPT_DECRYPT"

KeyUsageEncryptDecrypt is the string constant for the default key usage.

View Source
const KeyUsageGenerateMac = "GENERATE_VERIFY_MAC"

KeyUsageGenerateMac is the key usage for HMAC keys.

View Source
const KeyUsageKeyAgreement = "KEY_AGREEMENT"

KeyUsageKeyAgreement is the key usage for ECDH key agreement keys.

View Source
const KeyUsageSignVerify = "SIGN_VERIFY"

KeyUsageSignVerify is the string constant for sign/verify-only keys.

Variables

View Source
var (
	// ErrKeyNotFound is returned when the specified key does not exist.
	ErrKeyNotFound = errors.New("NotFoundException")

	// ErrMalformedPolicyDocument is returned when the provided policy is invalid.
	ErrMalformedPolicyDocument = errors.New("MalformedPolicyDocumentException")
	// ErrAliasNotFound is returned when the specified alias does not exist.
	ErrAliasNotFound = errors.New("NotFoundException")
	// ErrAliasAlreadyExists is returned when an alias with the given name already exists.
	ErrAliasAlreadyExists = errors.New("AlreadyExistsException")
	// ErrCustomKeyStoreAlreadyExists is returned when a custom key store with the given name already exists.
	ErrCustomKeyStoreAlreadyExists = errors.New("CustomKeyStoreNameInUseException")
	// ErrCustomKeyStoreNotFound is returned when a custom key store ID does not exist.
	ErrCustomKeyStoreNotFound = errors.New("CustomKeyStoreNotFoundException")
	// ErrKeyDisabled is returned when an operation is attempted on a disabled key.
	ErrKeyDisabled = errors.New("DisabledException")
	// ErrKeyInvalidState is returned when a key is in a state that does not allow the requested
	// operation (e.g. PendingDeletion).
	ErrKeyInvalidState = errors.New("KMSInvalidStateException")
	// ErrInvalidKeyUsage is returned when the key is used for an operation incompatible with its
	// KeyUsage (e.g. encrypting with a SIGN_VERIFY key).
	ErrInvalidKeyUsage = errors.New("InvalidKeyUsageException")
	// ErrInvalidCiphertext is returned when the ciphertext cannot be decrypted.
	ErrInvalidCiphertext = errors.New("InvalidCiphertextException")
	// ErrIncorrectKey is returned when the KMS key identified by a caller-supplied KeyId
	// (Decrypt) or SourceKeyId (ReEncrypt) is not the key that encrypted the ciphertext.
	ErrIncorrectKey = errors.New("IncorrectKeyException")
	// ErrGrantNotFound is returned when the specified grant does not exist.
	ErrGrantNotFound = errors.New("NotFoundException: grant not found")
	// ErrCiphertextTooShort is returned when the ciphertext is too short.
	ErrCiphertextTooShort = errors.New("ciphertext too short")
	// ErrInvalidDataKeySize is returned when a data key size is invalid or too large.
	ErrInvalidDataKeySize = errors.New("ValidationException: invalid data key size")
	// ErrInvalidSignature is returned when a signature verification fails.
	ErrInvalidSignature = errors.New("KMSInvalidSignatureException")
	// ErrKeyMaterialUnavailable is returned when key material is missing (e.g. restored from
	// an older snapshot that predates key material persistence).
	ErrKeyMaterialUnavailable = errors.New("key material unavailable for this key")
	// ErrUnsupportedOrigin is returned when an operation is incompatible with the key's origin.
	ErrUnsupportedOrigin = errors.New("UnsupportedOperationException")
	// ErrValidation is returned for invalid request parameters (maps to ValidationException).
	ErrValidation = errors.New("ValidationException")
	// ErrExpiredKeyMaterial is returned when a key's imported material has passed its ValidTo date.
	ErrExpiredKeyMaterial = errors.New("ExpiredImportTokenException")
	// ErrInvalidGrantToken is returned when a grant token is expired or malformed.
	ErrInvalidGrantToken = errors.New("InvalidGrantTokenException")
	// ErrLimitExceeded is returned when a service limit is exceeded (e.g. grants per key).
	ErrLimitExceeded = errors.New("LimitExceededException")
	// ErrInvalidAlgorithm is returned when an algorithm is not valid for the key spec.
	ErrInvalidAlgorithm = errors.New("InvalidAlgorithmException")
)
View Source
var ErrNilAppContext = errors.New("nil AppContext passed to KMS Provider.Init")

ErrNilAppContext is returned by Init when a nil AppContext is passed.

View Source
var ErrUnknownOperation = errors.New("UnknownOperationException")

ErrUnknownOperation is returned when the requested KMS operation is not supported.

Functions

func UnixTimeFloat

func UnixTimeFloat(t time.Time) float64

UnixTimeFloat converts a time value to a Unix timestamp float.

Types

type Alias

type Alias struct {
	// AliasName is the alias name (e.g., alias/my-key).
	AliasName string `json:"AliasName"`
	// AliasArn is the full ARN of the alias.
	AliasArn string `json:"AliasArn"`
	// TargetKeyId is the key ID that this alias points to.
	TargetKeyID string `json:"TargetKeyId,omitempty"`
	// CreationDate is the Unix timestamp when the alias was created.
	CreationDate float64 `json:"CreationDate,omitempty"`
	// LastUpdatedDate is the Unix timestamp when the alias was last updated.
	LastUpdatedDate float64 `json:"LastUpdatedDate,omitempty"`
}

Alias represents a KMS alias pointing to a key.

type CancelKeyDeletionInput

type CancelKeyDeletionInput struct {
	KeyID string `json:"KeyId"`
}

CancelKeyDeletionInput is the request payload for CancelKeyDeletion.

type CancelKeyDeletionOutput

type CancelKeyDeletionOutput struct {
	KeyID    string `json:"KeyId"`
	KeyState string `json:"KeyState"`
}

CancelKeyDeletionOutput is the response payload for CancelKeyDeletion.

type ConfigProvider

type ConfigProvider interface {
	GetKMSSettings() Settings
}

ConfigProvider is a private interface to extract KMS configuration from the abstract AppContext Config.

type ConnectCustomKeyStoreInput

type ConnectCustomKeyStoreInput struct {
	// CustomKeyStoreId identifies the custom key store to connect.
	CustomKeyStoreID string `json:"CustomKeyStoreId"`
}

ConnectCustomKeyStoreInput is the request payload for ConnectCustomKeyStore.

type CreateAliasInput

type CreateAliasInput struct {
	// AliasName is the name of the alias (must begin with alias/).
	AliasName string `json:"AliasName"`
	// TargetKeyId is the key ID the alias should point to.
	TargetKeyID string `json:"TargetKeyId"`
}

CreateAliasInput is the request payload for CreateAlias.

type CreateCustomKeyStoreInput

type CreateCustomKeyStoreInput struct {
	// CustomKeyStoreName is the name of the custom key store to create.
	CustomKeyStoreName string `json:"CustomKeyStoreName"`
	// CustomKeyStoreType is the type of custom key store (default AWS_CLOUDHSM).
	CustomKeyStoreType string `json:"CustomKeyStoreType,omitempty"`
}

CreateCustomKeyStoreInput is the request payload for CreateCustomKeyStore.

type CreateCustomKeyStoreOutput

type CreateCustomKeyStoreOutput struct {
	// CustomKeyStoreId is the ID of the newly created custom key store.
	CustomKeyStoreID string `json:"CustomKeyStoreId"`
}

CreateCustomKeyStoreOutput is the response payload for CreateCustomKeyStore.

type CreateGrantInput

type CreateGrantInput struct {
	Constraints       *GrantConstraints `json:"Constraints,omitempty"`
	KeyID             string            `json:"KeyId"`
	GranteePrincipal  string            `json:"GranteePrincipal"`
	RetiringPrincipal string            `json:"RetiringPrincipal,omitempty"`
	Name              string            `json:"Name,omitempty"`
	Operations        []string          `json:"Operations"`
}

CreateGrantInput is the request payload for CreateGrant.

type CreateGrantOutput

type CreateGrantOutput struct {
	GrantID    string `json:"GrantId"`
	GrantToken string `json:"GrantToken"`
}

CreateGrantOutput is the response payload for CreateGrant.

type CreateKeyInput

type CreateKeyInput struct {
	Description                    string `json:"Description,omitempty"`
	KeyUsage                       string `json:"KeyUsage,omitempty"`
	KeySpec                        string `json:"KeySpec,omitempty"`
	Origin                         string `json:"Origin,omitempty"`
	Policy                         string `json:"Policy,omitempty"`
	Region                         string `json:"-"`
	Tags                           []Tag  `json:"Tags,omitempty"`
	MultiRegion                    bool   `json:"MultiRegion,omitempty"`
	BypassPolicyLockoutSafetyCheck bool   `json:"BypassPolicyLockoutSafetyCheck,omitempty"`
}

CreateKeyInput is the request payload for CreateKey.

type CreateKeyOutput

type CreateKeyOutput struct {
	// KeyMetadata contains the newly created key metadata.
	KeyMetadata KeyMetadata `json:"KeyMetadata"`
}

CreateKeyOutput is the response payload for CreateKey.

type CustomKeyStore

type CustomKeyStore struct {
	CustomKeyStoreID   string  `json:"CustomKeyStoreId"`
	CustomKeyStoreName string  `json:"CustomKeyStoreName"`
	ConnectionState    string  `json:"ConnectionState"`
	CustomKeyStoreType string  `json:"CustomKeyStoreType"`
	CreationDate       float64 `json:"CreationDate"`
}

CustomKeyStore represents an AWS KMS custom key store entry.

type DecryptInput

type DecryptInput struct {
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens    []string `json:"GrantTokens,omitempty"`
	KeyID          string   `json:"KeyId,omitempty"`
	CiphertextBlob []byte   `json:"CiphertextBlob"`
}

DecryptInput is the request payload for Decrypt.

type DecryptOutput

type DecryptOutput struct {
	KeyID               string `json:"KeyId"`
	EncryptionAlgorithm string `json:"EncryptionAlgorithm,omitempty"`
	Plaintext           []byte `json:"Plaintext"`
}

DecryptOutput is the response payload for Decrypt.

type DeleteAliasInput

type DeleteAliasInput struct {
	// AliasName is the name of the alias to delete.
	AliasName string `json:"AliasName"`
}

DeleteAliasInput is the request payload for DeleteAlias.

type DeleteCustomKeyStoreInput

type DeleteCustomKeyStoreInput struct {
	// CustomKeyStoreId identifies the custom key store to delete.
	CustomKeyStoreID string `json:"CustomKeyStoreId"`
}

DeleteCustomKeyStoreInput is the request payload for DeleteCustomKeyStore.

type DeleteImportedKeyMaterialInput

type DeleteImportedKeyMaterialInput struct {
	// KeyId identifies the EXTERNAL-origin key whose material should be deleted.
	KeyID string `json:"KeyId"`
}

DeleteImportedKeyMaterialInput is the request payload for DeleteImportedKeyMaterial.

type DeriveSharedSecretInput

type DeriveSharedSecretInput struct {
	// KeyId is the ECC key (KEY_AGREEMENT usage) used to derive the shared secret.
	KeyID string `json:"KeyId"`
	// KeyAgreementAlgorithm is the key agreement algorithm (always ECDH).
	KeyAgreementAlgorithm string `json:"KeyAgreementAlgorithm"`
	// PublicKey is the DER-encoded public key of the other party.
	PublicKey []byte `json:"PublicKey"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

DeriveSharedSecretInput is the request payload for DeriveSharedSecret.

type DeriveSharedSecretOutput

type DeriveSharedSecretOutput struct {
	KeyID                 string `json:"KeyId"`
	KeyAgreementAlgorithm string `json:"KeyAgreementAlgorithm"`
	SharedSecret          []byte `json:"SharedSecret"`
}

DeriveSharedSecretOutput is the response payload for DeriveSharedSecret.

type DescribeCustomKeyStoresInput

type DescribeCustomKeyStoresInput struct {
	// CustomKeyStoreId filters results to a single custom key store by ID.
	CustomKeyStoreID string `json:"CustomKeyStoreId,omitempty"`
	// CustomKeyStoreName filters results to a single custom key store by name.
	CustomKeyStoreName string `json:"CustomKeyStoreName,omitempty"`
	// Limit caps the number of results returned.
	Limit *int32 `json:"Limit,omitempty"`
	// Marker is the pagination cursor from a previous call.
	Marker string `json:"Marker,omitempty"`
}

DescribeCustomKeyStoresInput is the request payload for DescribeCustomKeyStores.

type DescribeCustomKeyStoresOutput

type DescribeCustomKeyStoresOutput struct {
	NextMarker      string           `json:"NextMarker,omitempty"`
	CustomKeyStores []CustomKeyStore `json:"CustomKeyStores"`
	Truncated       bool             `json:"Truncated"`
}

DescribeCustomKeyStoresOutput is the response payload for DescribeCustomKeyStores.

type DescribeKeyInput

type DescribeKeyInput struct {
	// KeyId is the key ID or alias to describe.
	KeyID string `json:"KeyId"`
	// GrantTokens is an optional list of grant tokens used to make a just-created
	// grant that permits DescribeKey immediately effective. DescribeKey is a valid
	// grant operation (see isValidGrantOperation) and the real DescribeKey op
	// declares InvalidGrantTokenException in its error set, so a supplied token
	// must resolve to an existing, unexpired grant.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

DescribeKeyInput is the request payload for DescribeKey.

type DescribeKeyOutput

type DescribeKeyOutput struct {
	// KeyMetadata contains the key metadata.
	KeyMetadata KeyMetadata `json:"KeyMetadata"`
}

DescribeKeyOutput is the response payload for DescribeKey.

type DisableKeyInput

type DisableKeyInput struct {
	KeyID string `json:"KeyId"`
}

DisableKeyInput is the request payload for DisableKey.

type DisableKeyRotationInput

type DisableKeyRotationInput struct {
	// KeyId is the key to disable rotation for.
	KeyID string `json:"KeyId"`
}

DisableKeyRotationInput is the request payload for DisableKeyRotation.

type DisconnectCustomKeyStoreInput

type DisconnectCustomKeyStoreInput struct {
	// CustomKeyStoreId identifies the custom key store to disconnect.
	CustomKeyStoreID string `json:"CustomKeyStoreId"`
}

DisconnectCustomKeyStoreInput is the request payload for DisconnectCustomKeyStore.

type EnableKeyInput

type EnableKeyInput struct {
	KeyID string `json:"KeyId"`
}

EnableKeyInput is the request payload for EnableKey.

type EnableKeyRotationInput

type EnableKeyRotationInput struct {
	RotationPeriodInDays *int32 `json:"RotationPeriodInDays,omitempty"`
	KeyID                string `json:"KeyId"`
}

EnableKeyRotationInput is the request payload for EnableKeyRotation.

type EncryptInput

type EncryptInput struct {
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
	KeyID       string   `json:"KeyId"`
	Plaintext   []byte   `json:"Plaintext"`
}

EncryptInput is the request payload for Encrypt.

type EncryptOutput

type EncryptOutput struct {
	KeyID               string `json:"KeyId"`
	EncryptionAlgorithm string `json:"EncryptionAlgorithm,omitempty"`
	CiphertextBlob      []byte `json:"CiphertextBlob"`
}

EncryptOutput is the response payload for Encrypt.

type ErrorResponse

type ErrorResponse struct {
	// Type is the error type string.
	Type string `json:"__type"`
	// Message is the human-readable error message.
	Message string `json:"message"`
}

ErrorResponse is the KMS JSON error response format.

type GenerateDataKeyInput

type GenerateDataKeyInput struct {
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	NumberOfBytes     *int32            `json:"NumberOfBytes,omitempty"`
	KeyID             string            `json:"KeyId"`
	KeySpec           string            `json:"KeySpec,omitempty"`
	GrantTokens       []string          `json:"GrantTokens,omitempty"`
}

GenerateDataKeyInput is the request payload for GenerateDataKey.

type GenerateDataKeyOutput

type GenerateDataKeyOutput struct {
	KeyID          string `json:"KeyId"`
	CiphertextBlob []byte `json:"CiphertextBlob"`
	Plaintext      []byte `json:"Plaintext"`
}

GenerateDataKeyOutput is the response payload for GenerateDataKey.

type GenerateDataKeyPairInput

type GenerateDataKeyPairInput struct {
	// EncryptionContext is the optional encryption context for the wrapping key.
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	// KeyId is the KMS symmetric key used to encrypt the private key.
	KeyID string `json:"KeyId"`
	// KeyPairSpec specifies the asymmetric key spec (e.g. RSA_2048, ECC_NIST_P256).
	KeyPairSpec string `json:"KeyPairSpec"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

GenerateDataKeyPairInput is the request payload for GenerateDataKeyPair.

type GenerateDataKeyPairOutput

type GenerateDataKeyPairOutput struct {
	// KeyId is the ARN of the wrapping KMS key.
	KeyID string `json:"KeyId"`
	// KeyPairSpec is the key pair spec used.
	KeyPairSpec string `json:"KeyPairSpec"`
	// PrivateKeyCiphertextBlob is the DER-encoded private key encrypted under KeyId.
	PrivateKeyCiphertextBlob []byte `json:"PrivateKeyCiphertextBlob"`
	// PrivateKeyPlaintext is the DER-encoded PKCS#8 private key.
	PrivateKeyPlaintext []byte `json:"PrivateKeyPlaintext"`
	// PublicKey is the DER-encoded SubjectPublicKeyInfo public key.
	PublicKey []byte `json:"PublicKey"`
}

GenerateDataKeyPairOutput is the response payload for GenerateDataKeyPair.

type GenerateDataKeyPairWithoutPlaintextInput

type GenerateDataKeyPairWithoutPlaintextInput struct {
	// EncryptionContext is the optional encryption context for the wrapping key.
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	// KeyId is the KMS symmetric key used to encrypt the private key.
	KeyID string `json:"KeyId"`
	// KeyPairSpec specifies the asymmetric key spec (e.g. RSA_2048, ECC_NIST_P256).
	KeyPairSpec string `json:"KeyPairSpec"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

GenerateDataKeyPairWithoutPlaintextInput is the request payload for GenerateDataKeyPairWithoutPlaintext.

type GenerateDataKeyPairWithoutPlaintextOutput

type GenerateDataKeyPairWithoutPlaintextOutput struct {
	// KeyId is the ARN of the wrapping KMS key.
	KeyID string `json:"KeyId"`
	// KeyPairSpec is the key pair spec used.
	KeyPairSpec string `json:"KeyPairSpec"`
	// PrivateKeyCiphertextBlob is the DER-encoded private key encrypted under KeyId.
	PrivateKeyCiphertextBlob []byte `json:"PrivateKeyCiphertextBlob"`
	// PublicKey is the DER-encoded SubjectPublicKeyInfo public key.
	PublicKey []byte `json:"PublicKey"`
}

GenerateDataKeyPairWithoutPlaintextOutput is the response payload for GenerateDataKeyPairWithoutPlaintext.

type GenerateDataKeyWithoutPlaintextInput

type GenerateDataKeyWithoutPlaintextInput struct {
	EncryptionContext map[string]string `json:"EncryptionContext,omitempty"`
	NumberOfBytes     *int32            `json:"NumberOfBytes,omitempty"`
	KeyID             string            `json:"KeyId"`
	KeySpec           string            `json:"KeySpec,omitempty"`
	GrantTokens       []string          `json:"GrantTokens,omitempty"`
}

GenerateDataKeyWithoutPlaintextInput is the request payload for GenerateDataKeyWithoutPlaintext.

type GenerateDataKeyWithoutPlaintextOutput

type GenerateDataKeyWithoutPlaintextOutput struct {
	KeyID          string `json:"KeyId"`
	CiphertextBlob []byte `json:"CiphertextBlob"`
}

GenerateDataKeyWithoutPlaintextOutput is the response payload for GenerateDataKeyWithoutPlaintext.

type GenerateMacInput

type GenerateMacInput struct {
	// KeyId is the HMAC KMS key used to generate the MAC.
	KeyID string `json:"KeyId"`
	// MacAlgorithm specifies the MAC algorithm (e.g. HMAC_SHA_256).
	MacAlgorithm string `json:"MacAlgorithm"`
	// Message is the data over which to compute the MAC.
	Message []byte `json:"Message"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

GenerateMacInput is the request payload for GenerateMac.

type GenerateMacOutput

type GenerateMacOutput struct {
	KeyID        string `json:"KeyId"`
	MacAlgorithm string `json:"MacAlgorithm"`
	Mac          []byte `json:"Mac"`
}

GenerateMacOutput is the response payload for GenerateMac.

type GenerateRandomInput

type GenerateRandomInput struct {
	// NumberOfBytes specifies how many random bytes to generate (default 32, max 1024).
	NumberOfBytes *int32 `json:"NumberOfBytes,omitempty"`
}

GenerateRandomInput is the request payload for GenerateRandom.

type GenerateRandomOutput

type GenerateRandomOutput struct {
	// Plaintext contains the generated random bytes.
	Plaintext []byte `json:"Plaintext"`
}

GenerateRandomOutput is the response payload for GenerateRandom.

type GetKeyLastUsageInput

type GetKeyLastUsageInput struct {
	KeyID string `json:"KeyId"` //nolint:tagliatelle // AWS API uses KeyId
}

GetKeyLastUsageInput is the request payload for GetKeyLastUsage.

type GetKeyLastUsageOutput

type GetKeyLastUsageOutput struct {
	KeyLastUsage      *KeyLastUsageData `json:"KeyLastUsage,omitempty"`
	KeyID             string            `json:"KeyId,omitempty"`
	KeyCreationDate   float64           `json:"KeyCreationDate,omitempty"`
	TrackingStartDate float64           `json:"TrackingStartDate,omitempty"`
}

GetKeyLastUsageOutput is the response payload for GetKeyLastUsage.

type GetKeyPolicyInput

type GetKeyPolicyInput struct {
	KeyID      string `json:"KeyId"`
	PolicyName string `json:"PolicyName"`
}

GetKeyPolicyInput is the request payload for GetKeyPolicy.

type GetKeyPolicyOutput

type GetKeyPolicyOutput struct {
	Policy     string `json:"Policy"`
	PolicyName string `json:"PolicyName"`
}

GetKeyPolicyOutput is the response payload for GetKeyPolicy.

type GetKeyRotationStatusInput

type GetKeyRotationStatusInput struct {
	// KeyId is the key to query rotation status for.
	KeyID string `json:"KeyId"`
}

GetKeyRotationStatusInput is the request payload for GetKeyRotationStatus.

type GetKeyRotationStatusOutput

type GetKeyRotationStatusOutput struct {
	KeyID                     string  `json:"KeyId"`
	NextRotationDate          float64 `json:"NextRotationDate,omitempty"`
	OnDemandRotationStartDate float64 `json:"OnDemandRotationStartDate,omitempty"`
	RotationPeriodInDays      int32   `json:"RotationPeriodInDays,omitempty"`
	KeyRotationEnabled        bool    `json:"KeyRotationEnabled"`
}

GetKeyRotationStatusOutput is the response payload for GetKeyRotationStatus.

type GetParametersForImportInput

type GetParametersForImportInput struct {
	KeyID             string `json:"KeyId"`
	WrappingAlgorithm string `json:"WrappingAlgorithm,omitempty"`
	WrappingKeySpec   string `json:"WrappingKeySpec,omitempty"`
}

GetParametersForImportInput is the request payload for GetParametersForImport.

type GetParametersForImportOutput

type GetParametersForImportOutput struct {
	KeyID             string  `json:"KeyId"`
	ImportToken       []byte  `json:"ImportToken"`
	PublicKey         []byte  `json:"PublicKey"`
	ParametersValidTo float64 `json:"ParametersValidTo"`
}

GetParametersForImportOutput is the response payload for GetParametersForImport.

type GetPublicKeyInput

type GetPublicKeyInput struct {
	// KeyId identifies the asymmetric KMS key whose public key to retrieve.
	KeyID string `json:"KeyId"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

GetPublicKeyInput is the request payload for GetPublicKey.

type GetPublicKeyOutput

type GetPublicKeyOutput struct {
	// KeyId is the ID of the asymmetric KMS key.
	KeyID string `json:"KeyId"`
	// PublicKey is the DER-encoded public key.
	PublicKey []byte `json:"PublicKey"`
	// KeySpec is the key spec of the key.
	KeySpec string `json:"KeySpec"`
	// KeyUsage is the intended use of the key.
	KeyUsage string `json:"KeyUsage"`
	// SigningAlgorithms lists the signing algorithms supported by this key.
	SigningAlgorithms []string `json:"SigningAlgorithms,omitempty"`
	// EncryptionAlgorithms lists the encryption algorithms (empty for sign keys).
	EncryptionAlgorithms []string `json:"EncryptionAlgorithms,omitempty"`
	// KeyAgreementAlgorithms lists the key agreement algorithms (e.g. ECDH).
	KeyAgreementAlgorithms []string `json:"KeyAgreementAlgorithms,omitempty"`
}

GetPublicKeyOutput is the response payload for GetPublicKey.

type Grant

type Grant struct {
	// Constraints holds optional encryption context constraints for the grant.
	Constraints *GrantConstraints `json:"Constraints,omitempty"`
	// GrantID is the unique identifier for the grant.
	GrantID string `json:"GrantId"`
	// KeyID is the ID of the KMS key.
	KeyID string `json:"KeyId"`
	// GranteePrincipal is the principal that receives the grant.
	GranteePrincipal string `json:"GranteePrincipal"`
	// RetiringPrincipal is the principal that can retire the grant.
	RetiringPrincipal string `json:"RetiringPrincipal,omitempty"`
	// GrantToken is a token that can be used to identify this grant.
	GrantToken string `json:"GrantToken"`
	// TokenIssuedAt records when the grant token was issued, enabling expiry checks.
	TokenIssuedAt time.Time `json:"TokenIssuedAt"`
	// Name is an optional name for the grant.
	Name string `json:"Name,omitempty"`
	// Operations is the list of cryptographic operations the grantee can perform.
	Operations []string `json:"Operations"`
	// CreationDate is the Unix timestamp when the grant was created.
	CreationDate float64 `json:"CreationDate"`
}

Grant represents a KMS key grant.

type GrantConstraints

type GrantConstraints struct {
	// EncryptionContextEquals requires the caller's encryption context to be
	// an exact match of this map (same keys and values).
	EncryptionContextEquals map[string]string `json:"EncryptionContextEquals,omitempty"`
	// EncryptionContextSubset requires the caller's encryption context to
	// contain at least all key-value pairs present in this map.
	EncryptionContextSubset map[string]string `json:"EncryptionContextSubset,omitempty"`
}

GrantConstraints holds the encryption context constraints for a grant. When set, cryptographic operations using this grant's token must supply an encryption context that satisfies the constraint.

type Handler

type Handler struct {
	Backend StorageBackend

	DefaultRegion string
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for KMS operations.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new KMS handler with the given storage backend and logger.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this KMS instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the KMS operation name from the X-Amz-Target header.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the key ID from the request body when present.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported KMS operations (sorted alphabetically).

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for KMS operations.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority for the KMS handler.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state in the backend and the handler's tag store. It is used by the POST /_gopherstack/reset endpoint for CI pipelines.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable. It accepts both the current wrapped format (handlerSnapshot) and a legacy snapshot (raw bytes produced by delegating straight to Backend.Snapshot, with no handler-level tags) so that pre-existing on-disk snapshots taken before tags were persisted still restore backend state cleanly instead of erroring out.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a matcher that identifies KMS requests by the X-Amz-Target header.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable. It wraps the backend's own snapshot together with handler-level resource tags (see handlerSnapshot) so a Restore round-trip preserves tags, not just key/alias/grant state.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker starts the background janitor if one is configured.

func (*Handler) TagKeyByARN

func (h *Handler) TagKeyByARN(ctx context.Context, keyARN string, newTags map[string]string) error

TagKeyByARN applies tags to the KMS key identified by its ARN.

func (*Handler) TaggedKeys

func (h *Handler) TaggedKeys(ctx context.Context) []TaggedKeyInfo

TaggedKeys returns a snapshot of all KMS keys with their ARNs and tags. Intended for use by the Resource Groups Tagging API provider.

func (*Handler) UntagKeyByARN

func (h *Handler) UntagKeyByARN(ctx context.Context, keyARN string, tagKeys []string) error

UntagKeyByARN removes the specified tag keys from the KMS key identified by its ARN.

func (*Handler) WithJanitor

func (h *Handler) WithJanitor(interval time.Duration, taskTimeout ...time.Duration) *Handler

WithJanitor attaches a background key-deletion janitor to the handler. If the backend is not an *InMemoryBackend, this is a no-op.

type ImportKeyMaterialInput

type ImportKeyMaterialInput struct {
	KeyID           string  `json:"KeyId"`
	ExpirationModel string  `json:"ExpirationModel,omitempty"`
	KeyMaterial     []byte  `json:"KeyMaterial"`
	ValidTo         float64 `json:"ValidTo,omitempty"`
}

ImportKeyMaterialInput is the request payload for ImportKeyMaterial.

type InMemoryBackend

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

InMemoryBackend is a concurrency-safe in-memory KMS backend.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates and returns a new empty KMS backend with default account/region.

func NewInMemoryBackendWithConfig

func NewInMemoryBackendWithConfig(accountID, region string) *InMemoryBackend

NewInMemoryBackendWithConfig creates a new KMS backend with the given account ID and region.

func (*InMemoryBackend) AddCustomKeyStoreInternal

func (b *InMemoryBackend) AddCustomKeyStoreInternal(ks *CustomKeyStore)

AddCustomKeyStoreInternal inserts a custom key store directly into the backend. This is intended for test seeding only.

func (*InMemoryBackend) AddKeyInternal

func (b *InMemoryBackend) AddKeyInternal(key *Key, km *keyMaterial)

AddKeyInternal inserts a key directly into the backend without going through CreateKey. It also inserts the provided key material if non-nil. This is intended for test seeding only. The region is derived from the key ARN, falling back to defaultRegion.

func (*InMemoryBackend) CancelKeyDeletion

func (b *InMemoryBackend) CancelKeyDeletion(
	ctx context.Context,
	input *CancelKeyDeletionInput,
) (*CancelKeyDeletionOutput, error)

CancelKeyDeletion cancels a pending key deletion and sets the key to Disabled. AWS raises KMSInvalidStateException if the key is not in PendingDeletion state.

func (*InMemoryBackend) ConnectCustomKeyStore

func (b *InMemoryBackend) ConnectCustomKeyStore(
	ctx context.Context,
	input *ConnectCustomKeyStoreInput,
) error

ConnectCustomKeyStore transitions a custom key store from DISCONNECTED to CONNECTED.

func (*InMemoryBackend) CreateAlias

func (b *InMemoryBackend) CreateAlias(ctx context.Context, input *CreateAliasInput) error

CreateAlias creates an alias pointing to a key.

func (*InMemoryBackend) CreateCustomKeyStore

func (b *InMemoryBackend) CreateCustomKeyStore(
	ctx context.Context, input *CreateCustomKeyStoreInput,
) (*CreateCustomKeyStoreOutput, error)

CreateCustomKeyStore creates a new in-memory custom key store entry in DISCONNECTED state.

func (*InMemoryBackend) CreateGrant

func (b *InMemoryBackend) CreateGrant(
	ctx context.Context,
	input *CreateGrantInput,
) (*CreateGrantOutput, error)

CreateGrant creates a new grant on the specified key.

func (*InMemoryBackend) CreateKey

func (b *InMemoryBackend) CreateKey(
	ctx context.Context,
	input *CreateKeyInput,
) (*CreateKeyOutput, error)

CreateKey creates a new KMS key and stores it in the backend.

func (*InMemoryBackend) Decrypt

func (b *InMemoryBackend) Decrypt(
	ctx context.Context,
	input *DecryptInput,
) (*DecryptOutput, error)

func (*InMemoryBackend) DeleteAlias

func (b *InMemoryBackend) DeleteAlias(ctx context.Context, input *DeleteAliasInput) error

DeleteAlias removes an alias. Per AWS KMS behaviour, an alias pointing to a key in PendingDeletion state cannot be deleted — the caller must cancel the deletion first.

func (*InMemoryBackend) DeleteCustomKeyStore

func (b *InMemoryBackend) DeleteCustomKeyStore(
	ctx context.Context,
	input *DeleteCustomKeyStoreInput,
) error

DeleteCustomKeyStore removes an existing custom key store. It must be in DISCONNECTED state.

func (*InMemoryBackend) DeleteImportedKeyMaterial

func (b *InMemoryBackend) DeleteImportedKeyMaterial(
	ctx context.Context,
	input *DeleteImportedKeyMaterialInput,
) error

DeleteImportedKeyMaterial removes the imported key material from an EXTERNAL-origin key. The key transitions to PendingImport; it can receive new material via ImportKeyMaterial.

func (*InMemoryBackend) DeriveSharedSecret

func (b *InMemoryBackend) DeriveSharedSecret(
	ctx context.Context, input *DeriveSharedSecretInput,
) (*DeriveSharedSecretOutput, error)

DeriveSharedSecret computes an ECDH shared secret using an ECC KEY_AGREEMENT KMS key and the provided DER-encoded peer public key.

func (*InMemoryBackend) DescribeCustomKeyStores

func (b *InMemoryBackend) DescribeCustomKeyStores(
	ctx context.Context, input *DescribeCustomKeyStoresInput,
) (*DescribeCustomKeyStoresOutput, error)

DescribeCustomKeyStores returns a list of custom key stores matching optional filters.

func (*InMemoryBackend) DescribeKey

func (b *InMemoryBackend) DescribeKey(
	ctx context.Context,
	input *DescribeKeyInput,
) (*DescribeKeyOutput, error)

DescribeKey returns metadata for the specified key.

func (*InMemoryBackend) DisableKey

func (b *InMemoryBackend) DisableKey(ctx context.Context, input *DisableKeyInput) error

DisableKey disables the specified key. AWS raises KMSInvalidStateException for keys in PendingDeletion or PendingImport states.

func (*InMemoryBackend) DisableKeyRotation

func (b *InMemoryBackend) DisableKeyRotation(
	ctx context.Context,
	input *DisableKeyRotationInput,
) error

DisableKeyRotation disables automatic key rotation for the specified key. Asymmetric keys and EXTERNAL-origin keys do not support rotation and return ErrUnsupportedOrigin.

func (*InMemoryBackend) DisconnectCustomKeyStore

func (b *InMemoryBackend) DisconnectCustomKeyStore(
	ctx context.Context,
	input *DisconnectCustomKeyStoreInput,
) error

DisconnectCustomKeyStore transitions a custom key store from CONNECTED to DISCONNECTED.

func (*InMemoryBackend) EnableKey

func (b *InMemoryBackend) EnableKey(ctx context.Context, input *EnableKeyInput) error

EnableKey enables the specified key. AWS raises KMSInvalidStateException for keys in PendingDeletion or PendingImport states.

func (*InMemoryBackend) EnableKeyRotation

func (b *InMemoryBackend) EnableKeyRotation(
	ctx context.Context,
	input *EnableKeyRotationInput,
) error

EnableKeyRotation enables automatic key rotation for the specified key. The rotation period defaults to 365 days. Rotation is NOT performed immediately; it is scheduled starting from the key's creation date or last rotation date. The key must be in the Enabled state.

func (*InMemoryBackend) Encrypt

func (b *InMemoryBackend) Encrypt(
	ctx context.Context,
	input *EncryptInput,
) (*EncryptOutput, error)

Encrypt encrypts the given plaintext using the specified key.

func (*InMemoryBackend) GenerateDataKey

func (b *InMemoryBackend) GenerateDataKey(
	ctx context.Context,
	input *GenerateDataKeyInput,
) (*GenerateDataKeyOutput, error)

GenerateDataKey generates a random data key, returning both plaintext and encrypted forms.

func (*InMemoryBackend) GenerateDataKeyPair

func (b *InMemoryBackend) GenerateDataKeyPair(
	ctx context.Context, input *GenerateDataKeyPairInput,
) (*GenerateDataKeyPairOutput, error)

GenerateDataKeyPair generates a new ephemeral asymmetric key pair, returning the public key, plaintext private key (DER-encoded PKCS#8), and the private key encrypted under the specified KMS wrapping key.

func (*InMemoryBackend) GenerateDataKeyPairWithoutPlaintext

GenerateDataKeyPairWithoutPlaintext generates an asymmetric key pair but omits the plaintext private key from the response.

func (*InMemoryBackend) GenerateDataKeyWithoutPlaintext

GenerateDataKeyWithoutPlaintext generates a data key but returns only the encrypted copy.

func (*InMemoryBackend) GenerateMac

func (b *InMemoryBackend) GenerateMac(
	ctx context.Context,
	input *GenerateMacInput,
) (*GenerateMacOutput, error)

GenerateMac computes an HMAC tag over the provided message using an HMAC KMS key.

func (*InMemoryBackend) GenerateRandom

func (b *InMemoryBackend) GenerateRandom(
	_ context.Context,
	input *GenerateRandomInput,
) (*GenerateRandomOutput, error)

GenerateRandom returns the requested number of cryptographically secure random bytes. NumberOfBytes defaults to 32 when not specified; maximum is 1024.

func (*InMemoryBackend) GetKeyLastUsage

func (b *InMemoryBackend) GetKeyLastUsage(
	ctx context.Context,
	input *GetKeyLastUsageInput,
) (*GetKeyLastUsageOutput, error)

GetKeyLastUsage returns the last successful cryptographic operation performed with the specified key.

func (*InMemoryBackend) GetKeyPolicy

func (b *InMemoryBackend) GetKeyPolicy(
	ctx context.Context,
	input *GetKeyPolicyInput,
) (*GetKeyPolicyOutput, error)

GetKeyPolicy retrieves the key policy for a KMS key.

func (*InMemoryBackend) GetKeyRotationStatus

func (b *InMemoryBackend) GetKeyRotationStatus(
	ctx context.Context,
	input *GetKeyRotationStatusInput,
) (*GetKeyRotationStatusOutput, error)

GetKeyRotationStatus returns rotation configuration and schedule for the specified key.

func (*InMemoryBackend) GetParametersForImport

func (b *InMemoryBackend) GetParametersForImport(
	ctx context.Context, input *GetParametersForImportInput,
) (*GetParametersForImportOutput, error)

GetParametersForImport returns wrapping parameters for EXTERNAL-origin key material import. Returns a real RSA public key (DER-encoded SubjectPublicKeyInfo) that callers can use to RSA-OAEP-wrap their key material before calling ImportKeyMaterial.

func (*InMemoryBackend) GetPublicKey

func (b *InMemoryBackend) GetPublicKey(
	ctx context.Context,
	input *GetPublicKeyInput,
) (*GetPublicKeyOutput, error)

GetPublicKey returns the public key for an asymmetric KMS key.

func (*InMemoryBackend) ImportKeyMaterial

func (b *InMemoryBackend) ImportKeyMaterial(
	ctx context.Context,
	input *ImportKeyMaterialInput,
) error

ImportKeyMaterial imports externally supplied key material into a key created with Origin=EXTERNAL. The key must be in PendingImport state. On success the key transitions to Enabled. Only SYMMETRIC_DEFAULT keys are supported; asymmetric EXTERNAL keys are not modeled by this mock.

func (*InMemoryBackend) ListAliases

func (b *InMemoryBackend) ListAliases(
	ctx context.Context,
	input *ListAliasesInput,
) (*ListAliasesOutput, error)

ListAliases returns a paginated list of aliases, optionally filtered by key.

func (*InMemoryBackend) ListGrants

func (b *InMemoryBackend) ListGrants(
	ctx context.Context,
	input *ListGrantsInput,
) (*ListGrantsOutput, error)

ListGrants returns the grants for a specified key with optional pagination and GrantId filter.

func (*InMemoryBackend) ListKeyPolicies

func (b *InMemoryBackend) ListKeyPolicies(
	ctx context.Context,
	input *ListKeyPoliciesInput,
) (*ListKeyPoliciesOutput, error)

ListKeyPolicies returns policy names available for a key.

func (*InMemoryBackend) ListKeyRotations

func (b *InMemoryBackend) ListKeyRotations(
	ctx context.Context,
	input *ListKeyRotationsInput,
) (*ListKeyRotationsOutput, error)

ListKeyRotations returns observed key material rotation timestamps for a key.

func (*InMemoryBackend) ListKeys

func (b *InMemoryBackend) ListKeys(
	ctx context.Context,
	input *ListKeysInput,
) (*ListKeysOutput, error)

ListKeys returns a paginated list of all keys.

func (*InMemoryBackend) ListRetirableGrants

func (b *InMemoryBackend) ListRetirableGrants(
	ctx context.Context,
	input *ListRetirableGrantsInput,
) (*ListGrantsOutput, error)

ListRetirableGrants returns all grants for which the given principal is the retiring principal.

func (*InMemoryBackend) PutKeyPolicy

func (b *InMemoryBackend) PutKeyPolicy(ctx context.Context, input *PutKeyPolicyInput) error

PutKeyPolicy stores a key policy for a KMS key. Only the "default" policy name is supported.

func (*InMemoryBackend) ReEncrypt

func (b *InMemoryBackend) ReEncrypt(
	ctx context.Context,
	input *ReEncryptInput,
) (*ReEncryptOutput, error)

ReEncrypt decrypts a ciphertext and re-encrypts it under a different key.

func (*InMemoryBackend) ReplicateKey

func (b *InMemoryBackend) ReplicateKey(
	ctx context.Context,
	input *ReplicateKeyInput,
) (*ReplicateKeyOutput, error)

ReplicateKey creates a multi-region replica for an existing key in the target region.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state from the backend. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable. If a key in the snapshot does not have corresponding key material (e.g. from an older snapshot format), a warning is logged. Callers of Encrypt/Sign/etc. will receive ErrKeyMaterialUnavailable.

func (*InMemoryBackend) RetireGrant

func (b *InMemoryBackend) RetireGrant(ctx context.Context, input *RetireGrantInput) error

RetireGrant retires a grant by grant token or grant ID + key ID.

func (*InMemoryBackend) RevokeGrant

func (b *InMemoryBackend) RevokeGrant(ctx context.Context, input *RevokeGrantInput) error

RevokeGrant revokes a grant by ID.

func (*InMemoryBackend) RotateKeyOnDemand

func (b *InMemoryBackend) RotateKeyOnDemand(
	ctx context.Context,
	input *RotateKeyOnDemandInput,
) (*RotateKeyOnDemandOutput, error)

RotateKeyOnDemand rotates key material immediately without changing automatic rotation status.

func (*InMemoryBackend) ScheduleKeyDeletion

func (b *InMemoryBackend) ScheduleKeyDeletion(
	ctx context.Context,
	input *ScheduleKeyDeletionInput,
) (*ScheduleKeyDeletionOutput, error)

ScheduleKeyDeletion schedules a key for deletion. PendingWindowInDays must be in the range [7, 30]; values outside this range are rejected. AWS raises ValidationException for out-of-range values and KMSInvalidStateException for keys already in PendingDeletion.

func (*InMemoryBackend) Sign

func (b *InMemoryBackend) Sign(ctx context.Context, input *SignInput) (*SignOutput, error)

Sign creates a digital signature for the specified message using an asymmetric KMS key.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable. Key materials that cannot be serialized are omitted from the snapshot with a warning log.

func (*InMemoryBackend) UpdateAlias

func (b *InMemoryBackend) UpdateAlias(ctx context.Context, input *UpdateAliasInput) error

UpdateAlias redirects an existing alias to a different key. The alias must already exist; the target key must exist and not be in PendingDeletion state.

func (*InMemoryBackend) UpdateCustomKeyStore

func (b *InMemoryBackend) UpdateCustomKeyStore(
	ctx context.Context,
	input *UpdateCustomKeyStoreInput,
) error

UpdateCustomKeyStore updates mutable properties for a custom key store.

func (*InMemoryBackend) UpdateKeyDescription

func (b *InMemoryBackend) UpdateKeyDescription(
	ctx context.Context,
	input *UpdateKeyDescriptionInput,
) error

UpdateKeyDescription updates a key's description field.

func (*InMemoryBackend) UpdatePrimaryRegion

func (b *InMemoryBackend) UpdatePrimaryRegion(
	ctx context.Context,
	input *UpdatePrimaryRegionInput,
) error

UpdatePrimaryRegion promotes the replica in PrimaryRegion to be the new primary and demotes the current primary to a replica. Both keys must be Enabled multi-region keys.

func (*InMemoryBackend) Verify

func (b *InMemoryBackend) Verify(ctx context.Context, input *VerifyInput) (*VerifyOutput, error)

Verify verifies a digital signature using an asymmetric KMS key.

func (*InMemoryBackend) VerifyMac

func (b *InMemoryBackend) VerifyMac(
	ctx context.Context,
	input *VerifyMacInput,
) (*VerifyMacOutput, error)

VerifyMac verifies an HMAC tag over the provided message using an HMAC KMS key. Returns an error if the MAC does not match; on success returns the key ARN and algorithm.

type Janitor

type Janitor struct {
	Backend *InMemoryBackend

	Interval time.Duration
	// TaskTimeout bounds each individual janitor task. When non-zero, each task
	// runs with a child context that expires after this duration, preventing a
	// stalled operation from blocking the janitor loop indefinitely.
	TaskTimeout time.Duration
	// contains filtered or unexported fields
}

Janitor is the KMS background worker that permanently deletes keys past their scheduled deletion date and purges the associated key material.

func NewJanitor

func NewJanitor(backend *InMemoryBackend, interval time.Duration) *Janitor

NewJanitor creates a new KMS Janitor for the given backend. A zero interval falls back to defaultKMSJanitorInterval.

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context)

Run runs the janitor loop until ctx is cancelled.

func (*Janitor) SweepOnce

func (j *Janitor) SweepOnce(ctx context.Context)

SweepOnce executes a single deletion sweep. Exposed for testing.

type Key

type Key struct {
	Origin          string `json:"Origin,omitempty"`
	PrimaryRegion   string `json:"PrimaryRegion,omitempty"`
	Description     string `json:"Description,omitempty"`
	KeyState        string `json:"KeyState"`
	KeyUsage        string `json:"KeyUsage"`
	KeySpec         string `json:"KeySpec,omitempty"`
	KeyID           string `json:"KeyId"`
	Arn             string `json:"Arn"`
	ExpirationModel string `json:"ExpirationModel,omitempty"`
	// Rotations stores all rotation events with their types. The separate
	// RotationDates and OnDemandRotationDates slices are kept for JSON
	// backwards-compatibility with existing snapshots.
	Rotations             []RotationRecord `json:"Rotations,omitempty"`
	RotationDates         []float64        `json:"RotationDates,omitempty"`
	OnDemandRotationDates []float64        `json:"OnDemandRotationDates,omitempty"`
	// ReplicaKeyIDs stores the key IDs of replica keys created from this primary.
	ReplicaKeyIDs        []string `json:"ReplicaKeyIds,omitempty"`
	CreationDate         float64  `json:"CreationDate"`
	DeletionDate         float64  `json:"DeletionDate,omitempty"`
	ValidTo              float64  `json:"ValidTo,omitempty"`
	PendingWindowInDays  int      `json:"PendingWindowInDays,omitempty"`
	RotationPeriodInDays int32    `json:"RotationPeriodInDays,omitempty"`
	Enabled              bool     `json:"Enabled"`
	MultiRegion          bool     `json:"MultiRegion,omitempty"`
	RotationEnabled      bool     `json:"RotationEnabled"`
}

Key represents a KMS customer-managed key.

type KeyLastUsageData

type KeyLastUsageData struct {
	CloudTrailEventID string  `json:"CloudTrailEventId,omitempty"`
	KmsRequestID      string  `json:"KmsRequestId,omitempty"`
	Operation         string  `json:"Operation,omitempty"`
	Timestamp         float64 `json:"Timestamp,omitempty"`
}

KeyLastUsageData contains information about the last successful cryptographic operation on a KMS key.

type KeyListEntry

type KeyListEntry struct {
	// KeyId is the UUID of the key.
	KeyID string `json:"KeyId"`
	// KeyArn is the full ARN of the key.
	KeyArn string `json:"KeyArn"`
	// Description is the optional human-readable description of the key.
	Description string `json:"Description,omitempty"`
}

KeyListEntry is a brief key reference used in ListKeys.

type KeyMetadata

type KeyMetadata struct {
	MultiRegionConfiguration    *MultiRegionConfiguration `json:"MultiRegionConfiguration,omitempty"`
	PrimaryRegion               string                    `json:"PrimaryRegion,omitempty"`
	Arn                         string                    `json:"Arn"`
	Description                 string                    `json:"Description,omitempty"`
	KeyState                    string                    `json:"KeyState"`
	KeyUsage                    string                    `json:"KeyUsage"`
	KeyManager                  string                    `json:"KeyManager,omitempty"`
	Origin                      string                    `json:"Origin,omitempty"`
	KeySpec                     string                    `json:"KeySpec,omitempty"`
	KeyID                       string                    `json:"KeyId"`
	CustomerMasterKeySpec       string                    `json:"CustomerMasterKeySpec,omitempty"`
	MultiRegionKeyType          string                    `json:"MultiRegionKeyType,omitempty"`
	ExpirationModel             string                    `json:"ExpirationModel,omitempty"`
	MacAlgorithms               []string                  `json:"MacAlgorithms,omitempty"`
	SigningAlgorithms           []string                  `json:"SigningAlgorithms,omitempty"`
	KeyAgreementAlgorithms      []string                  `json:"KeyAgreementAlgorithms,omitempty"`
	EncryptionAlgorithms        []string                  `json:"EncryptionAlgorithms,omitempty"`
	CreationDate                float64                   `json:"CreationDate"`
	DeletionDate                float64                   `json:"DeletionDate,omitempty"`
	ValidTo                     float64                   `json:"ValidTo,omitempty"`
	PendingDeletionWindowInDays int                       `json:"PendingDeletionWindowInDays,omitempty"`
	MultiRegion                 bool                      `json:"MultiRegion"`
	Enabled                     bool                      `json:"Enabled"`
}

KeyMetadata is the metadata for a KMS key returned in API responses.

type KeyRotationEntry

type KeyRotationEntry struct {
	KeyID        string  `json:"KeyId,omitempty"`
	RotationType string  `json:"RotationType,omitempty"`
	RotationDate float64 `json:"RotationDate"`
}

KeyRotationEntry describes one key rotation event.

type ListAliasesInput

type ListAliasesInput struct {
	// KeyId optionally filters aliases to those pointing to this key.
	KeyID string `json:"KeyId,omitempty"`
	// Limit caps the number of results returned.
	Limit *int32 `json:"Limit,omitempty"`
	// Marker is the pagination cursor from a previous call.
	Marker string `json:"Marker,omitempty"`
}

ListAliasesInput is the request payload for ListAliases.

type ListAliasesOutput

type ListAliasesOutput struct {
	NextMarker string  `json:"NextMarker,omitempty"`
	Aliases    []Alias `json:"Aliases"`
	Truncated  bool    `json:"Truncated"`
}

ListAliasesOutput is the response payload for ListAliases.

type ListGrantsInput

type ListGrantsInput struct {
	Limit   *int32 `json:"Limit,omitempty"`
	KeyID   string `json:"KeyId"`
	GrantID string `json:"GrantId,omitempty"`
	Marker  string `json:"Marker,omitempty"`
}

ListGrantsInput is the request payload for ListGrants.

type ListGrantsOutput

type ListGrantsOutput struct {
	NextMarker string  `json:"NextMarker,omitempty"`
	Grants     []Grant `json:"Grants"`
	Truncated  bool    `json:"Truncated"`
}

ListGrantsOutput is the response payload for ListGrants.

type ListKeyPoliciesInput

type ListKeyPoliciesInput struct {
	Limit  *int32 `json:"Limit,omitempty"`
	KeyID  string `json:"KeyId"`
	Marker string `json:"Marker,omitempty"`
}

ListKeyPoliciesInput is the request payload for ListKeyPolicies.

type ListKeyPoliciesOutput

type ListKeyPoliciesOutput struct {
	NextMarker  string   `json:"NextMarker,omitempty"`
	PolicyNames []string `json:"PolicyNames"`
	Truncated   bool     `json:"Truncated"`
}

ListKeyPoliciesOutput is the response payload for ListKeyPolicies.

type ListKeyRotationsInput

type ListKeyRotationsInput struct {
	Limit  *int32 `json:"Limit,omitempty"`
	KeyID  string `json:"KeyId"`
	Marker string `json:"Marker,omitempty"`
}

ListKeyRotationsInput is the request payload for ListKeyRotations.

type ListKeyRotationsOutput

type ListKeyRotationsOutput struct {
	NextMarker string             `json:"NextMarker,omitempty"`
	Rotations  []KeyRotationEntry `json:"Rotations"`
	Truncated  bool               `json:"Truncated"`
}

ListKeyRotationsOutput is the response payload for ListKeyRotations.

type ListKeysInput

type ListKeysInput struct {
	// Limit caps the number of results returned.
	Limit *int32 `json:"Limit,omitempty"`
	// Marker is the pagination cursor from a previous call.
	Marker string `json:"Marker,omitempty"`
}

ListKeysInput is the request payload for ListKeys.

type ListKeysOutput

type ListKeysOutput struct {
	NextMarker string         `json:"NextMarker,omitempty"`
	Keys       []KeyListEntry `json:"Keys"`
	Truncated  bool           `json:"Truncated"`
}

ListKeysOutput is the response payload for ListKeys.

type ListRetirableGrantsInput

type ListRetirableGrantsInput struct {
	Limit             *int32 `json:"Limit,omitempty"`
	RetiringPrincipal string `json:"RetiringPrincipal"`
	Marker            string `json:"Marker,omitempty"`
}

ListRetirableGrantsInput is the request payload for ListRetirableGrants.

type MultiRegionConfiguration

type MultiRegionConfiguration struct {
	// MultiRegionKeyType is either PRIMARY or REPLICA.
	MultiRegionKeyType string `json:"MultiRegionKeyType,omitempty"`
	// PrimaryKey references the primary key in the multi-region set.
	PrimaryKey *MultiRegionKeyRef `json:"PrimaryKey,omitempty"`
	// ReplicaKeys lists the replica keys associated with the primary.
	ReplicaKeys []MultiRegionKeyRef `json:"ReplicaKeys,omitempty"`
}

MultiRegionConfiguration describes the multi-region key topology.

type MultiRegionKeyRef

type MultiRegionKeyRef struct {
	// Arn is the ARN of the multi-region key.
	Arn string `json:"Arn"`
	// Region is the AWS region of the multi-region key.
	Region string `json:"Region"`
}

MultiRegionKeyRef is a reference to a primary or replica key in a multi-region set.

type Provider

type Provider struct{}

Provider implements service.Provider for the KMS service.

func (*Provider) Init

Init initializes the KMS service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type PutKeyPolicyInput

type PutKeyPolicyInput struct {
	KeyID      string `json:"KeyId"`
	PolicyName string `json:"PolicyName"`
	Policy     string `json:"Policy"`
}

PutKeyPolicyInput is the request payload for PutKeyPolicy.

type ReEncryptInput

type ReEncryptInput struct {
	SourceEncryptionContext      map[string]string `json:"SourceEncryptionContext,omitempty"`
	DestinationEncryptionContext map[string]string `json:"DestinationEncryptionContext,omitempty"`
	DestinationKeyID             string            `json:"DestinationKeyId"`
	SourceKeyID                  string            `json:"SourceKeyId,omitempty"`
	CiphertextBlob               []byte            `json:"CiphertextBlob"`
}

ReEncryptInput is the request payload for ReEncrypt.

type ReEncryptOutput

type ReEncryptOutput struct {
	KeyID                          string `json:"KeyId"`
	SourceKeyID                    string `json:"SourceKeyId"`
	SourceEncryptionAlgorithm      string `json:"SourceEncryptionAlgorithm,omitempty"`
	DestinationEncryptionAlgorithm string `json:"DestinationEncryptionAlgorithm,omitempty"`
	CiphertextBlob                 []byte `json:"CiphertextBlob"`
}

ReEncryptOutput is the response payload for ReEncrypt.

type ReplicateKeyInput

type ReplicateKeyInput struct {
	KeyID         string `json:"KeyId"`
	ReplicaRegion string `json:"ReplicaRegion"`
	Description   string `json:"Description,omitempty"`
	// Policy is the key policy to attach to the replica. If omitted, KMS
	// attaches the default key policy (matches CreateKey's Policy field).
	// The key policy is NOT a shared property of multi-region keys: the
	// replica gets its own independent policy rather than inheriting the
	// primary's.
	Policy string `json:"Policy,omitempty"`
	// Tags are optional tags to apply to the replica key.
	Tags                           []Tag `json:"Tags,omitempty"`
	BypassPolicyLockoutSafetyCheck bool  `json:"BypassPolicyLockoutSafetyCheck,omitempty"`
}

ReplicateKeyInput is the request payload for ReplicateKey.

type ReplicateKeyOutput

type ReplicateKeyOutput struct {
	ReplicaKeyMetadata KeyMetadata `json:"ReplicaKeyMetadata"`
}

ReplicateKeyOutput is the response payload for ReplicateKey.

type RetireGrantInput

type RetireGrantInput struct {
	GrantToken string `json:"GrantToken,omitempty"`
	GrantID    string `json:"GrantId,omitempty"`
	KeyID      string `json:"KeyId,omitempty"`
}

RetireGrantInput is the request payload for RetireGrant.

type RevokeGrantInput

type RevokeGrantInput struct {
	KeyID   string `json:"KeyId"`
	GrantID string `json:"GrantId"`
}

RevokeGrantInput is the request payload for RevokeGrant.

type RotateKeyOnDemandInput

type RotateKeyOnDemandInput struct {
	KeyID string `json:"KeyId"`
}

RotateKeyOnDemandInput is the request payload for RotateKeyOnDemand.

type RotateKeyOnDemandOutput

type RotateKeyOnDemandOutput struct {
	KeyID string `json:"KeyId"`
}

RotateKeyOnDemandOutput is the response payload for RotateKeyOnDemand.

type RotationRecord

type RotationRecord struct {
	RotationType string  `json:"RotationType"`
	Date         float64 `json:"Date"`
}

RotationRecord records a single key material rotation with its type.

type ScheduleKeyDeletionInput

type ScheduleKeyDeletionInput struct {
	KeyID               string `json:"KeyId"`
	PendingWindowInDays int    `json:"PendingWindowInDays,omitempty"`
}

ScheduleKeyDeletionInput is the request payload for ScheduleKeyDeletion.

type ScheduleKeyDeletionOutput

type ScheduleKeyDeletionOutput struct {
	KeyID               string  `json:"KeyId"`
	KeyState            string  `json:"KeyState"`
	DeletionDate        float64 `json:"DeletionDate"`
	PendingWindowInDays int     `json:"PendingWindowInDays,omitempty"`
}

ScheduleKeyDeletionOutput is the response payload for ScheduleKeyDeletion.

type Settings

type Settings struct {
	JanitorInterval time.Duration `json:"janitor_interval" env:"KMS_JANITOR_INTERVAL" default:"1m" help:"Janitor tick interval."` //nolint:lll // Kong struct tag makes this line long
}

Settings holds service-level configuration for the KMS backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command.

type SignInput

type SignInput struct {
	KeyID            string   `json:"KeyId"`
	MessageType      string   `json:"MessageType,omitempty"`
	SigningAlgorithm string   `json:"SigningAlgorithm"`
	Message          []byte   `json:"Message"`
	GrantTokens      []string `json:"GrantTokens,omitempty"`
}

SignInput is the request payload for Sign.

type SignOutput

type SignOutput struct {
	KeyID            string `json:"KeyId"`
	SigningAlgorithm string `json:"SigningAlgorithm"`
	Signature        []byte `json:"Signature"`
}

SignOutput is the response payload for Sign.

type StorageBackend

type StorageBackend interface {
	CreateKey(ctx context.Context, input *CreateKeyInput) (*CreateKeyOutput, error)
	DescribeKey(ctx context.Context, input *DescribeKeyInput) (*DescribeKeyOutput, error)
	ListKeys(ctx context.Context, input *ListKeysInput) (*ListKeysOutput, error)
	Encrypt(ctx context.Context, input *EncryptInput) (*EncryptOutput, error)
	Decrypt(ctx context.Context, input *DecryptInput) (*DecryptOutput, error)
	GenerateDataKey(
		ctx context.Context,
		input *GenerateDataKeyInput,
	) (*GenerateDataKeyOutput, error)
	GenerateDataKeyWithoutPlaintext(
		ctx context.Context, input *GenerateDataKeyWithoutPlaintextInput,
	) (*GenerateDataKeyWithoutPlaintextOutput, error)
	ReEncrypt(ctx context.Context, input *ReEncryptInput) (*ReEncryptOutput, error)
	Sign(ctx context.Context, input *SignInput) (*SignOutput, error)
	Verify(ctx context.Context, input *VerifyInput) (*VerifyOutput, error)
	GetPublicKey(ctx context.Context, input *GetPublicKeyInput) (*GetPublicKeyOutput, error)
	CreateAlias(ctx context.Context, input *CreateAliasInput) error
	UpdateAlias(ctx context.Context, input *UpdateAliasInput) error
	DeleteAlias(ctx context.Context, input *DeleteAliasInput) error
	ListAliases(ctx context.Context, input *ListAliasesInput) (*ListAliasesOutput, error)
	EnableKeyRotation(ctx context.Context, input *EnableKeyRotationInput) error
	DisableKeyRotation(ctx context.Context, input *DisableKeyRotationInput) error
	GetKeyRotationStatus(
		ctx context.Context,
		input *GetKeyRotationStatusInput,
	) (*GetKeyRotationStatusOutput, error)
	DisableKey(ctx context.Context, input *DisableKeyInput) error
	EnableKey(ctx context.Context, input *EnableKeyInput) error
	ScheduleKeyDeletion(
		ctx context.Context,
		input *ScheduleKeyDeletionInput,
	) (*ScheduleKeyDeletionOutput, error)
	CancelKeyDeletion(
		ctx context.Context,
		input *CancelKeyDeletionInput,
	) (*CancelKeyDeletionOutput, error)
	CreateGrant(ctx context.Context, input *CreateGrantInput) (*CreateGrantOutput, error)
	ListGrants(ctx context.Context, input *ListGrantsInput) (*ListGrantsOutput, error)
	RevokeGrant(ctx context.Context, input *RevokeGrantInput) error
	RetireGrant(ctx context.Context, input *RetireGrantInput) error
	ListRetirableGrants(
		ctx context.Context,
		input *ListRetirableGrantsInput,
	) (*ListGrantsOutput, error)
	PutKeyPolicy(ctx context.Context, input *PutKeyPolicyInput) error
	GetKeyPolicy(ctx context.Context, input *GetKeyPolicyInput) (*GetKeyPolicyOutput, error)
	GetParametersForImport(
		ctx context.Context,
		input *GetParametersForImportInput,
	) (*GetParametersForImportOutput, error)
	ListKeyPolicies(
		ctx context.Context,
		input *ListKeyPoliciesInput,
	) (*ListKeyPoliciesOutput, error)
	ListKeyRotations(
		ctx context.Context,
		input *ListKeyRotationsInput,
	) (*ListKeyRotationsOutput, error)
	ImportKeyMaterial(ctx context.Context, input *ImportKeyMaterialInput) error
	DeleteImportedKeyMaterial(ctx context.Context, input *DeleteImportedKeyMaterialInput) error
	ReplicateKey(ctx context.Context, input *ReplicateKeyInput) (*ReplicateKeyOutput, error)
	RotateKeyOnDemand(
		ctx context.Context,
		input *RotateKeyOnDemandInput,
	) (*RotateKeyOnDemandOutput, error)
	ConnectCustomKeyStore(ctx context.Context, input *ConnectCustomKeyStoreInput) error
	CreateCustomKeyStore(
		ctx context.Context,
		input *CreateCustomKeyStoreInput,
	) (*CreateCustomKeyStoreOutput, error)
	DeleteCustomKeyStore(ctx context.Context, input *DeleteCustomKeyStoreInput) error
	DeriveSharedSecret(
		ctx context.Context,
		input *DeriveSharedSecretInput,
	) (*DeriveSharedSecretOutput, error)
	DescribeCustomKeyStores(
		ctx context.Context,
		input *DescribeCustomKeyStoresInput,
	) (*DescribeCustomKeyStoresOutput, error)
	DisconnectCustomKeyStore(ctx context.Context, input *DisconnectCustomKeyStoreInput) error
	UpdateCustomKeyStore(ctx context.Context, input *UpdateCustomKeyStoreInput) error
	UpdateKeyDescription(ctx context.Context, input *UpdateKeyDescriptionInput) error
	UpdatePrimaryRegion(ctx context.Context, input *UpdatePrimaryRegionInput) error
	GenerateDataKeyPair(
		ctx context.Context,
		input *GenerateDataKeyPairInput,
	) (*GenerateDataKeyPairOutput, error)
	GenerateDataKeyPairWithoutPlaintext(
		ctx context.Context, input *GenerateDataKeyPairWithoutPlaintextInput,
	) (*GenerateDataKeyPairWithoutPlaintextOutput, error)
	GenerateMac(ctx context.Context, input *GenerateMacInput) (*GenerateMacOutput, error)
	GenerateRandom(ctx context.Context, input *GenerateRandomInput) (*GenerateRandomOutput, error)
	VerifyMac(ctx context.Context, input *VerifyMacInput) (*VerifyMacOutput, error)
	GetKeyLastUsage(
		ctx context.Context,
		input *GetKeyLastUsageInput,
	) (*GetKeyLastUsageOutput, error)
}

StorageBackend defines the interface for the KMS in-memory backend.

type Tag

type Tag struct {
	// TagKey is the tag key.
	TagKey string `json:"TagKey"`
	// TagValue is the tag value.
	TagValue string `json:"TagValue"`
}

Tag is a key-value pair attached to a KMS resource.

type TaggedKeyInfo

type TaggedKeyInfo struct {
	Tags map[string]string
	ARN  string
}

TaggedKeyInfo contains a KMS key's ARN and tag snapshot. Used by the Resource Groups Tagging API cross-service listing.

type UpdateAliasInput

type UpdateAliasInput struct {
	// AliasName is the existing alias to redirect.
	AliasName string `json:"AliasName"`
	// TargetKeyId is the new key ID the alias should point to.
	TargetKeyID string `json:"TargetKeyId"`
}

UpdateAliasInput is the request payload for UpdateAlias.

type UpdateCustomKeyStoreInput

type UpdateCustomKeyStoreInput struct {
	CustomKeyStoreID      string `json:"CustomKeyStoreId"`
	NewCustomKeyStoreName string `json:"NewCustomKeyStoreName,omitempty"`
}

UpdateCustomKeyStoreInput is the request payload for UpdateCustomKeyStore.

type UpdateKeyDescriptionInput

type UpdateKeyDescriptionInput struct {
	KeyID       string `json:"KeyId"`
	Description string `json:"Description"`
}

UpdateKeyDescriptionInput is the request payload for UpdateKeyDescription.

type UpdatePrimaryRegionInput

type UpdatePrimaryRegionInput struct {
	KeyID         string `json:"KeyId"`
	PrimaryRegion string `json:"PrimaryRegion"`
}

UpdatePrimaryRegionInput is the request payload for UpdatePrimaryRegion.

type VerifyInput

type VerifyInput struct {
	KeyID            string   `json:"KeyId"`
	MessageType      string   `json:"MessageType,omitempty"`
	SigningAlgorithm string   `json:"SigningAlgorithm"`
	Message          []byte   `json:"Message"`
	Signature        []byte   `json:"Signature"`
	GrantTokens      []string `json:"GrantTokens,omitempty"`
}

VerifyInput is the request payload for Verify.

type VerifyMacInput

type VerifyMacInput struct {
	// KeyId is the HMAC KMS key used to verify the MAC.
	KeyID string `json:"KeyId"`
	// MacAlgorithm specifies the MAC algorithm (e.g. HMAC_SHA_256).
	MacAlgorithm string `json:"MacAlgorithm"`
	// Message is the data over which to verify the MAC.
	Message []byte `json:"Message"`
	// Mac is the MAC tag to verify.
	Mac []byte `json:"Mac"`
	// GrantTokens is an optional list of grant tokens used to authorize the operation.
	GrantTokens []string `json:"GrantTokens,omitempty"`
}

VerifyMacInput is the request payload for VerifyMac.

type VerifyMacOutput

type VerifyMacOutput struct {
	KeyID        string `json:"KeyId"`
	MacAlgorithm string `json:"MacAlgorithm"`
	MacValid     bool   `json:"MacValid"`
}

VerifyMacOutput is the response payload for VerifyMac.

type VerifyOutput

type VerifyOutput struct {
	KeyID            string `json:"KeyId"`
	SigningAlgorithm string `json:"SigningAlgorithm"`
	SignatureValid   bool   `json:"SignatureValid"`
}

VerifyOutput is the response payload for Verify.

Jump to

Keyboard shortcuts

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