Repository navigation
Support Post-Quantum Cryptography (ML-DSA) OIDC token signing and key… - #50358
arnabnandy7 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for post-quantum ML-DSA (FIPS 204) signature algorithms in Keycloak for OIDC/JWS by introducing AKP key handling, new signature/verifier SPI providers, and an admin key-provider for generated ML-DSA realm keys.
Changes:
- Added ML-DSA-44/65/87 algorithm → JCA mapping and associated
KeyType.AKPwiring (signing/verifying + JWKS thumbprints). - Introduced ML-DSA
SignatureProviderandClientSignatureVerifierProviderimplementations and registered them via ServiceLoader. - Added an admin-console key provider to generate/rotate ML-DSA keys and updated tests to ensure provider discovery.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| services/src/test/java/org/keycloak/crypto/CryptoUtilsTest.java | Extends provider-discovery test coverage to ML-DSA algorithms. |
| services/src/main/resources/META-INF/services/org.keycloak.keys.KeyProviderFactory | Registers the generated ML-DSA key provider factory. |
| services/src/main/resources/META-INF/services/org.keycloak.crypto.SignatureProviderFactory | Registers ML-DSA signature provider factories. |
| services/src/main/resources/META-INF/services/org.keycloak.crypto.ClientSignatureVerifierProviderFactory | Registers ML-DSA client signature verifier factories. |
| services/src/main/java/org/keycloak/protocol/oidc/utils/JWKSServerUtils.java | Emits AKP keys into JWKS responses. |
| services/src/main/java/org/keycloak/keys/GeneratedMlDsaKeyProviderFactory.java | Adds generated ML-DSA key provider factory + fallback key generation logic. |
| services/src/main/java/org/keycloak/keys/GeneratedMlDsaKeyProvider.java | Loads persisted/generated ML-DSA keys into KeyWrapper. |
| services/src/main/java/org/keycloak/keys/AbstractMlDsaKeyProviderFactory.java | Defines shared ML-DSA key provider factory config/validation building blocks. |
| services/src/main/java/org/keycloak/keys/AbstractMlDsaKeyProvider.java | Implements common ML-DSA KeyProvider behavior and KeyWrapper creation. |
| services/src/main/java/org/keycloak/crypto/MLDSASignatureProvider.java | Implements server-side ML-DSA signing/verifying via the Signature SPI. |
| services/src/main/java/org/keycloak/crypto/MLDSAClientSignatureVerifierProvider.java | Implements client assertion verification entry-point for ML-DSA. |
| services/src/main/java/org/keycloak/crypto/MLDSA44SignatureProviderFactory.java | Factory for ML-DSA-44 SignatureProvider. |
| services/src/main/java/org/keycloak/crypto/MLDSA65SignatureProviderFactory.java | Factory for ML-DSA-65 SignatureProvider. |
| services/src/main/java/org/keycloak/crypto/MLDSA87SignatureProviderFactory.java | Factory for ML-DSA-87 SignatureProvider. |
| services/src/main/java/org/keycloak/crypto/MLDSA44ClientSignatureVerifierProviderFactory.java | Factory for ML-DSA-44 ClientSignatureVerifierProvider. |
| services/src/main/java/org/keycloak/crypto/MLDSA65ClientSignatureVerifierProviderFactory.java | Factory for ML-DSA-65 ClientSignatureVerifierProvider. |
| services/src/main/java/org/keycloak/crypto/MLDSA87ClientSignatureVerifierProviderFactory.java | Factory for ML-DSA-87 ClientSignatureVerifierProvider. |
| services/src/main/java/org/keycloak/crypto/ClientMLDSASignatureVerifierContext.java | Adds ML-DSA-specific client signature verification context. |
| core/src/main/java/org/keycloak/util/KeyWrapperUtil.java | Enables generic asymmetric signer/verifier contexts for AKP keys. |
| core/src/main/java/org/keycloak/util/JWKSUtils.java | Adds AKP thumbprint member handling (including alg). |
| core/src/main/java/org/keycloak/crypto/JavaAlgorithm.java | Adds ML-DSA algorithm and hash mappings; maps ML-DSA to KeyType.AKP. |
56e7462 to
7017ed6
Compare
75fb3bf to
66bc1cd
Compare
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.cluster.GroupInvalidationClusterTest#crudWithoutFailoverorg.keycloak.testsuite.cluster.GroupInvalidationClusterTest#crudWithFailover |
a55b302 to
ed0d9b2
Compare
afc29ec to
a9132e0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 53 out of 53 changed files in this pull request and generated no new comments.
Suppressed comments (1)
services/src/main/java/org/keycloak/keys/GeneratedMlDsaKeyProviderFactory.java:151
- A missing or malformed persisted public key lets the Base64 decoder's runtime exception escape the component-validation path, producing either a generic “invalid provider type” response or a server error instead of an ML-DSA key validation error. Wrap decoding in
ComponentValidationException, as the generated EdDSA provider does.
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.cluster.JGroupsCertificateRotationClusterTest#testCoordinatorHasScheduleTask |
a9132e0 to
8d7bafc
Compare
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
8d7bafc to
6878ee0
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The security-sensitive cryptographic changes span multiple token-verification paths and require final human interoperability and provider review.
Review effort: Balanced
Findings: None


Description
This PR implements support for Post-Quantum Cryptography (PQC) signature algorithms (ML-DSA-44, ML-DSA-65, ML-DSA-87) in Keycloak. It extends Keycloak's core JWK, JWS, and SPI providers to support OIDC token signing and verification using these FIPS 204 standardized algorithms.
Key Changes
ML-DSA-44,ML-DSA-65, andML-DSA-87constants and mapped them toKeyType.AKPinJavaAlgorithm.java.JWKSUtilsto support AKP JWK thumbprints (usingalgandpubclaims) and updatedJWKSServerUtilsto format AKP keys into JWK representations.SignatureProviderandClientSignatureVerifierProviderfactories for ML-DSA and registered them via ServiceLoader.GeneratedMlDsaKeyProviderand factory so that administrators can generate and rotate ML-DSA keys directly from the Realm Keys management page.Testing & Verification
All modifications have been thoroughly validated with existing and updated test cases:
DefaultCryptoAKPJWKTest: Passed (verified AKP JWK decoding/encoding).DefaultCryptoJWKSUtilsTest: Passed (verified thumbprint calculations for AKP).CryptoUtilsTest: Passed (verified ML-DSA signature providers retrieval).Test execution command:
AI Agent Disclosure
In accordance with Keycloak's generative AI usage guidelines (Section 11.4 of CONTRIBUTING.md), this PR was generated and verified using Antigravity, an autonomous AI coding assistant. The agent analyzed the codebase, proposed the implementation plan, created the new provider classes, and executed tests to verify correctness.
Closes #50355