Skip to content

feat(kms): a key material identity, and the six members reporting it (#978) - #989

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/kms-key-material-id
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/kms-key-material-id

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #978.

API_KeyMetadata publishes CurrentKeyMaterialId — "identifies the current key material… AWS KMS uses the current key material for both encryption and decryption, and the non-current key material for decryption operations only" — and five operation responses carry the same identity under four other names. Substrate modelled no key material at all, so all six members were absent.

The member set is six, not five, and the conditions differ per page

The issue's table lists five members and says all five are "conditional on the key being a symmetric encryption key". Both claims are corrected on the record here; the issue itself flagged the two GenerateDataKey* rows "Verify against each page before implementing", and that is what the verification found.

Where Member The page's condition, verbatim
CreateKey, DescribeKey CurrentKeyMaterialId "present for symmetric encryption keys with AWS_KMS or EXTERNAL origin"
Decrypt KeyMaterialId "present only when the operation uses a symmetric encryption KMS key"
ReEncrypt SourceKeyMaterialId "present only when the original encryption used a symmetric encryption KMS key"
ReEncrypt DestinationKeyMaterialId "present only when data is reencrypted using a symmetric encryption KMS key"
GenerateDataKey KeyMaterialId No key-type condition — only "omitted if the request includes the Recipient parameter"
GenerateDataKeyWithoutPlaintext KeyMaterialId No condition at all

Encrypt publishes none. Its Response Syntax is exactly CiphertextBlob, EncryptionAlgorithm and KeyId, which the issue asked be confirmed and recorded — a test now asserts those three exactly, so a later sweep over "the operations that report key material" cannot add a fifth site AWS does not have. The asymmetry is AWS's and is not obviously deliberate: Encrypt names the material it used no more than Decrypt names the material that produced the ciphertext it was handed.

Stored on the key, not computed per site

The material ID is minted once at CreateKey, stored on KMSKey, and read from the key at all six sites. That is not an implementation preference — it is what makes the value worth reporting. AWS's member is named Current, and "current" is only meaningful against material that can change; more practically, a caller compares what Decrypt reports against what DescribeKey reports and learns that the material which decrypted its data is the material the key holds. A value each site computed for itself would satisfy that comparison by construction and prove nothing about the key.

ReEncrypt is where it shows. Its two members are the only two material identities in one response — AWS's own sample renders two different values — and each follows its own key, so a re-encryption out of an asymmetric key into a symmetric one reports the destination member alone. Reporting both from one key, or either from the wrong one, still produces two well-formed 64-hex values, which is why the test compares each against its own key's DescribeKey rather than against a literal.

The derivation

SHA-256 over the key's own ARN with a domain-separation prefix, not crypto/rand. All six members are constrained to a fixed length of 64 with pattern ^[a-f0-9]+$, and a SHA-256 digest hex-encodes to exactly 64 lowercase hex characters — so unlike cfnDeterministicUUID, which reaches for the same hash and then reshapes it, nothing is truncated or re-encoded. The ARN already carries the account, the Region and the key ID, so two keys never collide; the derivation adds no nondeterminism of its own and becomes fully deterministic the day #856 reaches the key ID itself.

The domain-separation prefix is not decoration: nothing else in the tree hashes a KMS key ARN today, a bare digest of one is the obvious thing for a later minter to reach for, and two identities that must differ colliding on one hash is not a failure any test would think to look for.

Two readings recorded as substrate's

Rotation mints no new material. Nothing rotates — ListKeyRotations and RotateKeyOnDemand are unimplemented, and KMSKey.RotationEnabledDate already records that a rotation schedule here is a value reported to a caller rather than an event that fires. A second material identity nothing can list or ask for would be a value no call could reach, so Current is true in the trivial sense: it is the only material the key has ever had. The comment states the condition for changing this — minting on rotation means implementing ListKeyRotations alongside it, so the non-current identities Decrypt is documented to still accept are observable.

Both GenerateDataKey* operations are held to the same symmetric-encryption-key condition as the other four, although their own pages state none. Both operations require a symmetric encryption key at AWS, which is why neither page needs a condition — but substrate's check tests the key usage rather than the key spec, so an RSA_2048 key with KeyUsage ENCRYPT_DECRYPT reaches both. That is filed as #988. Reporting unconditionally would put a material ID on a response AWS cannot produce, inventing a value for a state that exists only because of that defect; omitting says nothing about a request that should not have succeeded, which is #827's honest-empty reading. When #988 lands the condition stops carrying those two sites and becomes a guard at them, and the code says so.

Note that "symmetric encryption key" is narrower than "symmetric key": the four HMAC_* specs are symmetric, hold key material and encrypt nothing, so they report none. All seventeen key specs are walked by a test for exactly that reason — an implementation reading the condition as "not asymmetric" passes every other row and fails those four.

CurrentKeyMaterialId leaves kmsUnreachableMetadataMembers, which drops from nine members to eight, and the docs/services.md table of absent members is corrected with it (its count was already loose, and each remaining row now names the members it covers).

Verification

The nine-command gate passes. Coverage holds the baseline at 84.4% emulator / 83.9% total. Every assertion goes over the wire (#765).

…978)

API_KeyMetadata publishes CurrentKeyMaterialId and five operation responses
carry the same identity under four other names — Decrypt's KeyMaterialId,
ReEncrypt's SourceKeyMaterialId and DestinationKeyMaterialId, and a
KeyMaterialId on each of GenerateDataKey and GenerateDataKeyWithoutPlaintext.
Substrate modeled no key material at all, so all six were absent.

The value is stored on the key and read from it at every site, which is what
makes it worth reporting: a caller compares what Decrypt reports against what
DescribeKey reports and learns that the material which decrypted its data is
the material the key holds. A value each site computed for itself would satisfy
that comparison by construction. ReEncrypt is where it shows — its two members
are the only two material identities in one response, and each follows its own
key, so a re-encryption out of an asymmetric key into a symmetric one reports
the destination member alone.

Derived rather than drawn from crypto/rand: SHA-256 over the key's own ARN with
a domain-separation prefix. All six members are fixed at length 64 with pattern
^[a-f0-9]+$, and a SHA-256 digest hex-encodes to exactly 64 lowercase hex
characters, so nothing is truncated or reshaped.

Encrypt publishes no such member, and a test asserts its three exactly, so a
later sweep over the operations that report key material cannot add a site AWS
does not have.

Two readings are substrate's. Rotation mints no new material: nothing rotates,
ListKeyRotations and RotateKeyOnDemand are unimplemented, and a second identity
nothing can list or ask for would be a value no call could reach. And both
GenerateDataKey* operations are held to the same symmetric-encryption-key
condition as the other four although their pages state none, because both
require a symmetric encryption key at AWS while substrate's check tests the
usage rather than the spec — filed as #988.
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit bf6223f into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/kms-key-material-id branch September 17, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kms: no key material identity, so CurrentKeyMaterialId, KeyMaterialId and ReEncrypt's two material IDs are all absent

1 participant