Repository navigation
Description
Substrate models no key material identity, so five response members across four operations are absent. Split out of #969, which fixed that operation's request enforcement and its two algorithm members and recorded this as the largest of its three questions.
What AWS publishes
A KMS key's key material has an identifier of its own, distinct from the key ID, and five members report it. All five are the same shape — Length Constraints: Fixed length of 64, Pattern ^[a-f0-9]+$ — and all five are conditional on the key being a symmetric encryption key:
| Operation | Member | Gloss |
|---|---|---|
DescribeKey, CreateKey, ReplicateKey |
KeyMetadata.CurrentKeyMaterialId |
The identifier of the current key material |
Decrypt |
KeyMaterialId |
"The identifier of the key material used to decrypt the ciphertext. This field is present only when the operation uses a symmetric encryption KMS key." |
ReEncrypt |
SourceKeyMaterialId |
"The identifier of the key material used to originally encrypt the data. This field is present only when the original encryption used a symmetric encryption KMS key." |
ReEncrypt |
DestinationKeyMaterialId |
"The identifier of the key material used to reencrypt the data." |
GenerateDataKey, GenerateDataKeyWithoutPlaintext |
KeyMaterialId |
Verify against each page before implementing — the response syntax carries it, and the exact gloss should be quoted rather than assumed |
Note API_Encrypt publishes no such member: its response is exactly CiphertextBlob, EncryptionAlgorithm and KeyId. So the set is not "every cryptographic operation" and must be taken per page.
Both ReEncrypt and Decrypt sample responses render a real value, e.g. "KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6".
Why it is not just five more rendered strings
The value has to be minted once per key and reported consistently, or two operations disagree about one key — the invariant #848 exists to protect. Decrypt's KeyMaterialId and DescribeKey's CurrentKeyMaterialId describe the same material, so a caller can read one and compare it with the other. That means:
KMSKeygains a field, written atCreateKey.- The mint must be deterministic, since a wall-clock or
crypto/randderivation is the Identifiers minted from crypto/rand make a replay diverge from its recording, and three replay checks are weakened for it #856 class.cfnDeterministicUUID(emulator/cloudformation_plugin.go) is the SHA-256-over-joined-parts precedent, and 64 lowercase hex characters is exactly a SHA-256 digest, so the shape needs no truncation or re-encoding. ReEncrypt'sSourceKeyMaterialIdmust come from the source key's stored material ID and itsDestinationKeyMaterialIdfrom the destination's, which is why this needs the field rather than a value computed in the handler.
Rotation is the reason the member is named Current. API_KeyMetadata calls it CurrentKeyMaterialId, and ListKeyRotations and RotateKeyOnDemand — neither implemented — report a key's material history. Whether substrate mints a new material ID on rotation is the one design question here, and it interacts with #964's stored rotation period. The conservative answer is that automatic rotation in substrate produces no new material (no simulated clock advance rotates a key today), so the material ID is stable for a key's life and the member's Current prefix is honest without a history.
Acceptance criteria
-
KMSKeycarries a deterministically minted 64-lowercase-hex key material ID, written atCreateKey. -
CreateKeyandDescribeKeyreport it asCurrentKeyMaterialId, and a test asserts the two agree for one key. -
DecryptreportsKeyMaterialIdandReEncryptreportsSourceKeyMaterialIdandDestinationKeyMaterialId, each traceable to the key it describes, with a test that the source and destination values differ and that each matches its own key'sDescribeKeyvalue. -
GenerateDataKeyandGenerateDataKeyWithoutPlaintextare checked against their own pages and included or excluded on that basis. -
Encryptis confirmed to publish no such member and is left alone, recorded so a later sweep does not add one. - Whether rotation mints new material is decided and recorded, with
ListKeyRotations's absence noted. - Tests go over the wire (cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765).
Activity
feat(kms): a key material identity, and the six members reporting it (#…
fix(kms): data-key generation refuses a key that is not a symmetric e…