Skip to content

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

Closed

Description

@scttfrdmn

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:

  • KMSKey gains a field, written at CreateKey.
  • The mint must be deterministic, since a wall-clock or crypto/rand derivation 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's SourceKeyMaterialId must come from the source key's stored material ID and its DestinationKeyMaterialId from 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

  • KMSKey carries a deterministically minted 64-lowercase-hex key material ID, written at CreateKey.
  • CreateKey and DescribeKey report it as CurrentKeyMaterialId, and a test asserts the two agree for one key.
  • Decrypt reports KeyMaterialId and ReEncrypt reports SourceKeyMaterialId and DestinationKeyMaterialId, each traceable to the key it describes, with a test that the source and destination values differ and that each matches its own key's DescribeKey value.
  • GenerateDataKey and GenerateDataKeyWithoutPlaintext are checked against their own pages and included or excluded on that basis.
  • Encrypt is 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions