kms

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 44 Imported by: 0

README

KMS

Parity grade: A · SDK aws-sdk-go-v2/service/kms@v1.59.0 · last audited 2026-09-23 (d1ed0e39b)

Coverage

Metric Value
PARITY entries audited 54 (54 ok)
Feature families 4 (4 ok)
Known gaps 3
Deferred items 1
Resource leaks fixed
Known gaps
  • XksKeyId (CreateKeyInput, external-key-store variant of CustomKeyStoreId) is unmodeled: no code in CreateKey's declared error set (api_op_CreateKey.go) fits a malformed/missing identifier, and this service defines no ValidationException type at all to carry it, so CreateKey rejects EXTERNAL_KEY_STORE linkage outright with UnsupportedOperationException instead of guessing a code (gopherstack-ufvn).
  • ListKeyRotations ALL_KEY_MATERIAL covers the first AWS_KMS key material only: imported key material pending rotation, ImportState/ExpirationModel/ValidTo and per-generation imported material are unmodeled (EXTERNAL-origin and asymmetric keys get UnsupportedOperationException for ALL_KEY_MATERIAL).
  • External key store proxies are never contacted: XksProxyUriUnreachable/IncorrectAuthenticationCredential/InvalidResponse and the VPC endpoint service existence checks are not modeled; the proxy secret (RawSecretAccessKey) is not stored.
Deferred
  • Custom key store cryptographic connection/HSM simulation: ConnectCustomKeyStore is a pure state-machine transition (verified: no CloudHSM cluster or XKS proxy I/O in custom_key_stores.go); real HSM/XKS connectivity needs an external HSM/key-manager to talk to, which is out of scope for an in-memory emulator.

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 KeyManagerAWS = "AWS"

KeyManagerAWS is DescribeKey's KeyMetadata.KeyManager value for an AWS managed key (e.g. alias/aws/dynamodb), lazily provisioned on first reference -- see aws_managed_keys.go.

View Source
const KeyManagerCustomer = "CUSTOMER"

KeyManagerCustomer is DescribeKey's KeyMetadata.KeyManager value for a customer-created key. It is also the implicit value for a Key.KeyManager zero value, so keys persisted before this field existed still report CUSTOMER (additive persistence: gopherstack-6u8p4).

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 KeyStatePendingReplicaDeletion = "PendingReplicaDeletion"

