Architecture Decision Record
ADR-149: Crypto Agility for Token Signing (a Key-Size Floor, kid Rotation, Derived Discovery)
Status
Accepted (2026-12-04). Released in MMCA.Common v1.332.0 (MMCA.Common/CHANGELOG.md:9, the tokens-and-keys
entry at :15, the algorithm entry at :25, the discovery entry at :34) and deployed to MMCA.ADC and
MMCA.Store production on 2026-12-04. Builds on ADR-004 (services
validate Identity's tokens through JWKS and OIDC discovery) and ADR-050
(the refresh-token lifetime that bounds a rotation's overlap).
Context
The NSA advisory of 2026-12-02 set a 3072-bit interim floor for classical RSA. Both production Identity hosts signed RS256 with a 2048-bit key at the time (measured 2026-12-03). Three forces shaped the answer:
- A key change must not sign everyone out. Every service validates through JWKS
(ADR-004), and a token signed by the outgoing key stays live until it
expires. Replacing the key in one step rejects every live token, which is the right move after a leak
(
MMCA.ADC/infra/OPERATIONS.md:865,MMCA.Store/infra/OPERATIONS.md:612: hard cut, no overlap) and the wrong one for a planned change. - A floor that lives only in a runbook drifts. Nothing in the framework stopped a host from starting with a 2048-bit key, or from generating one for a new environment.
- The next algorithm is not known yet. A later move to PS256, an elliptic-curve key or a post-quantum signature should not need a framework change in every place that names the algorithm. Before v1.332.0 discovery advertised a fixed RS256.
Decision
- A key-strength floor enforced at start-up, outside Development.
JwtSettings.MinimumRsaKeySizeBits(Jwt:MinimumRsaKeySizeBits) defaults to 3072 and cannot be configured below 2048 (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Auth/JwtSettings.cs:74-81,[Range(2048, int.MaxValue)]at:80).JwtKeyStrengthValidatormeasures the signing and validation keys (MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Auth/JwtKeyStrengthValidator.cs:43-49) andJwksKeyStrengthValidatorevery JWKS key, the additional ones included, against the same floor (.../Startup/Auth/JwksKeyStrengthValidator.cs:31). The measure isJwtKeyMaterial.StrengthShortfall: an RSA modulus below the floor, or an EC key not on P-384 (MMCA.Common/Source/Build/Auth/JwtKeyMaterial.cs:98-124). In Development a shortfall logs one warning; elsewhere it fails options validation and the host does not start (JwtKeyStrengthValidator.cs:102-108). The floor may drop to 2048 only as a temporary override while an older public key is still configured for a rotation (step 2 below), and it returns to 3072 when that key is removed. - Rotation by
kid, with the outgoing public key published beside the new one. Identity signs with the current key underJwks:KeyId(MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Auth/TokenService.cs:98).Jwks:AdditionalKeyspublishes further public keys that are never used to sign (.../Auth/JwksSettings.cs:81); each entry has its ownKeyId, anAlgorithmdefaulting to RS256 (:220) and its key material, and options validation refuses a repeated or missing kid (:93-110).RsaJwksProviderpublishes the current key first and each additional key after it (.../Auth/RsaJwksProvider.cs:59-66), so a validator that ignoreskidstill gets the signing key, and every local validator accepts the additional keys (JwksSettings.cs:179-184). Both apps wire this in Bicep:jwksKeyIdnames the current kid (MMCA.ADC/infra/main.bicep:70,MMCA.Store/infra/main.bicep:78),previousJwksKeyIdthe outgoing one (MMCA.ADC/infra/main.bicep:201,MMCA.Store/infra/main.bicep:173), and when a previous public key is supplied (hasPreviousRsaKey,MMCA.ADC/infra/main.bicep:198,MMCA.Store/infra/main.bicep:170) the Identity app getsJwks__AdditionalKeys__0__KeyId,__Algorithm(RS256),__RsaPublicKeyPemandJwt__MinimumRsaKeySizeBits=2048(MMCA.ADC/infra/main.bicep:2599-2606,MMCA.Store/infra/main.bicep:2366-2373). - Discovery advertises what the JWKS publishes.
id_token_signing_alg_values_supportedis the distinctalgvalues of the published keys, current key first, and RS256 only when no provider or no key is configured (MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Endpoints/OidcDiscoveryEndpointExtensions.cs:33,:132,:142-150). The JWKS carriesalgper key (RsaJwksProvider.cs:59,:65). A rotation to another algorithm therefore changes configuration only: the new key's algorithm appears in discovery the moment it is published.Jwt:SigningAlgorithmaccepts RS256 (default), PS256, ES384 (P-384 only) and HS256 (MMCA.Common/CHANGELOG.md:25), and asymmetric validators accept exactly RS256, PS256 and ES384 (MMCA.Common/Source/Build/Auth/JwtAlgorithms.cs:24-25). Both well-known documents are served withCache-Control: public, max-age=300(.../Startup/Endpoints/JwksEndpointExtensions.cs:28). - Post-quantum items are watched, not adopted. ML-DSA token signing is deliberately not adopted. The
Azure Container Apps edge in front of both apps does not negotiate the hybrid
X25519MLKEM768key exchange and still accepts TLS 1.2 (measured 2026-12-03/04); that is a platform limit, not fixable in application code, and is watched.
Rationale
- The floor in code survives every environment. A host that starts proves its keys meet the floor, so a
new environment cannot be provisioned with a 2048-bit key by accident. Development stays permissive so a
local key or test fixture never blocks a developer, and the framework's own test keys are 3072-bit
(
MMCA.Common/Source/Hosting/MMCA.Common.Testing/Support/JwtTokenGenerator.cs:66,.../MMCA.Common.Testing.Aspire/Preconditions/EphemeralRsaKeyPair.cs:35). - The override is bound to the reason for it. The 2048 floor is set in the same Bicep condition that publishes the previous key, so it cannot outlive the rotation that needs it.
kidrotation keeps live tokens valid. Tokens signed before the switch validate against the additional key until they expire; tokens signed after it carry the new kid, and a peer refreshes a cached JWKS on the first unknown kid (MMCA.Store/infra/OPERATIONS.md:659-661).- Derived discovery removes a place to forget. An algorithm list hard-coded in discovery would have to change in step with every key; derived from the JWKS, it cannot disagree with it.
Trade-offs
- Two keys are trusted for a window. During the overlap a token signed by the outgoing 2048-bit key is
still accepted, for at most one refresh-token lifetime (7 days,
MMCA.Store/infra/OPERATIONS.md:662-663). - A manual removal step. The overlap ends only when an operator deletes the previous key and redeploys; nothing expires it automatically.
- Breaking for consumers. A non-Development host with a key below 3072 bits fails to start after the
upgrade until it rotates or sets the override (
MMCA.Common/UPGRADING.md:52). The JWT validators' clock skew also drops to 30 seconds (MMCA.Common/Source/Build/Auth/JwtAlgorithms.cs:22).
Alternatives rejected
- Immediate switch to a 3072-bit key with no overlap (2026-12-03). Simplest, but every live access and refresh token stops validating at once, which signs every user of both apps out. It stays the procedure for a leaked key, where that is the point. Revisit only for a leak.
- ES256 (2026-12-03). A P-256 key changes the algorithm every validator and client must accept and
gives a smaller margin than the advisory family asks for; the framework's elliptic-curve option is
ES384 on P-384 only (
JwtKeyMaterial.cs:98-124). RS256 at 3072 bits is a drop-in change. Revisit if token size or signing cost becomes a measured problem, and then as ES384. - ML-DSA signing now (2026-12-03). No validator in the framework accepts an ML-DSA algorithm
(
JwtAlgorithms.cs:24-25), so adopting it means every service and client validating a new algorithm at once, for a threat (forged tokens from a quantum adversary) that does not outlive a token's lifetime. Revisit when the token libraries the validators use support an ML-DSA JWS algorithm; the derived discovery and per-keyAlgorithmabove mean that move is a rotation, not a redesign.
Consequences
- Production state (measured 2026-12-04): both production JWKS publish a 3072-bit RS256 key under the
new kid (
mmca-adc-2026-12,MMCA.ADC/infra/main.bicep:70;mmca-store-2026-12,MMCA.Store/infra/main.bicep:78) with the previous 2048-bit key as an additional key. - Removal step, on or after 2026-12-11 (one refresh-token lifetime after the switch): delete the
previous-key secret and redeploy, which removes the additional key and the 2048 override together
(
MMCA.Store/infra/OPERATIONS.md:662-665). The runbooks are "JWKS signing-key rotation" inMMCA.ADC/infra/OPERATIONS.md:890and "JWKS signing-key rotation (planned)" inMMCA.Store/infra/OPERATIONS.md:631. - Consumer adoption: generate 3072-bit pairs, and rotate with the previous public key as a
Jwks:AdditionalKeysentry and the 2048 override only while it is configured (MMCA.Common/UPGRADING.md:52). - Watch: the Container Apps edge for hybrid post-quantum key exchange and a TLS 1.3 minimum; the token libraries for ML-DSA support.
Related
ADR-004 (JWKS and discovery validation), ADR-050 (refresh-token rotation and lifetime), ADR-140 (machine tokens are signed by the same key).