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