KeyStatePendingReplicaDeletion is the string constant for a multi-Region primary key whose deletion was scheduled while it still has replica keys. It stays in this non-final state indefinitely until the last replica is actually deleted, at which point it moves to KeyStatePendingDeletion and its waiting period begins.

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")
	// ErrInvalidAliasName is returned by CreateAlias when AliasName doesn't start with
	// "alias/", is reserved ("alias/aws/"), exceeds the length limit, or contains
	// disallowed characters. CreateAlias's own deserializeOpError (kms@v1.55.4
	// deserializers.go) recognizes InvalidAliasNameException for exactly this.
	ErrInvalidAliasName = errors.New("InvalidAliasNameException")
	// 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")
	// ErrCustomKeyStoreInvalidState is returned by CreateKey when the target custom
	// key store's ConnectionState is not CONNECTED, and by Connect/Disconnect/
	// DeleteCustomKeyStore for their own state preconditions (UpdateCustomKeyStore
	// has no ConnectionState guard in this backend; see PARITY.md gopherstack-akm2).
	// CreateKey's own deserializeOpError (kms@v1.55.4 deserializers.go) recognizes
	// CustomKeyStoreInvalidStateException for exactly this.
	ErrCustomKeyStoreInvalidState = errors.New("CustomKeyStoreInvalidStateException")
	// ErrXksProxyInvalidConfiguration rejects an inconsistent external key store proxy configuration.
	ErrXksProxyInvalidConfiguration = errors.New("XksProxyInvalidConfigurationException")
	// ErrXksProxyURIInUse is returned when another store already uses the endpoint+path pair.
	ErrXksProxyURIInUse = errors.New("XksProxyUriInUseException")
	// ErrXksProxyURIEndpointInUse is returned when another store already uses the endpoint.
	ErrXksProxyURIEndpointInUse = errors.New("XksProxyUriEndpointInUseException")
	// ErrXksProxyVPCEndpointServiceInUse is returned when another store already uses the VPC endpoint service.
	ErrXksProxyVPCEndpointServiceInUse = errors.New("XksProxyVpcEndpointServiceInUseException")
	// ErrCustomKeyStoreHasKeys is returned by DeleteCustomKeyStore when the store
	// still contains KMS keys. DeleteCustomKeyStore's own deserializeOpError
	// recognizes CustomKeyStoreHasCMKsException for exactly this ("The custom key
	// store that you delete cannot contain any KMS keys").
	ErrCustomKeyStoreHasKeys = errors.New("CustomKeyStoreHasCMKsException")
	// 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")
	// ErrIncorrectKeyMaterial is returned by ImportKeyMaterial when the supplied key
	// material does not meet expectations (e.g. wrong length for the target key spec).
	// IncorrectKeyMaterialException's doc (kms@v1.55.4 types/errors.go): "the key
	// material in the request is, expired, invalid, or does not meet expectations".
	ErrIncorrectKeyMaterial = errors.New("IncorrectKeyMaterialException")
	// 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")
	// ErrInvalidMac is returned when a VerifyMac HMAC comparison fails. Distinct from
	// ErrInvalidSignature: VerifyMac's own deserializeOpError (kms@v1.55.4
	// deserializers.go) recognizes KMSInvalidMacException, not KMSInvalidSignatureException
	// (that code belongs to Verify only).
	ErrInvalidMac = errors.New("KMSInvalidMacException")
	// 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).
	// "ValidationException" names no per-operation typed exception in kms@v1.55.4 (not in
	// types/errors.go, not in any op's deserializeOpError, and absent from the full
	// api-2.json model too) -- it is real for KMS at the pre-dispatch, protocol level
	// regardless: KMS's own GetPublicKey doc quotes a live wire ValidationException for a
	// malformed PublicKey that no op declares, and deserializeOpError's default case
	// preserves an unmodeled wire code rather than rejecting it. Settled by
	// gopherstack-q9bs; the sites below using it are correct, not landmines.
	ErrValidation = errors.New("ValidationException")
	// ErrDryRun is returned by the 15 KMS ops whose input carries a DryRun member
	// (CreateGrant, Decrypt, DeriveSharedSecret, Encrypt, GenerateDataKey,
	// GenerateDataKeyPair, GenerateDataKeyPairWithoutPlaintext,
	// GenerateDataKeyWithoutPlaintext, GenerateMac, ReEncrypt, RetireGrant,
	// RevokeGrant, Sign, Verify, VerifyMac -- grepped `DryRun \*bool` across
	// aws-sdk-go-v2/service/kms@v1.54.0's api_op_*.go) when DryRun=true and every
	// other check the op performs passes. DryRunOperationException's doc
	// (types/errors.go): "The request was rejected because the DryRun
	// parameter was specified".
	ErrDryRun = errors.New("DryRunOperationException")
	// 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)
	// or, per LimitExceededException's own doc ("a length constraint or quota was
	// exceeded"), a length constraint -- CreateKey's Description and CreateGrant's
	// Name length checks reuse it for exactly that (gopherstack-i4q8).
	ErrLimitExceeded = errors.New("LimitExceededException")
	// ErrAccessDenied is returned when a grant token is valid but its Operations list
	// does not authorize the operation being performed.
	ErrAccessDenied = errors.New("AccessDeniedException")
	// ErrInvalidTag is returned when a tag key/value fails KMS's format constraints
	// (empty key, length limit, reserved "aws:" prefix). TagResource, CreateKey and
	// ReplicateKey's deserializeOpError all recognize TagException for this.
	ErrInvalidTag = errors.New("TagException")
	// ErrUnsupportedParameter is returned when a KeySpec/KeyPairSpec/WrappingAlgorithm/
	// WrappingKeySpec/PolicyName value is not one this operation supports. CreateKey,
	// GenerateDataKeyPair(WithoutPlaintext), GetParametersForImport, the rotation
	// ops and PutKeyPolicy all recognize UnsupportedOperationException for an
	// unsupported parameter value, per its doc ("a specified parameter is not
	// supported") -- gopherstack-i4q8 added the PutKeyPolicy reuse; gopherstack-5rjn
	// added validateKeySpecUsage's KeySpec/KeyUsage pairing check.
	ErrUnsupportedParameter = errors.New("UnsupportedOperationException")
	// ErrInvalidImportToken is returned when ImportKeyMaterial's wrapped key material
	// cannot be unwrapped because no GetParametersForImport wrapping key is on record
	// for the target KMS key (stale or skipped GetParametersForImport call).
	// ImportKeyMaterial's deserializeOpError recognizes InvalidImportTokenException.
	ErrInvalidImportToken = errors.New("InvalidImportTokenException")
	// ErrInvalidArn is returned by resolveKeyID/resolveARNKeyID for a malformed KeyId
	// ARN, for the KeyId-accepting operations whose own deserializeOpError recognizes
	// InvalidArnException (gopherstack-qxaj). Crypto ops (Encrypt, Decrypt, Sign,
	// GenerateDataKey, ...) do not model it -- those callers pass ErrKeyNotFound
	// instead, the only resource-shaped code they do recognize.
	ErrInvalidArn = errors.New("InvalidArnException")
)
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"`
}

