Skip to content

Commit 89b7085

Browse files
Update TLS profiles to Mozilla guidelines v6.0
Mozilla updated their TLS configuration guidelines to v6.0, which includes: - Removed legacy "old" profile (preserved v5.7 definition for backwards compatibility) - Changed cipher list format from "ciphers.go" to "ciphers.iana" - Added X25519MLKEM768 post-quantum hybrid curve - Fixed cipher constant names (CHACHA20_POLY1305_SHA256) Updated update-tls-profiles.sh to handle the new JSON structure and added X25519MLKEM768 curve support to tlsprofiles package. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fd25bf7 commit 89b7085

4 files changed

Lines changed: 107 additions & 16 deletions

File tree

hack/tools/update-tls-profiles.sh

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,21 @@ curl -L -s ${INPUT} > ${TMPFILE}
1717

1818
version=$(${JQ} -r '.version' ${TMPFILE})
1919

20+
# Check if old profile exists to determine header note
21+
if ${JQ} -e '.configurations.old' ${TMPFILE} > /dev/null 2>&1; then
22+
old_profile_note=""
23+
else
24+
old_profile_note="
25+
// NOTE: The \"old\" profile is preserved from Mozilla v5.7 for backwards compatibility,
26+
// as it was removed from Mozilla guidelines v${version}."
27+
fi
28+
2029
cat > ${OUTPUT} <<EOF
2130
package tlsprofiles
2231
2332
// DO NOT EDIT, GENERATED BY ${0}
2433
// DATA SOURCE: ${INPUT}
25-
// DATA VERSION: ${version}
34+
// DATA VERSION: ${version}${old_profile_note}
2635
2736
import (
2837
"crypto/tls"
@@ -38,7 +47,7 @@ cipherNums: []uint16{
3847
EOF
3948

4049
${JQ} -r ".configurations.$1.ciphersuites.[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT}
41-
${JQ} -r ".configurations.$1.ciphers.go[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT}
50+
${JQ} -r ".configurations.$1.ciphers.iana[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT}
4251

4352
cat >> ${OUTPUT} <<EOF
4453
},
@@ -63,7 +72,51 @@ EOF
6372

6473
generate_profile "modern"
6574
generate_profile "intermediate"
66-
generate_profile "old"
75+
# Only generate old profile if it exists in the guidelines
76+
if ${JQ} -e '.configurations.old' ${TMPFILE} > /dev/null 2>&1; then
77+
generate_profile "old"
78+
else
79+
# Old profile removed from Mozilla guidelines v6.0
80+
# Preserving v5.7 definition for backwards compatibility
81+
cat >> ${OUTPUT} <<'EOF'
82+
83+
var oldTLSProfile = tlsProfile{
84+
ciphers: cipherSlice{
85+
cipherNums: []uint16{
86+
tls.TLS_AES_128_GCM_SHA256,
87+
tls.TLS_AES_256_GCM_SHA384,
88+
tls.TLS_CHACHA20_POLY1305_SHA256,
89+
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
90+
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
91+
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
92+
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
93+
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
94+
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
95+
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
96+
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
97+
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
98+
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
99+
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
100+
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
101+
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
102+
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
103+
tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
104+
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
105+
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
106+
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
107+
},
108+
},
109+
curves: curveSlice{
110+
curveNums: []tls.CurveID{
111+
X25519,
112+
prime256v1,
113+
secp384r1,
114+
},
115+
},
116+
minTLSVersion: tls.VersionTLS10,
117+
}
118+
EOF
119+
fi
67120

68121
# Make go happy
69122
go fmt ${OUTPUT}

internal/shared/util/tlsprofiles/mozilla_data.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package tlsprofiles
22

33
// DO NOT EDIT, GENERATED BY hack/tools/update-tls-profiles.sh
44
// DATA SOURCE: https://ssl-config.mozilla.org/guidelines/latest.json
5-
// DATA VERSION: 5.7
5+
// DATA VERSION: 6
6+
// NOTE: The "old" profile is preserved from Mozilla v5.7 for backwards compatibility,
7+
// as it was removed from Mozilla guidelines v6.0.
68

79
import (
810
"crypto/tls"
@@ -18,6 +20,7 @@ var modernTLSProfile = tlsProfile{
1820
},
1921
curves: curveSlice{
2022
curveNums: []tls.CurveID{
23+
X25519MLKEM768,
2124
X25519,
2225
prime256v1,
2326
secp384r1,
@@ -36,12 +39,13 @@ var intermediateTLSProfile = tlsProfile{
3639
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
3740
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
3841
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
39-
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
40-
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
42+
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
43+
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
4144
},
4245
},
4346
curves: curveSlice{
4447
curveNums: []tls.CurveID{
48+
X25519MLKEM768,
4549
X25519,
4650
prime256v1,
4751
secp384r1,

internal/shared/util/tlsprofiles/tlsprofiles.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,19 @@ func cipherSuiteId(name string) uint16 {
6969

7070
// This is primarily so that we don't have to rewrite curve values in mozilla_data.go
7171
const (
72-
X25519 tls.CurveID = tls.X25519
73-
prime256v1 tls.CurveID = tls.CurveP256
74-
secp384r1 tls.CurveID = tls.CurveP384
75-
secp521r1 tls.CurveID = tls.CurveP521
72+
X25519MLKEM768 tls.CurveID = tls.X25519MLKEM768
73+
X25519 tls.CurveID = tls.X25519
74+
prime256v1 tls.CurveID = tls.CurveP256
75+
secp384r1 tls.CurveID = tls.CurveP384
76+
secp521r1 tls.CurveID = tls.CurveP521
7677
)
7778

7879
var curves = map[string]tls.CurveID{
79-
"X25519": tls.X25519,
80-
"prime256v1": tls.CurveP256,
81-
"secp384r1": tls.CurveP384,
82-
"secp521r1": tls.CurveP521,
80+
"X25519MLKEM768": tls.X25519MLKEM768,
81+
"X25519": tls.X25519,
82+
"prime256v1": tls.CurveP256,
83+
"secp384r1": tls.CurveP384,
84+
"secp521r1": tls.CurveP521,
8385
}
8486

8587
// Returns 0 for an invalid curve name

internal/shared/util/tlsprofiles/tlsprofiles_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ func TestSetCustomCurves(t *testing.T) {
114114
name string
115115
result bool
116116
}{
117+
{"X25519MLKEM768", true},
117118
{"X25519", true},
118119
{"prime256v1", true},
119120
{"secp384r1", true},
120121
{"secp521r1", true},
121122
{"unknown-cuve", false},
122-
{"X448", false}, // Valid OpenSSL curve, not implemented
123-
{"X25519,prime256v1", true}, // Multiple
123+
{"X448", false}, // Valid OpenSSL curve, not implemented
124+
{"X25519,prime256v1", true}, // Multiple
125+
{"X25519MLKEM768,X25519,prime256v1", true}, // Multiple with new curve
124126
}
125127

126128
for _, test := range tests {
@@ -158,3 +160,33 @@ func TestSetCustomVersion(t *testing.T) {
158160
}
159161
}
160162
}
163+
164+
func TestModernProfileContents(t *testing.T) {
165+
// Verify modern profile contains X25519MLKEM768 (new in Mozilla v6.0)
166+
require.Contains(t, modernTLSProfile.curves.curveNums, X25519MLKEM768, "modern profile should include X25519MLKEM768 curve")
167+
require.Contains(t, modernTLSProfile.curves.curveNums, X25519, "modern profile should include X25519 curve")
168+
169+
// Verify modern profile ciphers
170+
require.NotEmpty(t, modernTLSProfile.ciphers.cipherNums, "modern profile should have ciphers")
171+
require.Equal(t, uint16(0x1301), modernTLSProfile.ciphers.cipherNums[0], "first cipher should be TLS_AES_128_GCM_SHA256")
172+
}
173+
174+
func TestIntermediateProfileContents(t *testing.T) {
175+
// Verify intermediate profile contains X25519MLKEM768 (new in Mozilla v6.0)
176+
require.Contains(t, intermediateTLSProfile.curves.curveNums, X25519MLKEM768, "intermediate profile should include X25519MLKEM768 curve")
177+
require.Contains(t, intermediateTLSProfile.curves.curveNums, X25519, "intermediate profile should include X25519 curve")
178+
179+
// Verify intermediate profile has TLS 1.2 ciphers
180+
require.NotEmpty(t, intermediateTLSProfile.ciphers.cipherNums, "intermediate profile should have ciphers")
181+
require.Greater(t, len(intermediateTLSProfile.ciphers.cipherNums), len(modernTLSProfile.ciphers.cipherNums), "intermediate profile should have more ciphers than modern")
182+
}
183+
184+
func TestOldProfileContents(t *testing.T) {
185+
// Verify old profile is preserved from Mozilla v5.7 (does NOT include X25519MLKEM768)
186+
require.NotContains(t, oldTLSProfile.curves.curveNums, X25519MLKEM768, "old profile should NOT include X25519MLKEM768 (preserved from v5.7)")
187+
require.Contains(t, oldTLSProfile.curves.curveNums, X25519, "old profile should include X25519 curve")
188+
189+
// Verify old profile has legacy ciphers
190+
require.NotEmpty(t, oldTLSProfile.ciphers.cipherNums, "old profile should have ciphers")
191+
require.Greater(t, len(oldTLSProfile.ciphers.cipherNums), len(intermediateTLSProfile.ciphers.cipherNums), "old profile should have more ciphers than intermediate")
192+
}

0 commit comments

Comments
 (0)