KMS
Parity grade: A · SDK aws-sdk-go-v2/service/kms@v1.61.4 · last audited 2026-10-11 (d1ed0e39b)
Category: Security · View PARITY.md on GitHub · All Services
In-memory KMS with symmetric, asymmetric and HMAC keys, aliases, grants, rotation, key import and custom key stores.
Quick start
bash
export AWS_ENDPOINT_URL=http://localhost:8000
KEY=$(aws kms create-key --description "My key" --query KeyMetadata.KeyId --output text)
aws kms create-alias --alias-name alias/my-key --target-key-id "$KEY"
aws kms encrypt --key-id alias/my-key --plaintext "SGVsbG8=" \
--query CiphertextBlob --output text
aws kms generate-data-key --key-id alias/my-key --key-spec AES_256
aws kms enable-key-rotation --key-id "$KEY"Supported operations
| Area | Operations |
|---|---|
| Keys | CreateKey, DescribeKey, ListKeys, EnableKey, DisableKey, ScheduleKeyDeletion, CancelKeyDeletion, UpdateKeyDescription, ReplicateKey, UpdatePrimaryRegion, GetKeyLastUsage |
| Crypto | Encrypt, Decrypt, ReEncrypt, GenerateDataKey, GenerateDataKeyWithoutPlaintext, GenerateDataKeyPair, GenerateDataKeyPairWithoutPlaintext, GenerateRandom, Sign, Verify, GetPublicKey, DeriveSharedSecret, GenerateMac, VerifyMac |
| Rotation | EnableKeyRotation, DisableKeyRotation, GetKeyRotationStatus, RotateKeyOnDemand, ListKeyRotations |
| Key material | GetParametersForImport, ImportKeyMaterial, DeleteImportedKeyMaterial |
| Aliases | CreateAlias, UpdateAlias, DeleteAlias, ListAliases |
| Grants | CreateGrant, ListGrants, ListRetirableGrants, RetireGrant, RevokeGrant |
| Key policy | PutKeyPolicy, GetKeyPolicy, ListKeyPolicies |
| Tags | TagResource, UntagResource, ListResourceTags |
| Custom key stores | CreateCustomKeyStore, UpdateCustomKeyStore, DeleteCustomKeyStore, DescribeCustomKeyStores, ConnectCustomKeyStore, DisconnectCustomKeyStore |
Behaviour
- AWS managed keys (
alias/aws/s3,alias/aws/dynamodb, ...) are created on first reference, as on AWS. ScheduleKeyDeletionenforces the 7-30 day window. A janitor purges keys past their deletion date and runs automatic rotations that are due.
Configuration
| Env | Default | Purpose |
|---|---|---|
KMS_JANITOR_INTERVAL | 1m | Janitor tick |
Differences from AWS
WARNING
IAM enforcement (--enforce-iam) evaluates identity and key policies only. Grants are not an authorization source there, so a grantee with no policy allow is denied.
- External key store proxies are never contacted. The
Xks*and VPC endpoint service errors are not produced. ListKeyRotationsomits multi-generation key-material fields.
Parity & Coverage
| Metric | Value |
|---|---|
| PARITY entries audited | 54 (54 ok) |
| Feature families | 4 (4 ok) |
| Known gaps | 1 |
| Structural gaps (can't be emulated) | 1 |
| Deferred items | 1 |
| Resource leaks | fixed |
Known Gaps
- Grants as an authorization source in IAM policy evaluation: the iam EnforcementMiddleware (services/iam/middleware.go:87 enforceIAMPolicy) evaluates identity and key policies only and does not consult KMS grants, so a grantee with no policy allow is denied there; IAM/resource-policy evaluation is out of scope (gopherstack-tnqy.6). Tokens presented to Encrypt/Decrypt/GenerateDataKey* are validated for existence, TTL, operations and constraints (grants.go:235).
Structural Gaps
These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.
- External key store proxies are never contacted: XksProxyUriUnreachable/IncorrectAuthenticationCredential/InvalidResponse, XksKeyNotFound/XksKeyInvalidConfiguration for the external key itself, and VPC endpoint service existence checks need a real proxy or VPC.
Deferred Items
- 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.
Audited Operations
54 audited operations
| Operation | Wire | Errors | State | Persist |
|---|---|---|---|---|
CreateKey | fixed | fixed | ok | ok |
DescribeKey | ok | fixed | ok | ok |
ListKeys | fixed | ok | ok | ok |
Encrypt | ok | fixed | ok | ok |
Decrypt | ok | fixed | ok | ok |
ReEncrypt | ok | ok | ok | ok |
GenerateDataKey | ok | ok | ok | ok |
GenerateDataKeyWithoutPlaintext | ok | ok | ok | ok |
GenerateDataKeyPair | fixed | ok | ok | ok |
GenerateDataKeyPairWithoutPlaintext | fixed | ok | ok | ok |
Sign | fixed | ok | ok | ok |
Verify | fixed | ok | ok | ok |
GetPublicKey | fixed | ok | ok | ok |
GenerateMac | fixed | ok | ok | ok |
VerifyMac | fixed | ok | ok | ok |
DeriveSharedSecret | fixed | ok | ok | ok |
GenerateRandom | ok | ok | ok | n/a |
CreateAlias | ok | ok | ok | ok |
UpdateAlias | ok | ok | ok | ok |
DeleteAlias | ok | ok | ok | ok |
ListAliases | ok | ok | ok | ok |
EnableKeyRotation | ok | ok | ok | ok |
DisableKeyRotation | ok | ok | ok | ok |
GetKeyRotationStatus | ok | fixed | ok | ok |
RotateKeyOnDemand | ok | ok | ok | ok |
ListKeyRotations | ok | ok | ok | ok |
DisableKey | ok | ok | ok | ok |
EnableKey | ok | ok | ok | ok |
ScheduleKeyDeletion | ok | ok | ok | ok |
CancelKeyDeletion | ok | ok | ok | ok |
CreateGrant | fixed | fixed | fixed | ok |
ListGrants | ok | ok | fixed | ok |
RevokeGrant | ok | ok | fixed | ok |
RetireGrant | ok | ok | fixed | ok |
ListRetirableGrants | fixed | ok | fixed | ok |
PutKeyPolicy | ok | ok | fixed | ok |
GetKeyPolicy | ok | ok | fixed | ok |
ListKeyPolicies | ok | ok | ok | n/a |
GetParametersForImport | ok | ok | ok | ok |
ImportKeyMaterial | ok | ok | ok | ok |
DeleteImportedKeyMaterial | ok | ok | ok | ok |
ReplicateKey | fixed | ok | ok | ok |
UpdateKeyDescription | ok | ok | ok | ok |
UpdatePrimaryRegion | ok | ok | ok | ok |
CreateCustomKeyStore | ok | ok | ok | ok |
DeleteCustomKeyStore | ok | fixed | fixed | ok |
DescribeCustomKeyStores | ok | ok | ok | ok |
ConnectCustomKeyStore | ok | ok | ok | ok |
DisconnectCustomKeyStore | ok | ok | ok | ok |
UpdateCustomKeyStore | ok | ok | ok | ok |
GetKeyLastUsage | fixed | ok | ok | n/a |
TagResource | ok | ok | ok | fixed |
UntagResource | ok | ok | ok | fixed |
ListResourceTags | ok | ok | ok | fixed |
Audited Feature Families
| Feature Family | Status |
|---|---|
crypto_core | ok |
error_classification | fixed |
key_state_machine | ok |
multi_region | ok |