CancelKeyDeletionOutput is the response payload for CancelKeyDeletion. KeyState is intentionally absent: the real CancelKeyDeletionOutput has only KeyId (kms@v1.59.0 api_op_CancelKeyDeletion.go:69).

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"`
	// CloudHsmClusterID and TrustAnchorCertificate are AWS_CLOUDHSM-only
	// inputs, echoed back verbatim by DescribeCustomKeyStores.
	CloudHsmClusterID      string `json:"CloudHsmClusterId,omitempty"`
	TrustAnchorCertificate string `json:"TrustAnchorCertificate,omitempty"`
	// EXTERNAL_KEY_STORE proxy settings.
	XksProxyAuthenticationCredential *XksProxyAuthenticationCredential `json:"XksProxyAuthenticationCredential,omitempty"`
	XksProxyConnectivity             string                            `json:"XksProxyConnectivity,omitempty"`
	XksProxyURIEndpoint              string                            `json:"XksProxyUriEndpoint,omitempty"`
	XksProxyURIPath                  string                            `json:"XksProxyUriPath,omitempty"`
	XksProxyVpcEndpointServiceName   string                            `json:"XksProxyVpcEndpointServiceName,omitempty"`
	XksProxyVpcEndpointServiceOwner  string                            `json:"XksProxyVpcEndpointServiceOwner,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,omitempty"`
	GranteeServicePrincipal  string            `json:"GranteeServicePrincipal,omitempty"`
	RetiringPrincipal        string            `json:"RetiringPrincipal,omitempty"`
	RetiringServicePrincipal string            `json:"RetiringServicePrincipal,omitempty"`
	Name                     string            `json:"Name,omitempty"`
	Operations               []string          `json:"Operations"`
	// GrantTokens authorizes the CreateGrant call itself via an existing,
	// not-yet-eventually-consistent grant. There is no IAM/authorization
	// layer anywhere in this mock, so this field is accepted for wire parity
	// and otherwise a no-op -- the same documented scope boundary as
	// CreateKeyInput/ReplicateKeyInput's BypassPolicyLockoutSafetyCheck.
	GrantTokens []string `json:"GrantTokens,omitempty"`
	DryRun      bool     `json:"DryRun,omitempty"`
}

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"`
	// CustomerMasterKeySpec is KeySpec's deprecated predecessor (same enum, same
	// meaning); aws_kms_key's customer_master_key_spec argument still sends this
	// wire field, not KeySpec.
	CustomerMasterKeySpec          string `json:"CustomerMasterKeySpec,omitempty"`
	Origin                         string `json:"Origin,omitempty"`
	Policy                         string `json:"Policy,omitempty"`
	Region                         string `json:"-"`
	CustomKeyStoreID               string `json:"CustomKeyStoreId,omitempty"`
	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"`
	// CloudHsmClusterId and TrustAnchorCertificate are echoed back by
	// DescribeCustomKeyStores for AWS_CLOUDHSM stores (types.go:37-40,225);
	// KeyStorePassword is write-only and never echoed.
	CloudHsmClusterID      string `json:"CloudHsmClusterId,omitempty"`
	TrustAnchorCertificate string `json:"TrustAnchorCertificate,omitempty"`
	// XksProxyConfiguration is set for EXTERNAL_KEY_STORE stores only.
	XksProxyConfiguration *XksProxyConfiguration `json:"XksProxyConfiguration,omitempty"`
}

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"`
	EncryptionAlgorithm string   `json:"EncryptionAlgorithm,omitempty"`
	DryRun              bool     `json:"DryRun,omitempty"`
}

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 DeleteImportedKeyMaterialOutput added in v1.3.1

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

