@marcel91200 / caddy Mirror · read-only / commits / dcbf38d0
Fork 0

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, 09:30 UTC

tls: use Go default kex for the moment that include PQC (#6542)

By default Go 1.23 enables X25519Kyber768, a post-quantum key agreement method that is enabled by default on Chrome. Go 1.23 does not expose the CurveID, so we cannot add it by specifying it in CurvePreferences. The reason is that X25519Kyber768 is a preliminary key agreement that will be supplanted by X25519MLKEM768. For the moment there is value in enabling it. A consequence of this is that by default Caddy will enable support for P-384 and P-521. This PR also removes the special code to add support for X25519Kyber768 via the Cloudflare Go branch. Cf #6540

Bas Westerbaan committed Aug 28, 2024 at 01:08 UTC dcbf38d0b370cc0f412157b11961dd0b0e007251
4 files changed +19 -25
cmd/caddy/main.go
+5
@@ -1,3 +1,8 @@
1 +// The below line is required to enable post-quantum key agreement in Go 1.23
2 +// by default without insisting on setting a minimum version of 1.23 in go.mod.
3 +// See https://github.com/caddyserver/caddy/issues/6540#issuecomment-2313094905
4 +//go:debug tlskyber=1
5 +
6 // Copyright 2015 Matthew Holt and The Caddy Authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
modules/caddytls/cf.go deleted
-24
@@ -1,24 +0,0 @@
1 -//go:build cfgo
2 -
3 -package caddytls
4 -
5 -// This file adds support for X25519Kyber768Draft00, a post-quantum
6 -// key agreement that is currently being rolled out by Chrome [1]
7 -// and Cloudflare [2,3]. For more context, see the PR [4].
8 -//
9 -// [1] https://blog.chromium.org/2023/08/protecting-chrome-traffic-with-hybrid.html
10 -// [2] https://blog.cloudflare.com/post-quantum-for-all/
11 -// [3] https://blog.cloudflare.com/post-quantum-to-origins/
12 -// [4] https://github.com/caddyserver/caddy/pull/5852
13 -
14 -import (
15 - "crypto/tls"
16 -)
17 -
18 -func init() {
19 - SupportedCurves["X25519Kyber768Draft00"] = tls.X25519Kyber768Draft00
20 - defaultCurves = append(
21 - []tls.CurveID{tls.X25519Kyber768Draft00},
22 - defaultCurves...,
23 - )
24 -}
modules/caddytls/connpolicy.go
+9 -1
@@ -841,7 +841,15 @@ func setDefaultTLSParams(cfg *tls.Config) {
841 cfg.CipherSuites = append([]uint16{tls.TLS_FALLBACK_SCSV}, cfg.CipherSuites...)
842
843 if len(cfg.CurvePreferences) == 0 {
844 - cfg.CurvePreferences = defaultCurves
844 + // We would want to write
845 + //
846 + // cfg.CurvePreferences = defaultCurves
847 + //
848 + // but that would disable the post-quantum key agreement X25519Kyber768
849 + // supported in Go 1.23, for which the CurveID is not exported.
850 + // Instead, we'll set CurvePreferences to nil, which will enable PQC.
851 + // See https://github.com/caddyserver/caddy/issues/6540
852 + cfg.CurvePreferences = nil
853 }
854
855 if cfg.MinVersion == 0 {
modules/caddytls/values.go
+5
@@ -108,6 +108,11 @@ var supportedCertKeyTypes = map[string]certmagic.KeyType{
108 // implementation exists (e.g. P256). The latter ones can be
109 // found here:
110 // 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
116 var defaultCurves = []tls.CurveID{
117 tls.X25519,
118 tls.CurveP256,