keys: generate only P256 keys under FIPS 140-only mode#42
Merged
Conversation
Under GODEBUG=fips140=only, crypto/ecdh refuses to generate an X25519 key. As a result keys.New() failed outright, and even with that guarded, Client.Enroll() panicked dereferencing the nil Ed25519 host key. This made it impossible for a FIPS-enforcing build to enroll at all, even into a P256 network. Generate the P256 keypair unconditionally, and only generate the X25519/Ed25519 keypair when crypto/fips140 is not enabled. Enroll() now includes the 25519 public keys only when they were generated. Non-FIPS builds are unchanged: both key sets are generated and sent. FIPS builds send only P256, which the DN API accepts for P256 networks (FIPS networks are always P256). Verified end to end: a fips140=only dnclient now enrolls into a P256 network and completes a P256 Nebula handshake. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sk4ZZA8bcjVi6FJ3k2opFB
Add TestNewFIPSAware covering both modes: without FIPS both key sets are generated, and under GODEBUG=fips140=only only P256 keys are produced and New() does not error (the regression that previously broke enrollment for FIPS builds). CI now runs the keys package a second time under GOFIPS140=v1.0.0 GODEBUG=fips140=only to exercise the FIPS branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sk4ZZA8bcjVi6FJ3k2opFB
johnmaguire
approved these changes
Jul 3, 2026
johnmaguire
reviewed
Jul 3, 2026
| # In fips140=only mode crypto/ecdh rejects X25519, so this also guards | ||
| # against a regression that would break enrollment for FIPS builds. | ||
| - name: Run FIPS key-generation tests | ||
| run: GOFIPS140=v1.0.0 GODEBUG=fips140=only go test ./keys/... |
Member
There was a problem hiding this comment.
I don't think it'd hurt to run the whole test suite under fips140.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under GODEBUG=fips140=only, crypto/ecdh refuses to generate an X25519 key. As a result keys.New() failed outright, and even with that guarded, Client.Enroll() panicked dereferencing the nil Ed25519 host key. This made it impossible for a FIPS-enforcing build to enroll at all, even into a P256 network.
Generate the P256 keypair unconditionally, and only generate the X25519/Ed25519 keypair when crypto/fips140 is not enabled. Enroll() now includes the 25519 public keys only when they were generated.
Non-FIPS builds are unchanged: both key sets are generated and sent. FIPS builds send only P256, which the DN API accepts for P256 networks (FIPS networks are always P256). Verified end to end: a fips140=only dnclient now enrolls into a P256 network and completes a P256 Nebula handshake.