DeleteImportedKeyMaterialOutput is the response payload for DeleteImportedKeyMaterial. See ImportKeyMaterialOutput for why KeyMaterialId is not modeled.

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"`
	DryRun      bool     `json:"DryRun,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"`
	// EncryptionAlgorithm is required only for asymmetric keys; symmetric keys
	// default to SYMMETRIC_DEFAULT when omitted.
	EncryptionAlgorithm string `json:"EncryptionAlgorithm,omitempty"`
	DryRun              bool   `json:"DryRun,omitempty"`
}

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"`
	DryRun            bool              `json:"DryRun,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"`
	DryRun      bool     `json:"DryRun,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"`
	DryRun      bool     `json:"DryRun,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"`
	DryRun            bool              `json:"DryRun,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"`
	DryRun      bool     `json:"DryRun,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 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. Mutually
	// exclusive with GranteeServicePrincipal; exactly one must be set.
	GranteePrincipal string `json:"GranteePrincipal,omitempty"`
	// GranteeServicePrincipal is the AWS service principal that receives the
	// grant. Mutually exclusive with GranteePrincipal; exactly one must be
	// set. No AWS-service-principal simulation exists in this mock (no
	// IAM/authorization layer at all -- see CreateGrantInput.GrantTokens), so
	// this is stored/round-tripped for wire parity, matching real AWS's
	// GrantListEntry shape, without any behavioral effect.
	GranteeServicePrincipal string `json:"GranteeServicePrincipal,omitempty"`
	// RetiringPrincipal is the principal that can retire the grant. Mutually
	// exclusive with RetiringServicePrincipal.
	RetiringPrincipal string `json:"RetiringPrincipal,omitempty"`
	// RetiringServicePrincipal is the AWS service principal that can retire
	// the grant. Mutually exclusive with RetiringPrincipal. Same no-IAM-layer
	// scope boundary as GranteeServicePrincipal.
	RetiringServicePrincipal string `json:"RetiringServicePrincipal,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"`
	// IssuingAccount is the AWS account ID under which the grant was issued.
	IssuingAccount string `json:"IssuingAccount,omitempty"`
}

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"`
	// SourceArn restricts grant use to requests made on behalf of the named
	// AWS resource (effectively the aws:SourceArn condition key). This mock
	// has no cross-service request-context plumbing to carry a "made on
	// behalf of" resource ARN through crypto calls, so the constraint is
	// stored and round-tripped (CreateGrant -> ListGrants/ListRetirableGrants)
	// for wire parity but is NOT enforced -- consistent with the scope
	// boundary already documented for grant-token authorization elsewhere in
	// this package (see isValidGrantOperation's doc and CreateGrantInput.
	// GrantTokens below).
	SourceArn string `json:"SourceArn,omitempty"`
}

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

type GrantListEntry added in v1.3.1

type GrantListEntry struct {
	Constraints              *GrantConstraints `json:"Constraints,omitempty"`
	GrantID                  string            `json:"GrantId"`
	KeyID                    string            `json:"KeyId"`
	GranteePrincipal         string            `json:"GranteePrincipal,omitempty"`
	GranteeServicePrincipal  string            `json:"GranteeServicePrincipal,omitempty"`
	RetiringPrincipal        string            `json:"RetiringPrincipal,omitempty"`
	RetiringServicePrincipal string            `json:"RetiringServicePrincipal,omitempty"`
	Name                     string            `json:"Name,omitempty"`
	Operations               []string          `json:"Operations"`
	CreationDate             float64           `json:"CreationDate"`
	IssuingAccount           string            `json:"IssuingAccount,omitempty"`
}

