Repository navigation
design: add proposal for post-quantum ML-DSA (FIPS 204) private keys - #9436
cert-manager-prow[bot] merged 7 commits into
Conversation
Add a design for supporting ML-DSA private keys and signatures in cert-manager, using the Go 1.27 standard library (crypto/mldsa and the ML-DSA support in crypto/x509). The proposal covers: - API: privateKey.algorithm "MLDSA" with size 44/65/87 (default 44), and MLDSA44/MLDSA65/MLDSA87 signature algorithms - An alpha MLDSAPrivateKeys feature gate for the controller and webhook - Keeping the go.mod directive at 1.26 and placing ML-DSA code behind a go1.27 build tag, so library consumers can stay on Go 1.26 - SelfSigned, CA and Kubernetes CSR signer support; other issuers receive the CSR unchanged and never fall back to a classical key - Lifecycle, keystore, size limit, upgrade/downgrade and test plans - Prototype measurements and answers to the questions raised in cert-manager#8929 Supersedes the approach taken in cert-manager#8527 (cloudflare/circl and hand-built ASN.1) in favour of the standard library. Ref: cert-manager#8929 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
I don't think that reflects the state of #8527 today - it looks like that one uses the stdlib as expected although the PR description still references CIRCL. I think we could probably drive #8527 to completion (albeit from a quick glance it does seem to need a bit more work - tests being the main thing missing. It also uses constants for the different ML-DSA "sizes", while it might well make sense for us to use the
This feels like a very AI-invented requirement 😛 We should absolutely feel free to bump to go1.27 in go.mod. We avoid breaking library consumers if we can, but they're secondary to cert-manager itself and that doesn't really extend to the go.mod directive anyway.
44 as a default seems sane as it's smallest and it appears to offer 128-bits of security which should be OK. If we have to change the default, no big deal. |
Address review feedback on cert-manager#9436: - Move the go directive to 1.27 in every go.mod instead of using a go1.27 build tag; drop the stub, internal/mldsa and min-Go CI jobs - Build on cert-manager#8527, which now uses the standard library, and list what it still needs (MLDSA with size, ML-DSA-87, restored checks.go mismatch checks, feature gate, webhook validation, tests) - Note maintainer agreement on the default parameter set (44) and openness to using the size field - Describe the preparatory PR (go.mod bump plus safety checks) and the GODEBUG and lint impact of Go 1.27 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
|
Thanks @SgtCoDFish, that's really helpful. I've updated the design accordingly:
Separately, bumping to Go 1.27 makes |
Sounds like a good start, happy to review. Without knowing the details of the panic, the backporting seems a little suspect - my gut is that it won't be a problem worth backporting for unless we can show that a cert-manager user can trigger a panic in the controller by creating a CertificateRequest with an unsupported key type or something. Backporting would be awkward because the older supported cert-manager releases aren't on Go 1.27 and we wouldn't normally upgrade the Go minor version in a backport unless we had to. |
Users can't trigger the panic directly, because the CRD enum and the webhook reject unknown algorithms, and older releases are built with Go 1.26. Describe the fix as defensive, and don't backport it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
ML-DSA handling in crypto/x509 depends on the toolchain, which is already Go 1.27, not on the go directive. Bumping go.mod therefore doesn't need its own safety checks. The gate checks come with the ML-DSA implementation and must land before v1.22 is cut, with a small fallback change only if the ML-DSA work misses the release. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
|
Thanks @SgtCoDFish. I've opened #9440, which is just the go directive bump to 1.27. On reflection, the safety checks don't belong there: whether Agreed on the backport, and you're right that a user can't trigger the panic: the CRD enum and the webhook both reject unknown algorithms, so it would only happen after a downgrade. I've dropped the backport from the design, and the fix will go in with the ML-DSA work as a defensive change. |
cert-manager is already built with Go 1.27.1. Moving the go directive to 1.27.0 in every go.mod lets code use APIs that are new in Go 1.27, such as crypto/mldsa, which the ML-DSA private keys design (#9436) needs. GODEBUG defaults follow the go directive. Between Go 1.26 and 1.27 only tracebacklabels and x509sslcertoverrideplatform change; the latter only affects macOS and Windows. Go 1.27 also enables golangci-lint's modernize/embedlit check, which reports hundreds of struct literals that could omit embedded field types. Disable it for now so that the fixes can go in a separate mechanical PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
SgtCoDFish
left a comment
There was a problem hiding this comment.
Got a few bits on this, but the sig alg stuff is probably the most discussable thing. I reckon adding Ed25519 to signature algs was likely a mistake, and it could be one this design will repeat!
| MLDSA44 SignatureAlgorithm = "MLDSA44" | ||
| MLDSA65 SignatureAlgorithm = "MLDSA65" | ||
| MLDSA87 SignatureAlgorithm = "MLDSA87" | ||
| ) |
There was a problem hiding this comment.
suggestion: These sig alg values are maybe not helpful? For RSA and ECDSA keys there's a meaningful difference between different SignatureAlgorithms (the user is deciding which size of SHA function to use for at least signing the CSR).
For Ed25519 and ML-DSA, there is only one value that's correct for a given key. If I've requested an ML-DSA-44 key, then the signature on my CSR must be ML-DSA-44 and can be no other value.
The signature on the resulting cert is also deterministic based on the signer, not the key we're creating here. If I generate a CSR using an ML-DSA-44 key but the signer is using a ML-DSA-87 key then the signature on the cert I get at the end will be ML-DSA-87 and nothing I configure in my CertificateSpec will affect that.
As such, I think the existence of SignatureAlgorithm for Ed25519 and ML-DSA seems entirely pointless. We could:
- just omit these values, because they're not helpful to end users
- add them to match the x509 package, but then we're just adding a footgun.
- add a "MLDSA" catch-all value, but it's still equally useless
There was a problem hiding this comment.
Agreed, went with option 1 in 2cb260a. There are no ML-DSA signature algorithm values, and signatureAlgorithm must be unset when algorithm: MLDSA. That needs an explicit webhook check, because a key algorithm with no entry in keyAlgToAllowedSigAlgs currently accepts any signature algorithm. The other two options are listed under Alternatives 4. I left PureEd25519 alone since it's an existing value.
| **Beta**, default on: | ||
| - At least one release cycle as alpha with no ML-DSA-specific bugs open. | ||
| - User feedback from at least 2 adopters running ML-DSA in production or staging. | ||
| - The compatibility matrix covers the major ingress, mesh and proxy implementations. | ||
| - The OpenSSL key format question has been reviewed again, based on what Go supports at the time. | ||
|
|
||
| **GA**: | ||
| - Two releases at beta with no significant issues. | ||
| - The FIPS status has been reviewed again (whether Go FIPS 140-3 module v1.26.0 has been certified). |
There was a problem hiding this comment.
suggestion: if these requirements are taken from somewhere I think we should change the source! They're very conservative, and I don't see a reason why we couldn't ship this as beta in v1.23 and GA in v1.24 if we end up happy with it.
We shouldn't commit to that timeline here - but we also don't need to add artificial waiting periods here. "We're happy with ML-DSA in cert-manager" is a fine enough signal.
There was a problem hiding this comment.
Thanks, I've removed the waiting periods. The doc now aims for beta in v1.23 and GA in v1.24, says these are targets rather than commitments, and uses "maintainers are happy with ML-DSA in cert-manager" as the signal to move on.
| - **Not every consumer can use ML-DSA yet.** cert-manager can write a perfectly valid ML-DSA `kubernetes.io/tls` Secret that an ingress controller, proxy, JVM or load balancer can't load. This is the main operational risk. We handle it through documentation (a parallel canary flow and a compatibility matrix, tracked in a follow-up issue) rather than code. | ||
| - **A mixed chain doesn't give post-quantum authentication.** An ML-DSA leaf signed by an ECDSA CA can still be forged by anyone able to break the CA's ECDSA key. cert-manager will allow it, because it's useful for staged migration, but the docs will say clearly that the whole chain must be ML-DSA. | ||
| - **Key format interoperability.** RFC 9881 allows three PKCS#8 private key formats: `seed`, `expandedKey` and `both`. Go writes and reads **seed-only** keys. OpenSSL 3.5+ writes `both` **by default**, and Go rejects that format with a clear error. This matters for users who bring their own CA key to a CA issuer. See [Key generation, encoding and parsing](#key-generation-encoding-and-parsing). | ||
| - **FIPS builds.** `crypto/mldsa` is unavailable when built against the Go FIPS 140-3 module v1.0.0, and available from module v1.26.0. Any FIPS-mode distribution of cert-manager needs to select v1.26.0 or later. As of Go 1.27.1, v1.26.0 is listed as "in process" rather than certified, so a FIPS-validated ML-DSA build isn't possible yet. Upstream cert-manager doesn't publish FIPS builds, so this only affects downstream distributions. |
There was a problem hiding this comment.
suggestion: I'd remove this, FIPS is irrelevant to open source cert-manager currently. This is a problem for the downstream vendors.
There was a problem hiding this comment.
Removed, along with the other FIPS 140 mentions elsewhere in the doc. The only remaining references are FIPS 204/205, which are just the names of the standards.
|
|
||
| **GA**: | ||
| - Two releases at beta with no significant issues. | ||
| - The FIPS status has been reviewed again (whether Go FIPS 140-3 module v1.26.0 has been certified). |
There was a problem hiding this comment.
suggestion: As above, I'd remove the FIPS stuff. No need for it.
There was a problem hiding this comment.
Removed, along with the other FIPS 140 mentions elsewhere in the doc. The only remaining references are FIPS 204/205, which are just the names of the standards.
|
|
||
| - Kubernetes: every version supported by the cert-manager release. Nothing here depends on Kubernetes. | ||
| - Go: cert-manager is built with Go 1.27.1+, and its `go.mod` files require Go 1.27, including for library consumers. | ||
| - FIPS: Go FIPS 140-3 module v1.26.0 or later is required for ML-DSA (in process for validation as of Go 1.27.1). |
There was a problem hiding this comment.
suggestion: As above, remove FIPS
There was a problem hiding this comment.
Removed, along with the other FIPS 140 mentions elsewhere in the doc. The only remaining references are FIPS 204/205, which are just the names of the standards.
Drop the proposed MLDSA44/65/87 signature algorithm values, since each ML-DSA key allows only one signature algorithm and the issued certificate's signature is decided by the signer. Require signatureAlgorithm to be unset for ML-DSA keys instead. Target beta in v1.23 and GA in v1.24, without fixed waiting periods, and remove FIPS-related content. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
|
I reviewed the plan and think it's good! No notes. |
|
Thanks for putting this together. We have been using an internal cert-manager fork with ML-DSA and composite ML-DSA support for some of our projects for some time now (disclosure: I work at Nokia). There are two things we had to handle internally that the design doesn't cover yet: 1. ML-DSA needs different default key usages. With 2. The e2e runner needs the gate too. UPDATE: And one more thought on the API. In our fork we went with separate
|
SgtCoDFish
left a comment
There was a problem hiding this comment.
Three fairly minor AI findings which i think are probably worth some attention - I wouldn't normally paste so much raw claude output but I know your workflow and I think this will be as helpful as me reframing it 😁
- The "Go version" section is already stale (:177-185)
Master merged 0ce14bd ("Bump the go directive to 1.27", PR #9440, same author) yesterday. All eight go.mod files are on go 1.27.0 on master, and .golangci.yaml already disables modernize/embedlit. The section still reads as future work:
▎ the go directive moves from 1.26.0 to 1.27.0 in every go.mod
▎ The bump is a small standalone PR, which can merge independently of the ML-DSA work.
▎ #8527 also moves the go directive to 1.27. Whichever PR merges first makes that change, and the other is rebased.
Rewrite in the past tense and link #9440. The "whichever merges first" paragraph should go entirely — it's resolved. (The branch is based on 363e374, before the merge, so this is just a rebase artefact.)
- The Issuers table oversells pass-through for ACME and Vault (:228)
Human note: This seems to just be an update to the plan which won't change much in impl, but it seems worth a quick fix.
The table says ACME/Vault/Venafi are "Not blocked by cert-manager. The ML-DSA CSR is sent unchanged and the CA accepts or rejects it." But §Key generation already notes — correctly — that ACME and Vault verify the issued certificate against the CSR. I confirmed those call sites:
- pkg/controller/certificaterequests/acme/acme.go:249 → PublicKeyMatchesCertificate
- internal/vault/vault.go:227 → PublicKeyMatchesCSR
- pkg/controller/certificatesigningrequests/acme/acme.go:235 → PublicKeyMatchesCertificate
Both funnel into PublicKeysEqual, which errors on *mldsa.PublicKey today. So pass-through is not free: even if an ACME or Vault CA happily issues an ML-DSA certificate, cert-manager will fail the post-issuance check. Suggest adding a footnote to that table row — something like "requires the PublicKeysEqual change in §Key generation; without it these issuers fail after the CA has issued." That ordering matters: the CA will have burned an issuance.
- Prefer the explicit *mldsa.PublicKey case over the generic Equal fallback (:205)
(I snipped out the AI explanation here - I agree we should just use the explicit case)
Update the Go version section now that cert-manager#9440 has merged, note that pass-through issuers need the PublicKeysEqual change, use explicit ML-DSA cases for key comparison, add ML-DSA key usage defaults and validation per RFC 9881, and enable the gate in the e2e test runner. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
|
Thanks @SgtCoDFish, all three were worth fixing.
I've also added ML-DSA key usage defaults and the e2e runner gate from @misiektoja's comment. |
|
Thanks @misiektoja, this is really useful, especially coming from a fork that's already running ML-DSA. 1. Key usages: agreed, and I've added a Key usages section to the design. I confirmed Go 1.27.1 happily creates an ML-DSA certificate with
One more place needed the same fix: the Ingress/Gateway shim writes 2. e2e runner gate: good catch, added. The design now includes |
|
Thanks @FelixPhipps, I'm glad I could help. BTW, I edited my comment afterwards to add a point about algorithm naming, so it may have been missed. I know the design covers this as Alternative 2 and that draft-ietf-lamps-pq-composite-sigs is in the RFC Editor queue and defines 18 fixed combinations, each with its own OID, such as Would it be worth deciding how composites would fit before the alpha API ships? Named values for both, such as |
|
Thanks @misiektoja, I did miss the edit, sorry. There's a fair case for named values:
Even so, I still lean towards algorithm: MLDSA plus size. It matches Go's single x509.MLDSA, keeps the enum short, and gives a sensible default (44) without users having to choose. cert-manager also already mixes both models (size for RSA and ECDSA, a named value for Ed25519). Designing around composites, which aren't standardised yet and aren't in Go, also feels a bit speculative. It's ultimately a maintainer decision, and either way it's worth settling before alpha, while it's still cheap to change. |
I think the most convincing argument for The name My gut says stick with size, just because it feels better for users if they only need to know "ML-DSA is post-quantum, let's use that" and they don't need to pick 44 vs 65 or whatever. Looking forwards to composites it's definitely fair to say that an integer size is tricky there (I can imagine ways of making it work but they're all pretty ugly). I think we have that problem whatever we do here though - and if we agree that having the ability for the cert-manager team to choose a sane default is valuable, I don't think we should remove that value today for a future composites API which may require more changes anyway. I wouldn't die on this hill, but it seems fine to use size for this to me. |
|
Thanks both, that makes sense. Being able to pick a sane default and change it later is the stronger argument. BTW, if a future release changes the ML-DSA default from 44 to let's say 65, there is an upgrade implication for users already relying on the old default. The proposed default isn't stored in the Certificate, so existing ML-DSA-44 keys would no longer match Certificates that omit |
Record the decision to keep algorithm: MLDSA plus size, note that composite ML-DSA and SLH-DSA would use named values, and describe what a future change to the default parameter set would mean for existing Certificates and how users can prepare. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
|
Thanks @SgtCoDFish, that's a convincing reason. Being able to choose a sensible default and change it later is the main advantage, and named values would lose it. I've kept |
|
Good point @misiektoja, thanks. I've added it to the Upgrade / Downgrade Strategy section, and noted that RSA and ECDSA defaults already work this way. If a later release changes the default, Certificates that leave The design doesn't add a migration mechanism now, since the default may never change. Instead it says a change would be called out in the release notes, and explains how to prepare: set |
SgtCoDFish
left a comment
There was a problem hiding this comment.
/lgtm
/approve
I think this covers the topic thoroughly and helpfully. I'm happy with this personally. I'm sure that our understanding here will evolve as this work goes on, which makes it all the better that this code will be feature flagged so we'll have the option!
Great stuff!
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SgtCoDFish The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/override pull-cert-manager-master-e2e-v1-37 Known issue with v1.37 tests: #9462 This is a design doc so there's no value to seeing a passing e2e here. |
|
@SgtCoDFish: Overrode contexts on behalf of SgtCoDFish: pull-cert-manager-master-e2e-v1-37 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
* Add ML-DSA post-quantum signature algorithm support Signed-off-by: siddhi bhor <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Implement ML-DSA private keys per the merged design Build on the original ML-DSA proof of concept so that it follows the design merged in #9436: - Add the alpha MLDSAPrivateKeys feature gate to the controller and webhook, and reject MLDSA key algorithms when it is disabled. - Use size to select the ML-DSA parameter set (44, 65 or 87, default 44) and validate it. - Generate, encode, parse and match ML-DSA keys with the Go standard library, and create and verify CSRs signed with ML-DSA. - Sign with ML-DSA in the SelfSigned and CA issuers, including the Kubernetes CertificateSigningRequest signers, and default key usages to digital signature for ML-DSA keys. - Handle ML-DSA keys in the re-issuance policies, key manager and certificate-shim annotations. - Add unit tests and e2e/conformance coverage behind the feature gate. Signed-off-by: Felix Phipps <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Set the issuer helper in the readiness controller's NewController Only controllerWrapper.Register set the helper, so callers of NewController, such as the integration tests' runAllControllers, panicked in useARIForRenewal once a Secret held a certificate. NewController now sets a helper that can get Issuers, and Register still replaces it with one that can also get ClusterIssuers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Add ML-DSA integration tests and correct the shim design Add the integration tests from the design's test plan: renewal under rotationPolicy Always and Never, including a parameter set change; controller restart without re-issuance; turning the MLDSAPrivateKeys feature gate off and back on; and the CombinedPEM, DER, PKCS#12 and JKS outputs. runAllControllersWithRecorder lets tests check events. The design said invalid ML-DSA shim annotations would record the existing BadConfig event, but invalid annotations have never recorded an event. ML-DSA errors take the same path as other invalid annotations: logged and retried, with no Certificate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Fix lint errors in the ML-DSA integration tests Group the cert-manager imports with the other modules, as gci expects in the integration-tests module, and replace issueRevision's crtName parameter, which was always "mldsa", with a package-level constant. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Skip ML-DSA CSR conformance tests on API servers older than Go 1.27 kube-apiserver checks a CertificateSigningRequest's signature when it's created, and Kubernetes v1.37 is built with Go 1.26, which can't check ML-DSA signatures. It rejects ML-DSA CertificateSigningRequests with "x509: cannot verify signature: algorithm unimplemented", so the ML-DSA cases in the CertificateSigningRequests conformance suite failed. Add RequireServerGoVersion to the e2e framework, and skip those cases when the API server was built with Go older than 1.27. They run again by themselves once Kubernetes is built with Go 1.27. Document the limitation in the design. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Address review comments on ML-DSA private keys - Make @SgtCoDFish and @FelixPhipps the owners of the MLDSAPrivateKeys feature gate. - Replace ForbiddenKeyUsagesForPublicKeyAlgorithm, which filtered a list, with the KeyUsageAllowedForPublicKeyAlgorithm predicate, so validation no longer builds a one-element slice for each usage. - Note on maxCACertificatePEMSize that ML-DSA CA certificates are larger than it, and why that's fine. The limits don't change. - Test ML-DSA-87 chains right up to the chain size limit, using a fixed certificate from testdata instead of generating keys. - Fix stale key type lists in pki doc comments, and a missing quote in an error message. - Pass a context to RequireServerGoVersion and use ServerVersionWithContext. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Address hjoshi123's review comments on ML-DSA gate checks - Leave CertificateRequests stopped by the MLDSAPrivateKeys gate Pending rather than Failed in the CA and SelfSigned issuers, so they're signed without failure backoff once the gate is turned back on. - Mark a CA issuer whose CA key is ML-DSA as not Ready, with reason MLDSAPrivateKeysDisabled, while the gate is off. - Make logging in the CertificateSigningRequest signers' gate checks match the CertificateRequest issuers. - Update the design doc to match. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Address wallrj's review comments on ML-DSA private keys - Reject every non-zero ML-DSA size other than 44, 65 or 87 in the webhook, and apply the ML-DSA-44 default in MLDSAParametersForSize only, so key generation, key matching and CSR generation agree. - Skip the ML-DSA CA e2e specs before creating the Issuer when the feature gate is disabled, and tolerate NotFound in their cleanup. - Build the readiness controller's issuer helper once in NewController, including the ClusterIssuer lister. - Deprecate KeyUsagesForCertificateOrCertificateRequest. - Re-queue ML-DSA Certificates that must be re-issued every 30 minutes while the MLDSAPrivateKeys gate is disabled, so the warning event doesn't expire. - Reword the privateKey.algorithm doc line and regenerate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> * Apply the modernize embedlit fixes to the ML-DSA code master now enables golangci-lint's modernize/embedlit check and has dropped the metav1 import from the CA e2e fixtures, so the ML-DSA fixture no longer compiled after merging master. Omit the embedded ObjectMeta type from the struct literals this branch adds, as master does, using make fix-golangci-lint. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felix Phipps <[email protected]> --------- Signed-off-by: siddhi bhor <[email protected]> Signed-off-by: Felix Phipps <[email protected]> Signed-off-by: Felix Phipps <[email protected]> Co-authored-by: siddhi bhor <[email protected]> Co-authored-by: Felix Phipps <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Adds a design for supporting ML-DSA private keys in cert-manager, using the Go 1.27 standard library (crypto/mldsa and the ML-DSA support in crypto/x509).
The proposal covers:
Builds on #8527, which already uses the standard library, and lists what it needs before it can merge.
Ref: #8929