Skip to content

feat(kms): one KeyMetadata builder, and the sixteen members it stopped withholding (#974) - #982

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

scttfrdmn merged 1 commit into
mainfrom
feat/kms-key-metadata-members

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #974.

API_KeyMetadata publishes 26 members. DescribeKey answered 10 of them and CreateKey answered 9 from a second map of its own. Five of the absent ones are sent by AWS on every call for a plain customer symmetric key — AWSAccountId, KeyManager, Origin, EncryptionAlgorithms and the deprecated CustomerMasterKeySpec — so a consumer reading any of them got a missing field from substrate where AWS always has a value. That is #765's failure mode aimed at a response shape.

Nothing added here is a simulation. Three of the five are constants for every key substrate can create and the other two are functions of KeySpec and KeyUsage, both of which the key already carried. Every member added is a value substrate already knew and withheld — which is what makes this and #971 the same finding read from two sides: that issue removed the one member substrate emitted and AWS does not publish, this one adds the members AWS publishes and substrate did not emit.

One builder, because AWS has one shape

The type's page says it "is used as a response element for the CreateKey, DescribeKey, and ReplicateKey operations", and substrate's two hand-built maps had already drifted: #963 added DeletionDate to DescribeKey's and left CreateKey's alone, so two operations disagreed about one documented type. That is the defect class #952 catalogues, and neither operation's own test could see it, because each asserted its own response against the page rather than against the other. A test now compares the two responses member by member on raw bytes.

ReplicateKey is the third caller AWS names and substrate does not implement it. When it arrives it must build from here rather than grow a third map, and the file's preamble says so.

Three constants, each recording a limit

Member Value Why a constant
AWSAccountId the key's own account Not the caller's — a difference only a cross-account DescribeKey separates, so that is the call the test makes (#737's distinction aimed at a response member)
KeyManager CUSTOMER Substrate mints no AWS managed key. This is also why #972's "you cannot enable or disable automatic rotation of AWS managed KMS keys" is unreachable rather than unenforced
Origin AWS_KMS Neither ImportKeyMaterial nor any custom key store exists, which is why ExpirationModel, ValidTo and XksKeyConfiguration stay absent for the same single reason rather than three separate ones

One algorithm list, selected by the key usage

Each of the four algorithm members names a KeyUsage as its presence condition, and a key has exactly one usage — so the switch is what makes them mutually exclusive rather than four independent branches. Contents come from the developer guide's key spec reference, the same table #969 read for encryption: the six RSA signing algorithms shared by all three RSA specs, one per NIST curve, ECC_NIST_EDWARDS25519's two, ML_DSA_SHAKE_256 for all three ML-DSA specs (stated in prose, not the table), the HMAC bijection AWS explains with "the length of the key determines the MAC algorithm", and ECDH for the NIST curves and SM2.

Two decisions worth naming:

CustomerMasterKeySpec, answered and then omitted outside its own enum

AWS still sends it — "the KeySpec and CustomerMasterKeySpec fields have the same value… to avoid breaking changes, AWS KMS supports both fields" — so dropping it as obsolete would omit a member AWS sends, which is the defect this issue is about. But its enum is narrower than KeySpec's: 13 valid values against 17. The four specs added since the deprecation — ML_DSA_44, ML_DSA_65, ML_DSA_87, ECC_NIST_EDWARDS25519 — appear only under KeySpec, so a key with one of those has no admissible value for the older member. Substrate omits it there. AWS documents no answer for a case its own deprecation predates, so that is a reading; the alternative puts a value outside the member's published set on the wire.

The ten that stay absent, asserted absent

Six fall out of the two constants above. The rest need a custom key store (CloudHsmClusterId, CustomKeyStoreId), a replica (MultiRegionConfiguration — substrate stores the flag but models no replica, so it would report a primary with an empty ReplicaKeys list), the PendingReplicaDeletion state (PendingDeletionWindowInDays, whose range is 1–365 rather than ScheduleKeyDeletion's 7–30, so reporting the waiting period under it would be wrong twice over), or a key material identity (CurrentKeyMaterialId, #978).

RotationEnabled is asserted absent beside them, and that is deliberate: adding sixteen members from a page is exactly the moment someone working from the struct rather than the page would put #971's member back.

Every non-symmetric key in the new tests is created through the gap #977 records, which is why #977 must re-verify this file when it closes it — the same note kms_rotation_key_type_test.go and kms_encryption_algorithm_test.go already carry.

Provenance

  • Published by AWS: the 26 members and their presence conditions; the header sentence naming the three operations that share the shape; KeyManager's and Origin's valid values and glosses; the deprecation sentence and CustomerMasterKeySpec's 13 valid values against KeySpec's 17; every per-spec signing, MAC and key-agreement algorithm list, including the ML-DSA prose and the two ECC specs excluded from key agreement; DeletionDate's and PendingDeletionWindowInDays' conditions and the latter's 1–365 range.
  • Substrate's reading: KeyAgreementAlgorithms' presence condition (AWS publishes none); omitting CustomerMasterKeySpec for the four specs outside its enum (AWS documents no answer); omitting an empty algorithm list rather than sending [] (cfn: Ref returns the physical ID for every type, but AWS returns an ARN for an ELBv2 load balancer and target group #827); KeyManager and Origin as constants, each stated with the operation that would have to exist to make it a stored field.

Verification

Nine-command gate green. Coverage 84.4% emulator / 83.9% total, holding the level #972/#973 set. Seven mutants introduced and all seven caught: emitting CustomerMasterKeySpec unconditionally, emitting an empty algorithm list, reporting the key as AWS managed, reporting ECDH on a signing key, dropping one member from CreateKey's copy of the shape, collapsing Edwards' two signing algorithms to one, and reporting DeletionDate whatever the key state.

…d withholding (#974)

DescribeKey answered 10 of API_KeyMetadata's 26 members and CreateKey answered 9 from
a second map of its own. Five of the absent ones are sent by AWS on every call for a
plain customer symmetric key — AWSAccountId, KeyManager, Origin, EncryptionAlgorithms
and the deprecated CustomerMasterKeySpec — so a consumer reading any of them got a
missing field where AWS always has a value. Nothing added here is a simulation: three
of the five are constants for every key substrate can create and the other two are
functions of KeySpec and KeyUsage, both of which the key already carried, which makes
this the same finding as #971 read from the other side.

The builder is shared because AWS shares the shape, its page naming CreateKey,
DescribeKey and ReplicateKey as the three operations that answer it — and substrate's
two maps had already drifted, #963 having added DeletionDate to one and not the other.
A test compares the two responses member by member on raw bytes. ReplicateKey is
unimplemented; when it arrives it builds from the same place.

KeyManager is a constant because substrate mints no AWS managed key, which is also why
#972's AWS-managed restriction is unreachable rather than unenforced; Origin is one
because neither ImportKeyMaterial nor any custom key store exists, which is why
ExpirationModel, ValidTo and XksKeyConfiguration stay absent. The four algorithm
members are mutually exclusive on KeyUsage, and KeyAgreementAlgorithms' condition is
substrate's reading — the other three publish one and it publishes none, so reporting
ECDH on a NIST-curve signing key would offer DeriveSharedSecret on a key AWS reserves
for Sign. An empty list is omitted rather than sent as [], because #977 lets a key
carry a usage and a spec AWS would never pair. CustomerMasterKeySpec is answered but
omitted for the four specs outside its own narrower thirteen-value enum, AWS
documenting no answer for a case its deprecation predates. Ten members stay absent and
all ten are asserted absent, RotationEnabled included.
@scttfrdmn scttfrdmn added this to the v0.118.0 milestone Sep 17, 2026
@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 fac30f4 into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/kms-key-metadata-members branch September 17, 2026 04:46
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: DescribeKey answers 10 of KeyMetadata's 26 members, omitting AWSAccountId, KeyManager and Origin

1 participant