GrantListEntry is the wire shape of a single ListGrants/ListRetirableGrants result entry, matching real AWS's types.GrantListEntry field-for-field. It deliberately excludes GrantToken and TokenIssuedAt: a grant token is returned exactly once, in the CreateGrant response, and is never retrievable from a List call -- see kms.Grant for the internal storage representation that does carry both.

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:"EncryptedKeyMaterial"`
	ValidTo         float64 `json:"ValidTo,omitempty"`
}

ImportKeyMaterialInput is the request payload for ImportKeyMaterial.

type ImportKeyMaterialOutput added in v1.3.1

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

ImportKeyMaterialOutput is the response payload for ImportKeyMaterial. The real output also declares KeyMaterialId, part of the multi-key-material rotation feature (aws-sdk-go-v2 kms@v1.55.4 api_op_ImportKeyMaterial.go); this backend has no concept of multiple key-material generations per key, so only KeyId — always present on the real wire response — is echoed back.

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 pending deletion (KeyStatePendingDeletion or KeyStatePendingReplicaDeletion).

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 pending deletion or import.

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 pending deletion or import.

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.

Unlike almost every other KeyId-accepting KMS operation, the real aws-sdk-go-v2/service/kms@v1.55.4 GetKeyLastUsageInput doc comment is explicit that "Alias names are not supported" here -- a key ID or key ARN only. Rejected before taking any lock, matching validKeyPolicyDoc-style input validation elsewhere in this file.

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. ListRetirableGrantsInput's doc requires exactly one of RetiringPrincipal/ RetiringServicePrincipal (kms@v1.55.4 api_op_ListRetirableGrants.go: "You must specify either RetiringPrincipal or RetiringServicePrincipal, but not both.").

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
	// OnKeyPurged, if set, is invoked synchronously at the end of purgeKey after
	// the key's backend-owned state has been removed. It lets a caller (see
	// Handler.WithJanitor) cascade-clean side state that lives outside
	// InMemoryBackend entirely -- specifically Handler.tags, a side map keyed
	// by KeyID that the janitor has no access to itself. Without this hook, a
	// permanently-deleted key's tag collection (and the lockmetrics/Prometheus
	// registration it owns) would never be released, since KMS key IDs are
	// UUIDs that are never reused and Handler.tags has no other cleanup path.
	// Called with the backend write lock held: implementations must not call
	// back into any InMemoryBackend method.
	OnKeyPurged func(region, keyID string)

	// Interval is the time between janitor sweeps.
	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"`
	CustomKeyStoreID string `json:"CustomKeyStoreId,omitempty"`
	// KeyManager is CUSTOMER or AWS (gopherstack-6u8p4); a zero value means
	// CUSTOMER (see KeyManagerCustomer).
	KeyManager string `json:"KeyManager,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"`
}

KeyListEntry is a brief key reference used in ListKeys, matching real AWS's types.KeyListEntry exactly -- KeyId and KeyArn only. It has no Description member (kms@v1.59.0 deserializers.go's awsAwsjson11_deserializeDocumentKeyListEntry has no "Description" case).

type KeyMetadata

type KeyMetadata struct {
	MultiRegionConfiguration    *MultiRegionConfiguration `json:"MultiRegionConfiguration,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"`
	AWSAccountID                string                    `json:"AWSAccountId,omitempty"`
	CustomKeyStoreID            string                    `json:"CustomKeyStoreId,omitempty"`
	CustomerMasterKeySpec       string                    `json:"CustomerMasterKeySpec,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"`
	KeyMaterialID    string  `json:"KeyMaterialId,omitempty"`
	KeyMaterialState string  `json:"KeyMaterialState,omitempty"`
	RotationType     string  `json:"RotationType,omitempty"`
	RotationDate     float64 `json:"RotationDate,omitempty"`
}

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     []GrantListEntry `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"`
	// IncludeKeyMaterial is ROTATIONS_ONLY (default) or ALL_KEY_MATERIAL.
	IncludeKeyMaterial string `json:"IncludeKeyMaterial,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,omitempty"`
	RetiringServicePrincipal string `json:"RetiringServicePrincipal,omitempty"`
	Marker                   string `json:"Marker,omitempty"`
}

