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 func defaultCurveEnabled(c CurveID) bool {
24 switch c {
25 case X25519, CurveP256, CurveP384, CurveP521:
26 return true
27 case X25519MLKEM768:
28 return tlsmlkem.Value() != "0"
29 case SecP256r1MLKEM768, SecP384r1MLKEM1024:
30 return tlsmlkem.Value() != "0" && tlssecpmlkem.Value() != "0"
31 default:
32 return false
33 }
34 }
35
36
37
38 func curvePreferenceOrder() []CurveID {
39 return []CurveID{
40 X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024, MLKEM1024,
41 X25519, CurveP256, CurveP384, CurveP521,
42 }
43 }
44
45
46
47
48
49 func defaultSupportedSignatureAlgorithms() []SignatureScheme {
50 return []SignatureScheme{
51 MLDSA44,
52 MLDSA65,
53 MLDSA87,
54 PSSWithSHA256,
55 ECDSAWithP256AndSHA256,
56 Ed25519,
57 PSSWithSHA384,
58 PSSWithSHA512,
59 PKCS1WithSHA256,
60 PKCS1WithSHA384,
61 PKCS1WithSHA512,
62 ECDSAWithP384AndSHA384,
63 ECDSAWithP521AndSHA512,
64 PKCS1WithSHA1,
65 ECDSAWithSHA1,
66 }
67 }
68
69 func supportedCipherSuites(aesGCMPreferred bool) []uint16 {
70 if aesGCMPreferred {
71 return slices.Clone(cipherSuitesPreferenceOrder)
72 } else {
73 return slices.Clone(cipherSuitesPreferenceOrderNoAES)
74 }
75 }
76
77 func defaultCipherSuites(aesGCMPreferred bool) []uint16 {
78 cipherSuites := supportedCipherSuites(aesGCMPreferred)
79 return slices.DeleteFunc(cipherSuites, func(c uint16) bool {
80 return disabledCipherSuites[c]
81 })
82 }
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 var defaultCipherSuitesTLS13 = []uint16{
99 TLS_AES_128_GCM_SHA256,
100 TLS_AES_256_GCM_SHA384,
101 TLS_CHACHA20_POLY1305_SHA256,
102 }
103
104
105
106
107
108
109
110
111
112
113
114 var defaultCipherSuitesTLS13NoAES = []uint16{
115 TLS_CHACHA20_POLY1305_SHA256,
116 TLS_AES_128_GCM_SHA256,
117 TLS_AES_256_GCM_SHA384,
118 }
119
View as plain text