Documentation
¶
Overview ¶
Package kms provides a mock AWS Key Management Service (KMS) implementation.
Index ¶
- Constants
- Variables
- func UnixTimeFloat(t time.Time) float64
- type Alias
- type CancelKeyDeletionInput
- type CancelKeyDeletionOutput
- type ConfigProvider
- type ConnectCustomKeyStoreInput
- type CreateAliasInput
- type CreateCustomKeyStoreInput
- type CreateCustomKeyStoreOutput
- type CreateGrantInput
- type CreateGrantOutput
- type CreateKeyInput
- type CreateKeyOutput
- type CustomKeyStore
- type DecryptInput
- type DecryptOutput
- type DeleteAliasInput
- type DeleteCustomKeyStoreInput
- type DeleteImportedKeyMaterialInput
- type DeriveSharedSecretInput
- type DeriveSharedSecretOutput
- type DescribeCustomKeyStoresInput
- type DescribeCustomKeyStoresOutput
- type DescribeKeyInput
- type DescribeKeyOutput
- type DisableKeyInput
- type DisableKeyRotationInput
- type DisconnectCustomKeyStoreInput
- type EnableKeyInput
- type EnableKeyRotationInput
- type EncryptInput
- type EncryptOutput
- type ErrorResponse
- type GenerateDataKeyInput
- type GenerateDataKeyOutput
- type GenerateDataKeyPairInput
- type GenerateDataKeyPairOutput
- type GenerateDataKeyPairWithoutPlaintextInput
- type GenerateDataKeyPairWithoutPlaintextOutput
- type GenerateDataKeyWithoutPlaintextInput
- type GenerateDataKeyWithoutPlaintextOutput
- type GenerateMacInput
- type GenerateMacOutput
- type GenerateRandomInput
- type GenerateRandomOutput
- type GetKeyLastUsageInput
- type GetKeyLastUsageOutput
- type GetKeyPolicyInput
- type GetKeyPolicyOutput
- type GetKeyRotationStatusInput
- type GetKeyRotationStatusOutput
- type GetParametersForImportInput
- type GetParametersForImportOutput
- type GetPublicKeyInput
- type GetPublicKeyOutput
- type Grant
- type GrantConstraints
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- func (h *Handler) TagKeyByARN(ctx context.Context, keyARN string, newTags map[string]string) error
- func (h *Handler) TaggedKeys(ctx context.Context) []TaggedKeyInfo
- func (h *Handler) UntagKeyByARN(ctx context.Context, keyARN string, tagKeys []string) error
- func (h *Handler) WithJanitor(interval time.Duration, taskTimeout ...time.Duration) *Handler
- type ImportKeyMaterialInput
- type InMemoryBackend
- func (b *InMemoryBackend) AddCustomKeyStoreInternal(ks *CustomKeyStore)
- func (b *InMemoryBackend) AddKeyInternal(key *Key, km *keyMaterial)
- func (b *InMemoryBackend) CancelKeyDeletion(ctx context.Context, input *CancelKeyDeletionInput) (*CancelKeyDeletionOutput, error)
- func (b *InMemoryBackend) ConnectCustomKeyStore(ctx context.Context, input *ConnectCustomKeyStoreInput) error
- func (b *InMemoryBackend) CreateAlias(ctx context.Context, input *CreateAliasInput) error
- func (b *InMemoryBackend) CreateCustomKeyStore(ctx context.Context, input *CreateCustomKeyStoreInput) (*CreateCustomKeyStoreOutput, error)
- func (b *InMemoryBackend) CreateGrant(ctx context.Context, input *CreateGrantInput) (*CreateGrantOutput, error)
- func (b *InMemoryBackend) CreateKey(ctx context.Context, input *CreateKeyInput) (*CreateKeyOutput, error)
- func (b *InMemoryBackend) Decrypt(ctx context.Context, input *DecryptInput) (*DecryptOutput, error)
- func (b *InMemoryBackend) DeleteAlias(ctx context.Context, input *DeleteAliasInput) error
- func (b *InMemoryBackend) DeleteCustomKeyStore(ctx context.Context, input *DeleteCustomKeyStoreInput) error
- func (b *InMemoryBackend) DeleteImportedKeyMaterial(ctx context.Context, input *DeleteImportedKeyMaterialInput) error
- func (b *InMemoryBackend) DeriveSharedSecret(ctx context.Context, input *DeriveSharedSecretInput) (*DeriveSharedSecretOutput, error)
- func (b *InMemoryBackend) DescribeCustomKeyStores(ctx context.Context, input *DescribeCustomKeyStoresInput) (*DescribeCustomKeyStoresOutput, error)
- func (b *InMemoryBackend) DescribeKey(ctx context.Context, input *DescribeKeyInput) (*DescribeKeyOutput, error)
- func (b *InMemoryBackend) DisableKey(ctx context.Context, input *DisableKeyInput) error
- func (b *InMemoryBackend) DisableKeyRotation(ctx context.Context, input *DisableKeyRotationInput) error
- func (b *InMemoryBackend) DisconnectCustomKeyStore(ctx context.Context, input *DisconnectCustomKeyStoreInput) error
- func (b *InMemoryBackend) EnableKey(ctx context.Context, input *EnableKeyInput) error
- func (b *InMemoryBackend) EnableKeyRotation(ctx context.Context, input *EnableKeyRotationInput) error
- func (b *InMemoryBackend) Encrypt(ctx context.Context, input *EncryptInput) (*EncryptOutput, error)
- func (b *InMemoryBackend) GenerateDataKey(ctx context.Context, input *GenerateDataKeyInput) (*GenerateDataKeyOutput, error)
- func (b *InMemoryBackend) GenerateDataKeyPair(ctx context.Context, input *GenerateDataKeyPairInput) (*GenerateDataKeyPairOutput, error)
- func (b *InMemoryBackend) GenerateDataKeyPairWithoutPlaintext(ctx context.Context, input *GenerateDataKeyPairWithoutPlaintextInput) (*GenerateDataKeyPairWithoutPlaintextOutput, error)
- func (b *InMemoryBackend) GenerateDataKeyWithoutPlaintext(ctx context.Context, input *GenerateDataKeyWithoutPlaintextInput) (*GenerateDataKeyWithoutPlaintextOutput, error)
- func (b *InMemoryBackend) GenerateMac(ctx context.Context, input *GenerateMacInput) (*GenerateMacOutput, error)
- func (b *InMemoryBackend) GenerateRandom(_ context.Context, input *GenerateRandomInput) (*GenerateRandomOutput, error)
- func (b *InMemoryBackend) GetKeyLastUsage(ctx context.Context, input *GetKeyLastUsageInput) (*GetKeyLastUsageOutput, error)
- func (b *InMemoryBackend) GetKeyPolicy(ctx context.Context, input *GetKeyPolicyInput) (*GetKeyPolicyOutput, error)
- func (b *InMemoryBackend) GetKeyRotationStatus(ctx context.Context, input *GetKeyRotationStatusInput) (*GetKeyRotationStatusOutput, error)
- func (b *InMemoryBackend) GetParametersForImport(ctx context.Context, input *GetParametersForImportInput) (*GetParametersForImportOutput, error)
- func (b *InMemoryBackend) GetPublicKey(ctx context.Context, input *GetPublicKeyInput) (*GetPublicKeyOutput, error)
- func (b *InMemoryBackend) ImportKeyMaterial(ctx context.Context, input *ImportKeyMaterialInput) error
- func (b *InMemoryBackend) ListAliases(ctx context.Context, input *ListAliasesInput) (*ListAliasesOutput, error)
- func (b *InMemoryBackend) ListGrants(ctx context.Context, input *ListGrantsInput) (*ListGrantsOutput, error)
- func (b *InMemoryBackend) ListKeyPolicies(ctx context.Context, input *ListKeyPoliciesInput) (*ListKeyPoliciesOutput, error)
- func (b *InMemoryBackend) ListKeyRotations(ctx context.Context, input *ListKeyRotationsInput) (*ListKeyRotationsOutput, error)
- func (b *InMemoryBackend) ListKeys(ctx context.Context, input *ListKeysInput) (*ListKeysOutput, error)
- func (b *InMemoryBackend) ListRetirableGrants(ctx context.Context, input *ListRetirableGrantsInput) (*ListGrantsOutput, error)
- func (b *InMemoryBackend) PutKeyPolicy(ctx context.Context, input *PutKeyPolicyInput) error
- func (b *InMemoryBackend) ReEncrypt(ctx context.Context, input *ReEncryptInput) (*ReEncryptOutput, error)
- func (b *InMemoryBackend) ReplicateKey(ctx context.Context, input *ReplicateKeyInput) (*ReplicateKeyOutput, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RetireGrant(ctx context.Context, input *RetireGrantInput) error
- func (b *InMemoryBackend) RevokeGrant(ctx context.Context, input *RevokeGrantInput) error
- func (b *InMemoryBackend) RotateKeyOnDemand(ctx context.Context, input *RotateKeyOnDemandInput) (*RotateKeyOnDemandOutput, error)
- func (b *InMemoryBackend) ScheduleKeyDeletion(ctx context.Context, input *ScheduleKeyDeletionInput) (*ScheduleKeyDeletionOutput, error)
- func (b *InMemoryBackend) Sign(ctx context.Context, input *SignInput) (*SignOutput, error)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) UpdateAlias(ctx context.Context, input *UpdateAliasInput) error
- func (b *InMemoryBackend) UpdateCustomKeyStore(ctx context.Context, input *UpdateCustomKeyStoreInput) error
- func (b *InMemoryBackend) UpdateKeyDescription(ctx context.Context, input *UpdateKeyDescriptionInput) error
- func (b *InMemoryBackend) UpdatePrimaryRegion(ctx context.Context, input *UpdatePrimaryRegionInput) error
- func (b *InMemoryBackend) Verify(ctx context.Context, input *VerifyInput) (*VerifyOutput, error)
- func (b *InMemoryBackend) VerifyMac(ctx context.Context, input *VerifyMacInput) (*VerifyMacOutput, error)
- type Janitor
- type Key
- type KeyLastUsageData
- type KeyListEntry
- type KeyMetadata
- type KeyRotationEntry
- type ListAliasesInput
- type ListAliasesOutput
- type ListGrantsInput
- type ListGrantsOutput
- type ListKeyPoliciesInput
- type ListKeyPoliciesOutput
- type ListKeyRotationsInput
- type ListKeyRotationsOutput
- type ListKeysInput
- type ListKeysOutput
- type ListRetirableGrantsInput
- type MultiRegionConfiguration
- type MultiRegionKeyRef
- type Provider
- type PutKeyPolicyInput
- type ReEncryptInput
- type ReEncryptOutput
- type ReplicateKeyInput
- type ReplicateKeyOutput
- type RetireGrantInput
- type RevokeGrantInput
- type RotateKeyOnDemandInput
- type RotateKeyOnDemandOutput
- type RotationRecord
- type ScheduleKeyDeletionInput
- type ScheduleKeyDeletionOutput
- type Settings
- type SignInput
- type SignOutput
- type StorageBackend
- type Tag
- type TaggedKeyInfo
- type UpdateAliasInput
- type UpdateCustomKeyStoreInput
- type UpdateKeyDescriptionInput
- type UpdatePrimaryRegionInput
- type VerifyInput
- type VerifyMacInput
- type VerifyMacOutput
- type VerifyOutput
Constants ¶
const ( // MockAccountID is the mock AWS account ID. MockAccountID = config.DefaultAccountID // MockRegion is the mock AWS region. MockRegion = config.DefaultRegion )
const ConnectionStateConnected = "CONNECTED"
ConnectionStateConnected indicates a custom key store is connected.
const ConnectionStateDisconnected = "DISCONNECTED"
ConnectionStateDisconnected indicates a custom key store is disconnected.
const KeyOriginAWSKMS = "AWS_KMS"
KeyOriginAWSKMS is the origin for keys whose material is generated by AWS KMS.
const KeyOriginExternal = "EXTERNAL"
KeyOriginExternal is the origin for keys whose material is imported by the customer.
const KeyStateDisabled = "Disabled"
KeyStateDisabled is the string constant for a disabled key.
const KeyStateEnabled = "Enabled"
KeyStateEnabled is the string constant for an enabled key.
const KeyStatePendingDeletion = "PendingDeletion"
KeyStatePendingDeletion is the string constant for a key pending deletion.
const KeyStatePendingImport = "PendingImport"
KeyStatePendingImport is the string constant for a key awaiting imported key material.
const KeyUsageEncryptDecrypt = "ENCRYPT_DECRYPT"
KeyUsageEncryptDecrypt is the string constant for the default key usage.
const KeyUsageGenerateMac = "GENERATE_VERIFY_MAC"
KeyUsageGenerateMac is the key usage for HMAC keys.
const KeyUsageKeyAgreement = "KEY_AGREEMENT"
KeyUsageKeyAgreement is the key usage for ECDH key agreement keys.
const KeyUsageSignVerify = "SIGN_VERIFY"
KeyUsageSignVerify is the string constant for sign/verify-only keys.
Variables ¶
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") // 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") )
var ErrNilAppContext = errors.New("nil AppContext passed to KMS Provider.Init")
ErrNilAppContext is returned by Init when a nil AppContext is passed.
var ErrUnknownOperation = errors.New("UnknownOperationException")
ErrUnknownOperation is returned when the requested KMS operation is not supported.
Functions ¶
func UnixTimeFloat ¶
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,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"`
}
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 string `json:"KeyId"`
KeyAgreementAlgorithm string `json:"KeyAgreementAlgorithm"`
PublicKey []byte `json:"PublicKey"`
GrantTokens []string `json:"GrantTokens,omitempty"`
}
DeriveSharedSecretInput is the request payload for DeriveSharedSecret.
type DeriveSharedSecretOutput ¶
type DeriveSharedSecretOutput struct {
}
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 ¶
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 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 ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this KMS instance handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the KMS operation name from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource returns the key ID from the request body when present.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority returns the routing priority for the KMS handler.
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 ¶
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 ¶
RouteMatcher returns a matcher that identifies KMS requests by the X-Amz-Target header.
func (*Handler) Snapshot ¶
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 ¶
StartWorker starts the background janitor if one is configured.
func (*Handler) TagKeyByARN ¶
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 ¶
UntagKeyByARN removes the specified tag keys from the KMS key identified by its ARN.
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 ¶
func (b *InMemoryBackend) GenerateDataKeyPairWithoutPlaintext( ctx context.Context, input *GenerateDataKeyPairWithoutPlaintextInput, ) (*GenerateDataKeyPairWithoutPlaintextOutput, error)
GenerateDataKeyPairWithoutPlaintext generates an asymmetric key pair but omits the plaintext private key from the response.
func (*InMemoryBackend) GenerateDataKeyWithoutPlaintext ¶
func (b *InMemoryBackend) GenerateDataKeyWithoutPlaintext( ctx context.Context, input *GenerateDataKeyWithoutPlaintextInput, ) (*GenerateDataKeyWithoutPlaintextOutput, error)
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.54.0 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.
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.
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the KMS service backend and handler.
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 ¶
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 ¶
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
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 ¶
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.
Source Files
¶
- aliases.go
- crypto.go
- custom_key_stores.go
- data_keys.go
- encryption.go
- errors.go
- grants.go
- handler.go
- handler_alias_rotation.go
- handler_crypto.go
- handler_custom_key_stores.go
- handler_generate_and_mac.go
- handler_grants_policies.go
- handler_keys.go
- handler_replication_maintenance.go
- handler_tags.go
- hmac.go
- import.go
- janitor.go
- key_agreement.go
- key_policies.go
- keys.go
- models.go
- persistence.go
- provider.go
- random.go
- replication.go
- rotation.go
- settings.go
- signing.go
- store.go