@@ -25,31 +25,6 @@ import (
25
25
"time"
26
26
)
27
27
28
- func allCipherSuitesIncludingTLS13 () []uint16 {
29
- s := allCipherSuites ()
30
- for _ , suite := range cipherSuitesTLS13 {
31
- s = append (s , suite .id )
32
- }
33
- return s
34
- }
35
-
36
- func isTLS13CipherSuite (id uint16 ) bool {
37
- for _ , suite := range cipherSuitesTLS13 {
38
- if id == suite .id {
39
- return true
40
- }
41
- }
42
- return false
43
- }
44
-
45
- func generateKeyShare (group CurveID ) keyShare {
46
- key , err := generateECDHEKey (rand .Reader , group )
47
- if err != nil {
48
- panic (err )
49
- }
50
- return keyShare {group : group , data : key .PublicKey ().Bytes ()}
51
- }
52
-
53
28
func TestBoringServerProtocolVersion (t * testing.T ) {
54
29
test := func (name string , v uint16 , msg string ) {
55
30
t .Run (name , func (t * testing.T ) {
@@ -58,11 +33,8 @@ func TestBoringServerProtocolVersion(t *testing.T) {
58
33
clientHello := & clientHelloMsg {
59
34
vers : v ,
60
35
random : make ([]byte , 32 ),
61
- cipherSuites : allCipherSuitesIncludingTLS13 (),
36
+ cipherSuites : allCipherSuites (),
62
37
compressionMethods : []uint8 {compressionNone },
63
- supportedCurves : defaultCurvePreferences ,
64
- keyShares : []keyShare {generateKeyShare (CurveP256 )},
65
- supportedPoints : []uint8 {pointFormatUncompressed },
66
38
supportedVersions : []uint16 {v },
67
39
}
68
40
testClientHelloFailure (t , serverConfig , clientHello , msg )
@@ -76,33 +48,33 @@ func TestBoringServerProtocolVersion(t *testing.T) {
76
48
77
49
fipstls .Force ()
78
50
defer fipstls .Abandon ()
79
- test ("VersionSSL30/fipstls " , VersionSSL30 , "client offered only unsupported versions" )
80
- test ("VersionTLS10/fipstls " , VersionTLS10 , "client offered only unsupported versions" )
81
- test ("VersionTLS11/fipstls " , VersionTLS11 , "client offered only unsupported versions" )
82
- test ("VersionTLS12/fipstls " , VersionTLS12 , "" )
83
- test ("VersionTLS13/fipstls " , VersionTLS13 , "" )
51
+ test ("VersionSSL30" , VersionSSL30 , "client offered only unsupported versions" )
52
+ test ("VersionTLS10" , VersionTLS10 , "client offered only unsupported versions" )
53
+ test ("VersionTLS11" , VersionTLS11 , "client offered only unsupported versions" )
54
+ test ("VersionTLS12" , VersionTLS12 , "" )
55
+ test ("VersionTLS13" , VersionTLS13 , "client offered only unsupported versions " )
84
56
}
85
57
86
58
func isBoringVersion (v uint16 ) bool {
87
- return v == VersionTLS12 || v == VersionTLS13
59
+ return v == VersionTLS12
88
60
}
89
61
90
62
func isBoringCipherSuite (id uint16 ) bool {
91
63
switch id {
92
- case TLS_AES_128_GCM_SHA256 ,
93
- TLS_AES_256_GCM_SHA384 ,
94
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,
64
+ case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,
95
65
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,
96
66
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 ,
97
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :
67
+ TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 ,
68
+ TLS_RSA_WITH_AES_128_GCM_SHA256 ,
69
+ TLS_RSA_WITH_AES_256_GCM_SHA384 :
98
70
return true
99
71
}
100
72
return false
101
73
}
102
74
103
75
func isBoringCurve (id CurveID ) bool {
104
76
switch id {
105
- case CurveP256 , CurveP384 :
77
+ case CurveP256 , CurveP384 , CurveP521 :
106
78
return true
107
79
}
108
80
return false
@@ -114,7 +86,7 @@ func isECDSA(id uint16) bool {
114
86
return suite .flags & suiteECSign == suiteECSign
115
87
}
116
88
}
117
- return false // TLS 1.3 cipher suites are not tied to the signature algorithm.
89
+ panic ( fmt . Sprintf ( "unknown cipher suite %#x" , id ))
118
90
}
119
91
120
92
func isBoringSignatureScheme (alg SignatureScheme ) bool {
@@ -126,6 +98,7 @@ func isBoringSignatureScheme(alg SignatureScheme) bool {
126
98
PKCS1WithSHA384 ,
127
99
ECDSAWithP384AndSHA384 ,
128
100
PKCS1WithSHA512 ,
101
+ ECDSAWithP521AndSHA512 ,
129
102
PSSWithSHA256 ,
130
103
PSSWithSHA384 ,
131
104
PSSWithSHA512 :
@@ -136,9 +109,10 @@ func isBoringSignatureScheme(alg SignatureScheme) bool {
136
109
137
110
func TestBoringServerCipherSuites (t * testing.T ) {
138
111
serverConfig := testConfig .Clone ()
112
+ serverConfig .CipherSuites = allCipherSuites ()
139
113
serverConfig .Certificates = make ([]Certificate , 1 )
140
114
141
- for _ , id := range allCipherSuitesIncludingTLS13 () {
115
+ for _ , id := range allCipherSuites () {
142
116
if isECDSA (id ) {
143
117
serverConfig .Certificates [0 ].Certificate = [][]byte {testECDSACertificate }
144
118
serverConfig .Certificates [0 ].PrivateKey = testECDSAPrivateKey
@@ -147,19 +121,14 @@ func TestBoringServerCipherSuites(t *testing.T) {
147
121
serverConfig .Certificates [0 ].PrivateKey = testRSAPrivateKey
148
122
}
149
123
serverConfig .BuildNameToCertificate ()
150
- t .Run (fmt .Sprintf ("suite=%s " , CipherSuiteName ( id ) ), func (t * testing.T ) {
124
+ t .Run (fmt .Sprintf ("suite=%#x " , id ), func (t * testing.T ) {
151
125
clientHello := & clientHelloMsg {
152
126
vers : VersionTLS12 ,
153
127
random : make ([]byte , 32 ),
154
128
cipherSuites : []uint16 {id },
155
129
compressionMethods : []uint8 {compressionNone },
156
130
supportedCurves : defaultCurvePreferences ,
157
- keyShares : []keyShare {generateKeyShare (CurveP256 )},
158
131
supportedPoints : []uint8 {pointFormatUncompressed },
159
- supportedVersions : []uint16 {VersionTLS12 },
160
- }
161
- if isTLS13CipherSuite (id ) {
162
- clientHello .supportedVersions = []uint16 {VersionTLS13 }
163
132
}
164
133
165
134
testClientHello (t , serverConfig , clientHello )
@@ -191,9 +160,7 @@ func TestBoringServerCurves(t *testing.T) {
191
160
cipherSuites : []uint16 {TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 },
192
161
compressionMethods : []uint8 {compressionNone },
193
162
supportedCurves : []CurveID {curveid },
194
- keyShares : []keyShare {generateKeyShare (curveid )},
195
163
supportedPoints : []uint8 {pointFormatUncompressed },
196
- supportedVersions : []uint16 {VersionTLS12 },
197
164
}
198
165
199
166
testClientHello (t , serverConfig , clientHello )
@@ -312,7 +279,7 @@ func TestBoringClientHello(t *testing.T) {
312
279
}
313
280
314
281
if ! isBoringVersion (hello .vers ) {
315
- t .Errorf ("client vers=%#x" , hello .vers )
282
+ t .Errorf ("client vers=%#x, want %#x (TLS 1.2) " , hello .vers , VersionTLS12 )
316
283
}
317
284
for _ , v := range hello .supportedVersions {
318
285
if ! isBoringVersion (v ) {
0 commit comments