Source file
src/crypto/tls/defaults.go
1
2
3
4
5 package tls
6
7 import (
8 "internal/godebug"
9 "slices"
10 _ "unsafe"
11 )
12
13
14
15
16
17 var tlsmlkem = godebug.New("tlsmlkem")
18
19
20 var tlssecpmlkem = godebug.New("tlssecpmlkem")
21
22
23
24
25 var tlsechgrease = godebug.New("tlsechgrease")
26
27
28 func defaultCurveEnabled(c CurveID) bool {
29 switch c {
30 case X25519, CurveP256, CurveP384, CurveP521:
31 return true
32 case X25519MLKEM768:
33 return tlsmlkem.Value() != "0"
34 case SecP256r1MLKEM768, SecP384r1MLKEM1024:
35 return tlsmlkem.Value() != "0" && tlssecpmlkem.Value() != "0"
36 default:
37 return false
38 }
39 }
40
41
42
43 func curvePreferenceOrder() []CurveID {
44 return []CurveID{
45 X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024, MLKEM1024,
46 X25519, CurveP256, CurveP384, CurveP521,
47 }
48 }
49
50
51
52
53
54 func defaultSupportedSignatureAlgorithms() []SignatureScheme {
55 return []SignatureScheme{
56 MLDSA44,
57 MLDSA65,
58 MLDSA87,
59 PSSWithSHA256,
60 ECDSAWithP256AndSHA256,
61 Ed25519,
62 PSSWithSHA384,
63 PSSWithSHA512,
64 PKCS1WithSHA256,
65 PKCS1WithSHA384,
66 PKCS1WithSHA512,
67 ECDSAWithP384AndSHA384,
68 ECDSAWithP521AndSHA512,
69 PKCS1WithSHA1,
70 ECDSAWithSHA1,
71 }
72 }
73
74 func supportedCipherSuites(aesGCMPreferred bool) []uint16 {
75 if aesGCMPreferred {
76 return slices.Clone(cipherSuitesPreferenceOrder)
77 } else {
78 return slices.Clone(cipherSuitesPreferenceOrderNoAES)
79 }
80 }
81
82 func defaultCipherSuites(aesGCMPreferred bool) []uint16 {
83 cipherSuites := supportedCipherSuites(aesGCMPreferred)
84 return slices.DeleteFunc(cipherSuites, func(c uint16) bool {
85 return disabledCipherSuites[c]
86 })
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 var defaultCipherSuitesTLS13 = []uint16{
104 TLS_AES_128_GCM_SHA256,
105 TLS_AES_256_GCM_SHA384,
106 TLS_CHACHA20_POLY1305_SHA256,
107 }
108
109
110
111
112
113
114
115
116
117
118
119 var defaultCipherSuitesTLS13NoAES = []uint16{
120 TLS_CHACHA20_POLY1305_SHA256,
121 TLS_AES_128_GCM_SHA256,
122 TLS_AES_256_GCM_SHA384,
123 }
124
View as plain text