Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 03:15 UTC
caddytls: Support post-quantum key exchange mechanism X25519MLKEM768
Also bump minimum Go version to 1.24.
Matthew Holt committed
Feb 11, 2025 at 22:43 UTC
172136a0a0f6aa47be4eab3727fa2482d7af6617
3 files changed
+21
-27
go.mod
+1
-3
@@ -1,8 +1,6 @@
1
module github.com/caddyserver/caddy/v2
2
3
-go 1.22.3
4
-
5
-toolchain go1.23.0
3
+go 1.24
4
5
require (
6
github.com/BurntSushi/toml v1.4.0
modules/caddytls/connpolicy.go
+8
-10
@@ -884,19 +884,17 @@ func setDefaultTLSParams(cfg *tls.Config) {
884
cfg.CipherSuites = append([]uint16{tls.TLS_FALLBACK_SCSV}, cfg.CipherSuites...)
885
886
if len(cfg.CurvePreferences) == 0 {
887
- // We would want to write
888
- //
889
- // cfg.CurvePreferences = defaultCurves
890
- //
891
- // but that would disable the post-quantum key agreement X25519Kyber768
892
- // supported in Go 1.23, for which the CurveID is not exported.
893
- // Instead, we'll set CurvePreferences to nil, which will enable PQC.
894
- // See https://github.com/caddyserver/caddy/issues/6540
895
- cfg.CurvePreferences = nil
887
+ cfg.CurvePreferences = defaultCurves
888
}
889
890
if cfg.MinVersion == 0 {
899
- cfg.MinVersion = tls.VersionTLS12
891
+ // crypto/tls docs:
892
+ // "If EncryptedClientHelloKeys is set, MinVersion, if set, must be VersionTLS13."
893
+ if cfg.EncryptedClientHelloKeys == nil {
894
+ cfg.MinVersion = tls.VersionTLS12
895
+ } else {
896
+ cfg.MinVersion = tls.VersionTLS13
897
+ }
898
}
899
if cfg.MaxVersion == 0 {
900
cfg.MaxVersion = tls.VersionTLS13
modules/caddytls/values.go
+12
-14
@@ -81,13 +81,15 @@ func getOptimalDefaultCipherSuites() []uint16 {
81
return defaultCipherSuitesWithoutAESNI
82
}
83
84
-// SupportedCurves is the unordered map of supported curves.
84
+// SupportedCurves is the unordered map of supported curves
85
+// or key exchange mechanisms ("curves" traditionally).
86
// https://golang.org/pkg/crypto/tls/#CurveID
87
var SupportedCurves = map[string]tls.CurveID{
87
- "x25519": tls.X25519,
88
- "secp256r1": tls.CurveP256,
89
- "secp384r1": tls.CurveP384,
90
- "secp521r1": tls.CurveP521,
88
+ "X25519mlkem768": tls.X25519MLKEM768,
89
+ "x25519": tls.X25519,
90
+ "secp256r1": tls.CurveP256,
91
+ "secp384r1": tls.CurveP384,
92
+ "secp521r1": tls.CurveP521,
93
}
94
95
// supportedCertKeyTypes is all the key types that are supported
@@ -100,20 +102,16 @@ var supportedCertKeyTypes = map[string]certmagic.KeyType{
102
"ed25519": certmagic.ED25519,
103
}
104
103
-// defaultCurves is the list of only the curves we want to use
104
-// by default, in descending order of preference.
105
+// defaultCurves is the list of only the curves or key exchange
106
+// mechanisms we want to use by default. The order is irrelevant.
107
//
106
-// This list should only include curves which are fast by design
107
-// (e.g. X25519) and those for which an optimized assembly
108
+// This list should only include mechanisms which are fast by
109
+// design (e.g. X25519) and those for which an optimized assembly
110
// implementation exists (e.g. P256). The latter ones can be
111
// found here:
112
// https://github.com/golang/go/tree/master/src/crypto/elliptic
111
-//
112
-// Temporily we ignore these default, to take advantage of X25519Kyber768
113
-// in Go's defaults (X25519Kyber768, X25519, P-256, P-384, P-521), which
114
-// isn't exported. See https://github.com/caddyserver/caddy/issues/6540
115
-// nolint:unused
113
var defaultCurves = []tls.CurveID{
114
+ tls.X25519MLKEM768,
115
tls.X25519,
116
tls.CurveP256,
117
}