ListRetirableGrantsInput is the request payload for ListRetirableGrants. Real AWS requires exactly one of RetiringPrincipal/RetiringServicePrincipal (aws-sdk-go-v2/service/kms@v1.55.4 api_op_ListRetirableGrants.go).

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"`
	// BypassPolicyLockoutSafetyCheck is accepted as a no-op -- same precedent
	// as CreateKeyInput/ReplicateKeyInput's field of the same name (models.go),
	// no IAM layer exists in this mock to enforce the lockout check it waives.
	BypassPolicyLockoutSafetyCheck bool `json:"BypassPolicyLockoutSafetyCheck,omitempty"`
}

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"`
	SourceEncryptionAlgorithm      string            `json:"SourceEncryptionAlgorithm,omitempty"`
	DestinationEncryptionAlgorithm string            `json:"DestinationEncryptionAlgorithm,omitempty"`
	DryRun                         bool              `json:"DryRun,omitempty"`
}

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"`
	ReplicaPolicy      string      `json:"ReplicaPolicy,omitempty"`
	ReplicaTags        []Tag       `json:"ReplicaTags,omitempty"`
}

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"`
	DryRun     bool   `json:"DryRun,omitempty"`
}

RetireGrantInput is the request payload for RetireGrant.

type RevokeGrantInput

type RevokeGrantInput struct {
	KeyID   string `json:"KeyId"`
	GrantID string `json:"GrantId"`
	DryRun  bool   `json:"DryRun,omitempty"`
}

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 is absent for a multi-Region primary key with replicas:
	// real AWS doesn't know the deletion date until the last replica is
	// deleted, so the key is in KeyStatePendingReplicaDeletion instead.
	DeletionDate        float64 `json:"DeletionDate,omitempty"`
	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"`
	DryRun           bool     `json:"DryRun,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 {
	NewCustomKeyStoreName            *string                           `json:"NewCustomKeyStoreName,omitempty"`
	CloudHsmClusterID                *string                           `json:"CloudHsmClusterId,omitempty"`
	KeyStorePassword                 *string                           `json:"KeyStorePassword,omitempty"`
	XksProxyAuthenticationCredential *XksProxyAuthenticationCredential `json:"XksProxyAuthenticationCredential,omitempty"`
	XksProxyConnectivity             *string                           `json:"XksProxyConnectivity,omitempty"`
	XksProxyURIEndpoint              *string                           `json:"XksProxyUriEndpoint,omitempty"`
	XksProxyURIPath                  *string                           `json:"XksProxyUriPath,omitempty"`
	XksProxyVpcEndpointServiceName   *string                           `json:"XksProxyVpcEndpointServiceName,omitempty"`
	XksProxyVpcEndpointServiceOwner  *string                           `json:"XksProxyVpcEndpointServiceOwner,omitempty"`
	CustomKeyStoreID                 string                            `json:"CustomKeyStoreId"`
}

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"`
	DryRun           bool     `json:"DryRun,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"`
	DryRun      bool     `json:"DryRun,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.

type XksProxyAuthenticationCredential

type XksProxyAuthenticationCredential struct {
	AccessKeyID        string `json:"AccessKeyId"`
	RawSecretAccessKey string `json:"RawSecretAccessKey"`
}

XksProxyAuthenticationCredential is the write-only proxy credential; the secret is never stored.

type XksProxyConfiguration

type XksProxyConfiguration struct {
	AccessKeyID             string `json:"AccessKeyId,omitempty"`
	Connectivity            string `json:"Connectivity,omitempty"`
	URIEndpoint             string `json:"UriEndpoint,omitempty"`
	URIPath                 string `json:"UriPath,omitempty"`
	VpcEndpointServiceName  string `json:"VpcEndpointServiceName,omitempty"`
	VpcEndpointServiceOwner string `json:"VpcEndpointServiceOwner,omitempty"`
}

XksProxyConfiguration is the CustomKeyStoresListEntry.XksProxyConfiguration wire shape.

Jump to

Keyboard shortcuts

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