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