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