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