Skip to content
Open
8 changes: 8 additions & 0 deletions config/configtls/curves_fips.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ var tlsCurveTypes = map[string]tls.CurveID{
//"X25519": tls.X25519,
//"X25519MLKEM768": tls.X25519MLKEM768,
}

// defaultCurvePreferences defines the default order of curve preferences for FIPS builds.
// Only NIST P-curves are available in FIPS mode.
var defaultCurvePreferences = []tls.CurveID{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the same set as tlsCurveTypes right above

tls.CurveP256, // FIPS approved, widely supported
tls.CurveP384, // FIPS approved, higher security
tls.CurveP521, // FIPS approved, highest security
}
12 changes: 11 additions & 1 deletion config/configtls/curves_nofips.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ var tlsCurveTypes = map[string]tls.CurveID{
"P384": tls.CurveP384,
"P521": tls.CurveP521,
"X25519": tls.X25519,
"X25519MLKEM768": tls.X25519MLKEM768,
"X25519MLKEM768": X25519MLKEM768,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you breaking convention?

}

// defaultCurvePreferences defines the default order of curve preferences.
// X25519MLKEM768 is prioritized for post-quantum security when compiled with Go 1.24+.
var defaultCurvePreferences = []tls.CurveID{
X25519MLKEM768, // Post-quantum hybrid key exchange
tls.X25519, // Modern, fast elliptic curve
tls.CurveP256, // Widely supported
tls.CurveP384, // Higher security margin
tls.CurveP521, // Highest security margin
}