Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 21 | "crypto/x509" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 22 | "encoding/base64" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 23 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 24 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 25 | "flag" |
| 26 | "fmt" |
| 27 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 28 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 29 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 30 | "net" |
| 31 | "os" |
| 32 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 33 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 34 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 35 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 36 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 37 | "strings" |
| 38 | "sync" |
| 39 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 40 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 41 | ) |
| 42 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 43 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 44 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 45 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 46 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 47 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 48 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 49 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask bssl_shim to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
| 50 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 51 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 52 | testToRun = flag.String("test", "", "The pattern to filter tests to run, or empty to run all tests") |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 53 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 54 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 55 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 56 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 57 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 58 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 59 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 60 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 61 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 62 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 63 | type testCert int |
| 64 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 65 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 66 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 67 | testCertRSA1024 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 68 | testCertECDSAP256 |
| 69 | testCertECDSAP384 |
| 70 | testCertECDSAP521 |
| 71 | ) |
| 72 | |
| 73 | const ( |
| 74 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 75 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 76 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 77 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 78 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 79 | ) |
| 80 | |
| 81 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 82 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 83 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 84 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 85 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 86 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 87 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 88 | ) |
| 89 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 90 | var ( |
| 91 | rsaCertificate Certificate |
| 92 | rsa1024Certificate Certificate |
| 93 | ecdsaP256Certificate Certificate |
| 94 | ecdsaP384Certificate Certificate |
| 95 | ecdsaP521Certificate Certificate |
| 96 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 97 | |
| 98 | var testCerts = []struct { |
| 99 | id testCert |
| 100 | certFile, keyFile string |
| 101 | cert *Certificate |
| 102 | }{ |
| 103 | { |
| 104 | id: testCertRSA, |
| 105 | certFile: rsaCertificateFile, |
| 106 | keyFile: rsaKeyFile, |
| 107 | cert: &rsaCertificate, |
| 108 | }, |
| 109 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 110 | id: testCertRSA1024, |
| 111 | certFile: rsa1024CertificateFile, |
| 112 | keyFile: rsa1024KeyFile, |
| 113 | cert: &rsa1024Certificate, |
| 114 | }, |
| 115 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 116 | id: testCertECDSAP256, |
| 117 | certFile: ecdsaP256CertificateFile, |
| 118 | keyFile: ecdsaP256KeyFile, |
| 119 | cert: &ecdsaP256Certificate, |
| 120 | }, |
| 121 | { |
| 122 | id: testCertECDSAP384, |
| 123 | certFile: ecdsaP384CertificateFile, |
| 124 | keyFile: ecdsaP384KeyFile, |
| 125 | cert: &ecdsaP384Certificate, |
| 126 | }, |
| 127 | { |
| 128 | id: testCertECDSAP521, |
| 129 | certFile: ecdsaP521CertificateFile, |
| 130 | keyFile: ecdsaP521KeyFile, |
| 131 | cert: &ecdsaP521Certificate, |
| 132 | }, |
| 133 | } |
| 134 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 135 | var channelIDKey *ecdsa.PrivateKey |
| 136 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 137 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 138 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 139 | var testSCTList = []byte{5, 6, 7, 8} |
| 140 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 141 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 142 | for i := range testCerts { |
| 143 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 144 | if err != nil { |
| 145 | panic(err) |
| 146 | } |
| 147 | cert.OCSPStaple = testOCSPResponse |
| 148 | cert.SignedCertificateTimestampList = testSCTList |
| 149 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 150 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 151 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 152 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 153 | if err != nil { |
| 154 | panic(err) |
| 155 | } |
| 156 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 157 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 158 | panic("bad key type") |
| 159 | } |
| 160 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 161 | if err != nil { |
| 162 | panic(err) |
| 163 | } |
| 164 | if channelIDKey.Curve != elliptic.P256() { |
| 165 | panic("bad curve") |
| 166 | } |
| 167 | |
| 168 | channelIDBytes = make([]byte, 64) |
| 169 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 170 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 171 | } |
| 172 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 173 | func getRunnerCertificate(t testCert) Certificate { |
| 174 | for _, cert := range testCerts { |
| 175 | if cert.id == t { |
| 176 | return *cert.cert |
| 177 | } |
| 178 | } |
| 179 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 180 | } |
| 181 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 182 | func getShimCertificate(t testCert) string { |
| 183 | for _, cert := range testCerts { |
| 184 | if cert.id == t { |
| 185 | return cert.certFile |
| 186 | } |
| 187 | } |
| 188 | panic("Unknown test certificate") |
| 189 | } |
| 190 | |
| 191 | func getShimKey(t testCert) string { |
| 192 | for _, cert := range testCerts { |
| 193 | if cert.id == t { |
| 194 | return cert.keyFile |
| 195 | } |
| 196 | } |
| 197 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 198 | } |
| 199 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 200 | type testType int |
| 201 | |
| 202 | const ( |
| 203 | clientTest testType = iota |
| 204 | serverTest |
| 205 | ) |
| 206 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 207 | type protocol int |
| 208 | |
| 209 | const ( |
| 210 | tls protocol = iota |
| 211 | dtls |
| 212 | ) |
| 213 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 214 | const ( |
| 215 | alpn = 1 |
| 216 | npn = 2 |
| 217 | ) |
| 218 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 219 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 220 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 221 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 222 | name string |
| 223 | config Config |
| 224 | shouldFail bool |
| 225 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 226 | // expectedLocalError, if not empty, contains a substring that must be |
| 227 | // found in the local error. |
| 228 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 229 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 230 | // negotiated. |
| 231 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 232 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 233 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 234 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 235 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 236 | // should be negotiated. |
| 237 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 238 | // expectChannelID controls whether the connection should have |
| 239 | // negotiated a Channel ID with channelIDKey. |
| 240 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 241 | // expectedNextProto controls whether the connection should |
| 242 | // negotiate a next protocol via NPN or ALPN. |
| 243 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 244 | // expectNoNextProto, if true, means that no next protocol should be |
| 245 | // negotiated. |
| 246 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 247 | // expectedNextProtoType, if non-zero, is the expected next |
| 248 | // protocol negotiation mechanism. |
| 249 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 250 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 251 | // should be negotiated. If zero, none should be negotiated. |
| 252 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 253 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 254 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 255 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 256 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 257 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 258 | // algorithm that the peer should have used in the handshake. |
| 259 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 260 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 261 | // have used. |
| 262 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 263 | // messageLen is the length, in bytes, of the test message that will be |
| 264 | // sent. |
| 265 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 266 | // messageCount is the number of test messages that will be sent. |
| 267 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 268 | // certFile is the path to the certificate to use for the server. |
| 269 | certFile string |
| 270 | // keyFile is the path to the private key to use for the server. |
| 271 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 272 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 273 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 274 | resumeSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 275 | // expectResumeRejected, if true, specifies that the attempted |
| 276 | // resumption must be rejected by the client. This is only valid for a |
| 277 | // serverTest. |
| 278 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 279 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 280 | // resumption. Unless newSessionsOnResume is set, |
| 281 | // SessionTicketKey, ServerSessionCache, and |
| 282 | // ClientSessionCache are copied from the initial connection's |
| 283 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 284 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 285 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 286 | // use a different session resumption context. |
| 287 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 288 | // noSessionCache, if true, will cause the server to run without a |
| 289 | // session cache. |
| 290 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 291 | // sendPrefix sends a prefix on the socket before actually performing a |
| 292 | // handshake. |
| 293 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 294 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 295 | // message before doing a roundtrip with the runner. |
| 296 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 297 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 298 | // connection immediately after the handshake rather than echoing |
| 299 | // messages from the runner. |
| 300 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 301 | // renegotiate indicates the number of times the connection should be |
| 302 | // renegotiated during the exchange. |
| 303 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 304 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 305 | // HelloRequest when the handshake completes. |
| 306 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 307 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 308 | // switched in just before renegotiation. |
| 309 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 310 | // replayWrites, if true, configures the underlying transport |
| 311 | // to replay every write it makes in DTLS tests. |
| 312 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 313 | // damageFirstWrite, if true, configures the underlying transport to |
| 314 | // damage the final byte of the first application data write. |
| 315 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 316 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 317 | // keying material and verify they match. |
| 318 | exportKeyingMaterial int |
| 319 | exportLabel string |
| 320 | exportContext string |
| 321 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 322 | // flags, if not empty, contains a list of command-line flags that will |
| 323 | // be passed to the shim program. |
| 324 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 325 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 326 | // which will be compared against the expected value. |
| 327 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 328 | // sendEmptyRecords is the number of consecutive empty records to send |
| 329 | // before and after the test message. |
| 330 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 331 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 332 | // before and after the test message. |
| 333 | sendWarningAlerts int |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 334 | // expectMessageDropped, if true, means the test message is expected to |
| 335 | // be dropped by the client rather than echoed back. |
| 336 | expectMessageDropped bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 339 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 340 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 341 | func writeTranscript(test *testCase, isResume bool, data []byte) { |
| 342 | if len(data) == 0 { |
| 343 | return |
| 344 | } |
| 345 | |
| 346 | protocol := "tls" |
| 347 | if test.protocol == dtls { |
| 348 | protocol = "dtls" |
| 349 | } |
| 350 | |
| 351 | side := "client" |
| 352 | if test.testType == serverTest { |
| 353 | side = "server" |
| 354 | } |
| 355 | |
| 356 | dir := path.Join(*transcriptDir, protocol, side) |
| 357 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 358 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 359 | return |
| 360 | } |
| 361 | |
| 362 | name := test.name |
| 363 | if isResume { |
| 364 | name += "-Resume" |
| 365 | } else { |
| 366 | name += "-Normal" |
| 367 | } |
| 368 | |
| 369 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 370 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 371 | } |
| 372 | } |
| 373 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 374 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 375 | type timeoutConn struct { |
| 376 | net.Conn |
| 377 | timeout time.Duration |
| 378 | } |
| 379 | |
| 380 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 381 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 382 | return 0, err |
| 383 | } |
| 384 | return t.Conn.Read(b) |
| 385 | } |
| 386 | |
| 387 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 388 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 389 | return 0, err |
| 390 | } |
| 391 | return t.Conn.Write(b) |
| 392 | } |
| 393 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 394 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool) error { |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 395 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 396 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 397 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 398 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 399 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 400 | } |
| 401 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 402 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 403 | local, peer := "client", "server" |
| 404 | if test.testType == clientTest { |
| 405 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 406 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 407 | connDebug := &recordingConn{ |
| 408 | Conn: conn, |
| 409 | isDatagram: test.protocol == dtls, |
| 410 | local: local, |
| 411 | peer: peer, |
| 412 | } |
| 413 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 414 | if *flagDebug { |
| 415 | defer connDebug.WriteTo(os.Stdout) |
| 416 | } |
| 417 | if len(*transcriptDir) != 0 { |
| 418 | defer func() { |
| 419 | writeTranscript(test, isResume, connDebug.Transcript()) |
| 420 | }() |
| 421 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 422 | |
| 423 | if config.Bugs.PacketAdaptor != nil { |
| 424 | config.Bugs.PacketAdaptor.debug = connDebug |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | if test.replayWrites { |
| 429 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 430 | } |
| 431 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 432 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 433 | if test.damageFirstWrite { |
| 434 | connDamage = newDamageAdaptor(conn) |
| 435 | conn = connDamage |
| 436 | } |
| 437 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 438 | if test.sendPrefix != "" { |
| 439 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 440 | return err |
| 441 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 442 | } |
| 443 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 444 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 445 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 446 | if test.protocol == dtls { |
| 447 | tlsConn = DTLSServer(conn, config) |
| 448 | } else { |
| 449 | tlsConn = Server(conn, config) |
| 450 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 451 | } else { |
| 452 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 453 | if test.protocol == dtls { |
| 454 | tlsConn = DTLSClient(conn, config) |
| 455 | } else { |
| 456 | tlsConn = Client(conn, config) |
| 457 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 458 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 459 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 460 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 461 | if err := tlsConn.Handshake(); err != nil { |
| 462 | return err |
| 463 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 464 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 465 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 466 | // expectations struct that can be specified separately for the two |
| 467 | // legs. |
| 468 | expectedVersion := test.expectedVersion |
| 469 | if isResume && test.expectedResumeVersion != 0 { |
| 470 | expectedVersion = test.expectedResumeVersion |
| 471 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 472 | connState := tlsConn.ConnectionState() |
| 473 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 474 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 475 | } |
| 476 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 477 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 478 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 479 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 480 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 481 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 482 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 483 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 484 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 485 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 486 | if channelID == nil { |
| 487 | return fmt.Errorf("no channel ID negotiated") |
| 488 | } |
| 489 | if channelID.Curve != channelIDKey.Curve || |
| 490 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 491 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 492 | return fmt.Errorf("incorrect channel ID") |
| 493 | } |
| 494 | } |
| 495 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 496 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 497 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 498 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 499 | } |
| 500 | } |
| 501 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 502 | if test.expectNoNextProto { |
| 503 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 504 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 505 | } |
| 506 | } |
| 507 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 508 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 509 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 510 | return fmt.Errorf("next proto type mismatch") |
| 511 | } |
| 512 | } |
| 513 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 514 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 515 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 516 | } |
| 517 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 518 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 519 | return fmt.Errorf("OCSP Response mismatch: got %x, wanted %x", tlsConn.OCSPResponse(), test.expectedOCSPResponse) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 520 | } |
| 521 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 522 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 523 | return fmt.Errorf("SCT list mismatch") |
| 524 | } |
| 525 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 526 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 527 | return fmt.Errorf("expected peer to use signature algorithm %04x, but got %04x", expected, connState.PeerSignatureAlgorithm) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 528 | } |
| 529 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 530 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 531 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 532 | } |
| 533 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 534 | if test.exportKeyingMaterial > 0 { |
| 535 | actual := make([]byte, test.exportKeyingMaterial) |
| 536 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 537 | return err |
| 538 | } |
| 539 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 540 | if err != nil { |
| 541 | return err |
| 542 | } |
| 543 | if !bytes.Equal(actual, expected) { |
| 544 | return fmt.Errorf("keying material mismatch") |
| 545 | } |
| 546 | } |
| 547 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 548 | if test.testTLSUnique { |
| 549 | var peersValue [12]byte |
| 550 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 551 | return err |
| 552 | } |
| 553 | expected := tlsConn.ConnectionState().TLSUnique |
| 554 | if !bytes.Equal(peersValue[:], expected) { |
| 555 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 556 | } |
| 557 | } |
| 558 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 559 | if test.shimWritesFirst { |
| 560 | var buf [5]byte |
| 561 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 562 | if err != nil { |
| 563 | return err |
| 564 | } |
| 565 | if string(buf[:]) != "hello" { |
| 566 | return fmt.Errorf("bad initial message") |
| 567 | } |
| 568 | } |
| 569 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 570 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 571 | tlsConn.Write(nil) |
| 572 | } |
| 573 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 574 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 575 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 576 | } |
| 577 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 578 | if test.sendHalfHelloRequest { |
| 579 | tlsConn.SendHalfHelloRequest() |
| 580 | } |
| 581 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 582 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 583 | if test.renegotiateCiphers != nil { |
| 584 | config.CipherSuites = test.renegotiateCiphers |
| 585 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 586 | for i := 0; i < test.renegotiate; i++ { |
| 587 | if err := tlsConn.Renegotiate(); err != nil { |
| 588 | return err |
| 589 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 590 | } |
| 591 | } else if test.renegotiateCiphers != nil { |
| 592 | panic("renegotiateCiphers without renegotiate") |
| 593 | } |
| 594 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 595 | if test.damageFirstWrite { |
| 596 | connDamage.setDamage(true) |
| 597 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 598 | connDamage.setDamage(false) |
| 599 | } |
| 600 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 601 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 602 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 603 | if test.protocol == dtls { |
| 604 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 605 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 606 | // Read until EOF. |
| 607 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 608 | return err |
| 609 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 610 | if messageLen == 0 { |
| 611 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 612 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 613 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 614 | messageCount := test.messageCount |
| 615 | if messageCount == 0 { |
| 616 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 617 | } |
| 618 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 619 | for j := 0; j < messageCount; j++ { |
| 620 | testMessage := make([]byte, messageLen) |
| 621 | for i := range testMessage { |
| 622 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 623 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 624 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 625 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 626 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 627 | tlsConn.Write(nil) |
| 628 | } |
| 629 | |
| 630 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 631 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 632 | } |
| 633 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 634 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 635 | // The shim will not respond. |
| 636 | continue |
| 637 | } |
| 638 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 639 | buf := make([]byte, len(testMessage)) |
| 640 | if test.protocol == dtls { |
| 641 | bufTmp := make([]byte, len(buf)+1) |
| 642 | n, err := tlsConn.Read(bufTmp) |
| 643 | if err != nil { |
| 644 | return err |
| 645 | } |
| 646 | if n != len(buf) { |
| 647 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 648 | } |
| 649 | copy(buf, bufTmp) |
| 650 | } else { |
| 651 | _, err := io.ReadFull(tlsConn, buf) |
| 652 | if err != nil { |
| 653 | return err |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | for i, v := range buf { |
| 658 | if v != testMessage[i]^0xff { |
| 659 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 660 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 661 | } |
| 662 | } |
| 663 | |
| 664 | return nil |
| 665 | } |
| 666 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 667 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
| 668 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 669 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 670 | valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 671 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 672 | valgrindArgs = append(valgrindArgs, path) |
| 673 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 674 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 675 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 676 | } |
| 677 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 678 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 679 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 680 | xtermArgs = append(xtermArgs, path) |
| 681 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 682 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 683 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 684 | } |
| 685 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 686 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 687 | xtermArgs := []string{"-e", "lldb", "--"} |
| 688 | xtermArgs = append(xtermArgs, path) |
| 689 | xtermArgs = append(xtermArgs, args...) |
| 690 | |
| 691 | return exec.Command("xterm", xtermArgs...) |
| 692 | } |
| 693 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 694 | var ( |
| 695 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 696 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 697 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 698 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 699 | // accept accepts a connection from listener, unless waitChan signals a process |
| 700 | // exit first. |
| 701 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 702 | type connOrError struct { |
| 703 | conn net.Conn |
| 704 | err error |
| 705 | } |
| 706 | connChan := make(chan connOrError, 1) |
| 707 | go func() { |
| 708 | conn, err := listener.Accept() |
| 709 | connChan <- connOrError{conn, err} |
| 710 | close(connChan) |
| 711 | }() |
| 712 | select { |
| 713 | case result := <-connChan: |
| 714 | return result.conn, result.err |
| 715 | case childErr := <-waitChan: |
| 716 | waitChan <- childErr |
| 717 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 718 | } |
| 719 | } |
| 720 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 721 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 722 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 723 | panic("Error expected without shouldFail in " + test.name) |
| 724 | } |
| 725 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 726 | if test.expectResumeRejected && !test.resumeSession { |
| 727 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 728 | } |
| 729 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 730 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 731 | if err != nil { |
| 732 | panic(err) |
| 733 | } |
| 734 | defer func() { |
| 735 | if listener != nil { |
| 736 | listener.Close() |
| 737 | } |
| 738 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 739 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 740 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 741 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 742 | flags = append(flags, "-server") |
| 743 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 744 | flags = append(flags, "-key-file") |
| 745 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 746 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 747 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 748 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | flags = append(flags, "-cert-file") |
| 752 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 753 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 754 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 755 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 756 | } |
| 757 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 758 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 759 | if test.protocol == dtls { |
| 760 | flags = append(flags, "-dtls") |
| 761 | } |
| 762 | |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 763 | if test.resumeSession { |
| 764 | flags = append(flags, "-resume") |
| 765 | } |
| 766 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 767 | if test.shimWritesFirst { |
| 768 | flags = append(flags, "-shim-writes-first") |
| 769 | } |
| 770 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 771 | if test.shimShutsDown { |
| 772 | flags = append(flags, "-shim-shuts-down") |
| 773 | } |
| 774 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 775 | if test.exportKeyingMaterial > 0 { |
| 776 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 777 | flags = append(flags, "-export-label", test.exportLabel) |
| 778 | flags = append(flags, "-export-context", test.exportContext) |
| 779 | if test.useExportContext { |
| 780 | flags = append(flags, "-use-export-context") |
| 781 | } |
| 782 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 783 | if test.expectResumeRejected { |
| 784 | flags = append(flags, "-expect-session-miss") |
| 785 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 786 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 787 | if test.testTLSUnique { |
| 788 | flags = append(flags, "-tls-unique") |
| 789 | } |
| 790 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 791 | flags = append(flags, test.flags...) |
| 792 | |
| 793 | var shim *exec.Cmd |
| 794 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 795 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 796 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 797 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 798 | } else if *useLLDB { |
| 799 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 800 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 801 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 802 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 803 | shim.Stdin = os.Stdin |
| 804 | var stdoutBuf, stderrBuf bytes.Buffer |
| 805 | shim.Stdout = &stdoutBuf |
| 806 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 807 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 808 | shim.Env = os.Environ() |
| 809 | shim.Env = append(shim.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10)) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 810 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 811 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 812 | } |
| 813 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 814 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 815 | |
| 816 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 817 | panic(err) |
| 818 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 819 | waitChan := make(chan error, 1) |
| 820 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 821 | |
| 822 | config := test.config |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 823 | if !test.noSessionCache { |
| 824 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 825 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 826 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 827 | if test.testType == clientTest { |
| 828 | if len(config.Certificates) == 0 { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 829 | config.Certificates = []Certificate{rsaCertificate} |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 830 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 831 | } else { |
| 832 | // Supply a ServerName to ensure a constant session cache key, |
| 833 | // rather than falling back to net.Conn.RemoteAddr. |
| 834 | if len(config.ServerName) == 0 { |
| 835 | config.ServerName = "test" |
| 836 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 837 | } |
David Benjamin | f2b8363 | 2016-03-01 22:57:46 -0500 | [diff] [blame] | 838 | if *fuzzer { |
| 839 | config.Bugs.NullAllCiphers = true |
| 840 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 841 | if *deterministic { |
| 842 | config.Rand = &deterministicRand{} |
| 843 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 844 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 845 | conn, err := acceptOrWait(listener, waitChan) |
| 846 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 847 | err = doExchange(test, &config, conn, false /* not a resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 848 | conn.Close() |
| 849 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 850 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 851 | if err == nil && test.resumeSession { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 852 | var resumeConfig Config |
| 853 | if test.resumeConfig != nil { |
| 854 | resumeConfig = *test.resumeConfig |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 855 | if len(resumeConfig.ServerName) == 0 { |
| 856 | resumeConfig.ServerName = config.ServerName |
| 857 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 858 | if len(resumeConfig.Certificates) == 0 { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 859 | resumeConfig.Certificates = []Certificate{rsaCertificate} |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 860 | } |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 861 | if test.newSessionsOnResume { |
| 862 | if !test.noSessionCache { |
| 863 | resumeConfig.ClientSessionCache = NewLRUClientSessionCache(1) |
| 864 | resumeConfig.ServerSessionCache = NewLRUServerSessionCache(1) |
| 865 | } |
| 866 | } else { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 867 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 868 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 869 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 870 | } |
David Benjamin | f2b8363 | 2016-03-01 22:57:46 -0500 | [diff] [blame] | 871 | if *fuzzer { |
| 872 | resumeConfig.Bugs.NullAllCiphers = true |
| 873 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 874 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 875 | } else { |
| 876 | resumeConfig = config |
| 877 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 878 | var connResume net.Conn |
| 879 | connResume, err = acceptOrWait(listener, waitChan) |
| 880 | if err == nil { |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 881 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 882 | connResume.Close() |
| 883 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 884 | } |
| 885 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 886 | // Close the listener now. This is to avoid hangs should the shim try to |
| 887 | // open more connections than expected. |
| 888 | listener.Close() |
| 889 | listener = nil |
| 890 | |
| 891 | childErr := <-waitChan |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 892 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 893 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 894 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 895 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 896 | case 89: |
| 897 | return errUnimplemented |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 898 | } |
| 899 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 900 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 901 | // Account for Windows line endings. |
| 902 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 903 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 904 | |
| 905 | // Separate the errors from the shim and those from tools like |
| 906 | // AddressSanitizer. |
| 907 | var extraStderr string |
| 908 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 909 | stderr = stderrParts[0] |
| 910 | extraStderr = stderrParts[1] |
| 911 | } |
| 912 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 913 | failed := err != nil || childErr != nil |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 914 | correctFailure := len(test.expectedError) == 0 || strings.Contains(stderr, test.expectedError) |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 915 | localError := "none" |
| 916 | if err != nil { |
| 917 | localError = err.Error() |
| 918 | } |
| 919 | if len(test.expectedLocalError) != 0 { |
| 920 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 921 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 922 | |
| 923 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 924 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 925 | if childErr != nil { |
| 926 | childError = childErr.Error() |
| 927 | } |
| 928 | |
| 929 | var msg string |
| 930 | switch { |
| 931 | case failed && !test.shouldFail: |
| 932 | msg = "unexpected failure" |
| 933 | case !failed && test.shouldFail: |
| 934 | msg = "unexpected success" |
| 935 | case failed && !correctFailure: |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 936 | msg = "bad error (wanted '" + test.expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 937 | default: |
| 938 | panic("internal error") |
| 939 | } |
| 940 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 941 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s", msg, localError, childError, stdout, stderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 942 | } |
| 943 | |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 944 | if !*useValgrind && (len(extraStderr) > 0 || (!failed && len(stderr) > 0)) { |
| 945 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | return nil |
| 949 | } |
| 950 | |
| 951 | var tlsVersions = []struct { |
| 952 | name string |
| 953 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 954 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 955 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 956 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 957 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 958 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 959 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 960 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 961 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | var testCipherSuites = []struct { |
| 965 | name string |
| 966 | id uint16 |
| 967 | }{ |
| 968 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 969 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 970 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 971 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 972 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 973 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 974 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 975 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 976 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 977 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 978 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 979 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 980 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 981 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 982 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 983 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 984 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 985 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 986 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 987 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 988 | {"ECDHE-ECDSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 989 | {"ECDHE-ECDSA-RC4-SHA", TLS_ECDHE_ECDSA_WITH_RC4_128_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 990 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 991 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 992 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 993 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 994 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 995 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 996 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 997 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 998 | {"ECDHE-RSA-RC4-SHA", TLS_ECDHE_RSA_WITH_RC4_128_SHA}, |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 999 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1000 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1001 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1002 | {"CECPQ1-ECDSA-AES256-GCM-SHA384", TLS_CECPQ1_ECDSA_WITH_AES_256_GCM_SHA384}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1003 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1004 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1005 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1006 | {"ECDHE-PSK-AES256-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1007 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 3084e7b | 2016-06-02 12:07:20 -0400 | [diff] [blame] | 1008 | {"ECDHE-PSK-AES128-GCM-SHA256", TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256}, |
| 1009 | {"ECDHE-PSK-AES256-GCM-SHA384", TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1010 | {"PSK-RC4-SHA", TLS_PSK_WITH_RC4_128_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1011 | {"RC4-MD5", TLS_RSA_WITH_RC4_128_MD5}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1012 | {"RC4-SHA", TLS_RSA_WITH_RC4_128_SHA}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1013 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1016 | func hasComponent(suiteName, component string) bool { |
| 1017 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1018 | } |
| 1019 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1020 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1021 | return hasComponent(suiteName, "GCM") || |
| 1022 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1023 | hasComponent(suiteName, "SHA384") || |
| 1024 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1025 | } |
| 1026 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1027 | func isTLS13Suite(suiteName string) bool { |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 1028 | // Only AEADs. |
| 1029 | if !hasComponent(suiteName, "GCM") && !hasComponent(suiteName, "POLY1305") { |
| 1030 | return false |
| 1031 | } |
| 1032 | // No old CHACHA20_POLY1305. |
| 1033 | if hasComponent(suiteName, "CHACHA20-POLY1305-OLD") { |
| 1034 | return false |
| 1035 | } |
| 1036 | // Must have ECDHE. |
| 1037 | // TODO(davidben,svaldez): Add pure PSK support. |
| 1038 | if !hasComponent(suiteName, "ECDHE") { |
| 1039 | return false |
| 1040 | } |
| 1041 | // TODO(davidben,svaldez): Add PSK support. |
| 1042 | if hasComponent(suiteName, "PSK") { |
| 1043 | return false |
| 1044 | } |
| 1045 | return true |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1048 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1049 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1050 | } |
| 1051 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1052 | func bigFromHex(hex string) *big.Int { |
| 1053 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1054 | if !ok { |
| 1055 | panic("failed to parse hex number 0x" + hex) |
| 1056 | } |
| 1057 | return ret |
| 1058 | } |
| 1059 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1060 | func addBasicTests() { |
| 1061 | basicTests := []testCase{ |
| 1062 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1063 | name: "NoFallbackSCSV", |
| 1064 | config: Config{ |
| 1065 | Bugs: ProtocolBugs{ |
| 1066 | FailIfNotFallbackSCSV: true, |
| 1067 | }, |
| 1068 | }, |
| 1069 | shouldFail: true, |
| 1070 | expectedLocalError: "no fallback SCSV found", |
| 1071 | }, |
| 1072 | { |
| 1073 | name: "SendFallbackSCSV", |
| 1074 | config: Config{ |
| 1075 | Bugs: ProtocolBugs{ |
| 1076 | FailIfNotFallbackSCSV: true, |
| 1077 | }, |
| 1078 | }, |
| 1079 | flags: []string{"-fallback-scsv"}, |
| 1080 | }, |
| 1081 | { |
| 1082 | name: "ClientCertificateTypes", |
| 1083 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1084 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1085 | ClientAuth: RequestClientCert, |
| 1086 | ClientCertificateTypes: []byte{ |
| 1087 | CertTypeDSSSign, |
| 1088 | CertTypeRSASign, |
| 1089 | CertTypeECDSASign, |
| 1090 | }, |
| 1091 | }, |
| 1092 | flags: []string{ |
| 1093 | "-expect-certificate-types", |
| 1094 | base64.StdEncoding.EncodeToString([]byte{ |
| 1095 | CertTypeDSSSign, |
| 1096 | CertTypeRSASign, |
| 1097 | CertTypeECDSASign, |
| 1098 | }), |
| 1099 | }, |
| 1100 | }, |
| 1101 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1102 | name: "UnauthenticatedECDH", |
| 1103 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1104 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1105 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1106 | Bugs: ProtocolBugs{ |
| 1107 | UnauthenticatedECDH: true, |
| 1108 | }, |
| 1109 | }, |
| 1110 | shouldFail: true, |
| 1111 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1112 | }, |
| 1113 | { |
| 1114 | name: "SkipCertificateStatus", |
| 1115 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1116 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1117 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1118 | Bugs: ProtocolBugs{ |
| 1119 | SkipCertificateStatus: true, |
| 1120 | }, |
| 1121 | }, |
| 1122 | flags: []string{ |
| 1123 | "-enable-ocsp-stapling", |
| 1124 | }, |
| 1125 | }, |
| 1126 | { |
| 1127 | name: "SkipServerKeyExchange", |
| 1128 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1129 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1130 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1131 | Bugs: ProtocolBugs{ |
| 1132 | SkipServerKeyExchange: true, |
| 1133 | }, |
| 1134 | }, |
| 1135 | shouldFail: true, |
| 1136 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1137 | }, |
| 1138 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1139 | testType: serverTest, |
| 1140 | name: "Alert", |
| 1141 | config: Config{ |
| 1142 | Bugs: ProtocolBugs{ |
| 1143 | SendSpuriousAlert: alertRecordOverflow, |
| 1144 | }, |
| 1145 | }, |
| 1146 | shouldFail: true, |
| 1147 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1148 | }, |
| 1149 | { |
| 1150 | protocol: dtls, |
| 1151 | testType: serverTest, |
| 1152 | name: "Alert-DTLS", |
| 1153 | config: Config{ |
| 1154 | Bugs: ProtocolBugs{ |
| 1155 | SendSpuriousAlert: alertRecordOverflow, |
| 1156 | }, |
| 1157 | }, |
| 1158 | shouldFail: true, |
| 1159 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1160 | }, |
| 1161 | { |
| 1162 | testType: serverTest, |
| 1163 | name: "FragmentAlert", |
| 1164 | config: Config{ |
| 1165 | Bugs: ProtocolBugs{ |
| 1166 | FragmentAlert: true, |
| 1167 | SendSpuriousAlert: alertRecordOverflow, |
| 1168 | }, |
| 1169 | }, |
| 1170 | shouldFail: true, |
| 1171 | expectedError: ":BAD_ALERT:", |
| 1172 | }, |
| 1173 | { |
| 1174 | protocol: dtls, |
| 1175 | testType: serverTest, |
| 1176 | name: "FragmentAlert-DTLS", |
| 1177 | config: Config{ |
| 1178 | Bugs: ProtocolBugs{ |
| 1179 | FragmentAlert: true, |
| 1180 | SendSpuriousAlert: alertRecordOverflow, |
| 1181 | }, |
| 1182 | }, |
| 1183 | shouldFail: true, |
| 1184 | expectedError: ":BAD_ALERT:", |
| 1185 | }, |
| 1186 | { |
| 1187 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1188 | name: "DoubleAlert", |
| 1189 | config: Config{ |
| 1190 | Bugs: ProtocolBugs{ |
| 1191 | DoubleAlert: true, |
| 1192 | SendSpuriousAlert: alertRecordOverflow, |
| 1193 | }, |
| 1194 | }, |
| 1195 | shouldFail: true, |
| 1196 | expectedError: ":BAD_ALERT:", |
| 1197 | }, |
| 1198 | { |
| 1199 | protocol: dtls, |
| 1200 | testType: serverTest, |
| 1201 | name: "DoubleAlert-DTLS", |
| 1202 | config: Config{ |
| 1203 | Bugs: ProtocolBugs{ |
| 1204 | DoubleAlert: true, |
| 1205 | SendSpuriousAlert: alertRecordOverflow, |
| 1206 | }, |
| 1207 | }, |
| 1208 | shouldFail: true, |
| 1209 | expectedError: ":BAD_ALERT:", |
| 1210 | }, |
| 1211 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1212 | name: "SkipNewSessionTicket", |
| 1213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1214 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1215 | Bugs: ProtocolBugs{ |
| 1216 | SkipNewSessionTicket: true, |
| 1217 | }, |
| 1218 | }, |
| 1219 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1220 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1221 | }, |
| 1222 | { |
| 1223 | testType: serverTest, |
| 1224 | name: "FallbackSCSV", |
| 1225 | config: Config{ |
| 1226 | MaxVersion: VersionTLS11, |
| 1227 | Bugs: ProtocolBugs{ |
| 1228 | SendFallbackSCSV: true, |
| 1229 | }, |
| 1230 | }, |
| 1231 | shouldFail: true, |
| 1232 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1233 | }, |
| 1234 | { |
| 1235 | testType: serverTest, |
| 1236 | name: "FallbackSCSV-VersionMatch", |
| 1237 | config: Config{ |
| 1238 | Bugs: ProtocolBugs{ |
| 1239 | SendFallbackSCSV: true, |
| 1240 | }, |
| 1241 | }, |
| 1242 | }, |
| 1243 | { |
| 1244 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1245 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1246 | config: Config{ |
| 1247 | MaxVersion: VersionTLS12, |
| 1248 | Bugs: ProtocolBugs{ |
| 1249 | SendFallbackSCSV: true, |
| 1250 | }, |
| 1251 | }, |
| 1252 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1253 | }, |
| 1254 | { |
| 1255 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1256 | name: "FragmentedClientVersion", |
| 1257 | config: Config{ |
| 1258 | Bugs: ProtocolBugs{ |
| 1259 | MaxHandshakeRecordLength: 1, |
| 1260 | FragmentClientVersion: true, |
| 1261 | }, |
| 1262 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1263 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1264 | }, |
| 1265 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1266 | testType: serverTest, |
| 1267 | name: "HttpGET", |
| 1268 | sendPrefix: "GET / HTTP/1.0\n", |
| 1269 | shouldFail: true, |
| 1270 | expectedError: ":HTTP_REQUEST:", |
| 1271 | }, |
| 1272 | { |
| 1273 | testType: serverTest, |
| 1274 | name: "HttpPOST", |
| 1275 | sendPrefix: "POST / HTTP/1.0\n", |
| 1276 | shouldFail: true, |
| 1277 | expectedError: ":HTTP_REQUEST:", |
| 1278 | }, |
| 1279 | { |
| 1280 | testType: serverTest, |
| 1281 | name: "HttpHEAD", |
| 1282 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1283 | shouldFail: true, |
| 1284 | expectedError: ":HTTP_REQUEST:", |
| 1285 | }, |
| 1286 | { |
| 1287 | testType: serverTest, |
| 1288 | name: "HttpPUT", |
| 1289 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1290 | shouldFail: true, |
| 1291 | expectedError: ":HTTP_REQUEST:", |
| 1292 | }, |
| 1293 | { |
| 1294 | testType: serverTest, |
| 1295 | name: "HttpCONNECT", |
| 1296 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1297 | shouldFail: true, |
| 1298 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1299 | }, |
| 1300 | { |
| 1301 | testType: serverTest, |
| 1302 | name: "Garbage", |
| 1303 | sendPrefix: "blah", |
| 1304 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1305 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1306 | }, |
| 1307 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1308 | name: "RSAEphemeralKey", |
| 1309 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1310 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1311 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1312 | Bugs: ProtocolBugs{ |
| 1313 | RSAEphemeralKey: true, |
| 1314 | }, |
| 1315 | }, |
| 1316 | shouldFail: true, |
| 1317 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1318 | }, |
| 1319 | { |
| 1320 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1321 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1322 | shouldFail: true, |
| 1323 | expectedError: ":WRONG_SSL_VERSION:", |
| 1324 | }, |
| 1325 | { |
| 1326 | protocol: dtls, |
| 1327 | name: "DisableEverything-DTLS", |
| 1328 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1329 | shouldFail: true, |
| 1330 | expectedError: ":WRONG_SSL_VERSION:", |
| 1331 | }, |
| 1332 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1333 | protocol: dtls, |
| 1334 | testType: serverTest, |
| 1335 | name: "MTU", |
| 1336 | config: Config{ |
| 1337 | Bugs: ProtocolBugs{ |
| 1338 | MaxPacketLength: 256, |
| 1339 | }, |
| 1340 | }, |
| 1341 | flags: []string{"-mtu", "256"}, |
| 1342 | }, |
| 1343 | { |
| 1344 | protocol: dtls, |
| 1345 | testType: serverTest, |
| 1346 | name: "MTUExceeded", |
| 1347 | config: Config{ |
| 1348 | Bugs: ProtocolBugs{ |
| 1349 | MaxPacketLength: 255, |
| 1350 | }, |
| 1351 | }, |
| 1352 | flags: []string{"-mtu", "256"}, |
| 1353 | shouldFail: true, |
| 1354 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1355 | }, |
| 1356 | { |
| 1357 | name: "CertMismatchRSA", |
| 1358 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1359 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1360 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1361 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1362 | Bugs: ProtocolBugs{ |
| 1363 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1364 | }, |
| 1365 | }, |
| 1366 | shouldFail: true, |
| 1367 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1368 | }, |
| 1369 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1370 | name: "CertMismatchRSA-TLS13", |
| 1371 | config: Config{ |
| 1372 | MaxVersion: VersionTLS13, |
| 1373 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1374 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 1375 | Bugs: ProtocolBugs{ |
| 1376 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1377 | }, |
| 1378 | }, |
| 1379 | shouldFail: true, |
| 1380 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1381 | }, |
| 1382 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1383 | name: "CertMismatchECDSA", |
| 1384 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1385 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1386 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1387 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1388 | Bugs: ProtocolBugs{ |
| 1389 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1390 | }, |
| 1391 | }, |
| 1392 | shouldFail: true, |
| 1393 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1394 | }, |
| 1395 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1396 | name: "CertMismatchECDSA-TLS13", |
| 1397 | config: Config{ |
| 1398 | MaxVersion: VersionTLS13, |
| 1399 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1400 | Certificates: []Certificate{rsaCertificate}, |
| 1401 | Bugs: ProtocolBugs{ |
| 1402 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1403 | }, |
| 1404 | }, |
| 1405 | shouldFail: true, |
| 1406 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1407 | }, |
| 1408 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1409 | name: "EmptyCertificateList", |
| 1410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1411 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1412 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1413 | Bugs: ProtocolBugs{ |
| 1414 | EmptyCertificateList: true, |
| 1415 | }, |
| 1416 | }, |
| 1417 | shouldFail: true, |
| 1418 | expectedError: ":DECODE_ERROR:", |
| 1419 | }, |
| 1420 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1421 | name: "EmptyCertificateList-TLS13", |
| 1422 | config: Config{ |
| 1423 | MaxVersion: VersionTLS13, |
| 1424 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1425 | Bugs: ProtocolBugs{ |
| 1426 | EmptyCertificateList: true, |
| 1427 | }, |
| 1428 | }, |
| 1429 | shouldFail: true, |
| 1430 | expectedError: ":DECODE_ERROR:", |
| 1431 | }, |
| 1432 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1433 | name: "TLSFatalBadPackets", |
| 1434 | damageFirstWrite: true, |
| 1435 | shouldFail: true, |
| 1436 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1437 | }, |
| 1438 | { |
| 1439 | protocol: dtls, |
| 1440 | name: "DTLSIgnoreBadPackets", |
| 1441 | damageFirstWrite: true, |
| 1442 | }, |
| 1443 | { |
| 1444 | protocol: dtls, |
| 1445 | name: "DTLSIgnoreBadPackets-Async", |
| 1446 | damageFirstWrite: true, |
| 1447 | flags: []string{"-async"}, |
| 1448 | }, |
| 1449 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1450 | name: "AppDataBeforeHandshake", |
| 1451 | config: Config{ |
| 1452 | Bugs: ProtocolBugs{ |
| 1453 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1454 | }, |
| 1455 | }, |
| 1456 | shouldFail: true, |
| 1457 | expectedError: ":UNEXPECTED_RECORD:", |
| 1458 | }, |
| 1459 | { |
| 1460 | name: "AppDataBeforeHandshake-Empty", |
| 1461 | config: Config{ |
| 1462 | Bugs: ProtocolBugs{ |
| 1463 | AppDataBeforeHandshake: []byte{}, |
| 1464 | }, |
| 1465 | }, |
| 1466 | shouldFail: true, |
| 1467 | expectedError: ":UNEXPECTED_RECORD:", |
| 1468 | }, |
| 1469 | { |
| 1470 | protocol: dtls, |
| 1471 | name: "AppDataBeforeHandshake-DTLS", |
| 1472 | config: Config{ |
| 1473 | Bugs: ProtocolBugs{ |
| 1474 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1475 | }, |
| 1476 | }, |
| 1477 | shouldFail: true, |
| 1478 | expectedError: ":UNEXPECTED_RECORD:", |
| 1479 | }, |
| 1480 | { |
| 1481 | protocol: dtls, |
| 1482 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1483 | config: Config{ |
| 1484 | Bugs: ProtocolBugs{ |
| 1485 | AppDataBeforeHandshake: []byte{}, |
| 1486 | }, |
| 1487 | }, |
| 1488 | shouldFail: true, |
| 1489 | expectedError: ":UNEXPECTED_RECORD:", |
| 1490 | }, |
| 1491 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1492 | name: "AppDataAfterChangeCipherSpec", |
| 1493 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1494 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1495 | Bugs: ProtocolBugs{ |
| 1496 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1497 | }, |
| 1498 | }, |
| 1499 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1500 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1501 | }, |
| 1502 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1503 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1504 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1505 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1506 | Bugs: ProtocolBugs{ |
| 1507 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1508 | }, |
| 1509 | }, |
| 1510 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1511 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1512 | }, |
| 1513 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1514 | protocol: dtls, |
| 1515 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1516 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1517 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1518 | Bugs: ProtocolBugs{ |
| 1519 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1520 | }, |
| 1521 | }, |
| 1522 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1523 | // application data. |
| 1524 | }, |
| 1525 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1526 | protocol: dtls, |
| 1527 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1528 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1529 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1530 | Bugs: ProtocolBugs{ |
| 1531 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1532 | }, |
| 1533 | }, |
| 1534 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1535 | // application data. |
| 1536 | }, |
| 1537 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1538 | name: "AlertAfterChangeCipherSpec", |
| 1539 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1540 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1541 | Bugs: ProtocolBugs{ |
| 1542 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1543 | }, |
| 1544 | }, |
| 1545 | shouldFail: true, |
| 1546 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1547 | }, |
| 1548 | { |
| 1549 | protocol: dtls, |
| 1550 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1551 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1552 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1553 | Bugs: ProtocolBugs{ |
| 1554 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1555 | }, |
| 1556 | }, |
| 1557 | shouldFail: true, |
| 1558 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1559 | }, |
| 1560 | { |
| 1561 | protocol: dtls, |
| 1562 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1563 | config: Config{ |
| 1564 | Bugs: ProtocolBugs{ |
| 1565 | ReorderHandshakeFragments: true, |
| 1566 | // Small enough that every handshake message is |
| 1567 | // fragmented. |
| 1568 | MaxHandshakeRecordLength: 2, |
| 1569 | }, |
| 1570 | }, |
| 1571 | }, |
| 1572 | { |
| 1573 | protocol: dtls, |
| 1574 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1575 | config: Config{ |
| 1576 | Bugs: ProtocolBugs{ |
| 1577 | ReorderHandshakeFragments: true, |
| 1578 | // Large enough that no handshake message is |
| 1579 | // fragmented. |
| 1580 | MaxHandshakeRecordLength: 2048, |
| 1581 | }, |
| 1582 | }, |
| 1583 | }, |
| 1584 | { |
| 1585 | protocol: dtls, |
| 1586 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1587 | config: Config{ |
| 1588 | Bugs: ProtocolBugs{ |
| 1589 | ReorderHandshakeFragments: true, |
| 1590 | MixCompleteMessageWithFragments: true, |
| 1591 | MaxHandshakeRecordLength: 2, |
| 1592 | }, |
| 1593 | }, |
| 1594 | }, |
| 1595 | { |
| 1596 | name: "SendInvalidRecordType", |
| 1597 | config: Config{ |
| 1598 | Bugs: ProtocolBugs{ |
| 1599 | SendInvalidRecordType: true, |
| 1600 | }, |
| 1601 | }, |
| 1602 | shouldFail: true, |
| 1603 | expectedError: ":UNEXPECTED_RECORD:", |
| 1604 | }, |
| 1605 | { |
| 1606 | protocol: dtls, |
| 1607 | name: "SendInvalidRecordType-DTLS", |
| 1608 | config: Config{ |
| 1609 | Bugs: ProtocolBugs{ |
| 1610 | SendInvalidRecordType: true, |
| 1611 | }, |
| 1612 | }, |
| 1613 | shouldFail: true, |
| 1614 | expectedError: ":UNEXPECTED_RECORD:", |
| 1615 | }, |
| 1616 | { |
| 1617 | name: "FalseStart-SkipServerSecondLeg", |
| 1618 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1619 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1620 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1621 | NextProtos: []string{"foo"}, |
| 1622 | Bugs: ProtocolBugs{ |
| 1623 | SkipNewSessionTicket: true, |
| 1624 | SkipChangeCipherSpec: true, |
| 1625 | SkipFinished: true, |
| 1626 | ExpectFalseStart: true, |
| 1627 | }, |
| 1628 | }, |
| 1629 | flags: []string{ |
| 1630 | "-false-start", |
| 1631 | "-handshake-never-done", |
| 1632 | "-advertise-alpn", "\x03foo", |
| 1633 | }, |
| 1634 | shimWritesFirst: true, |
| 1635 | shouldFail: true, |
| 1636 | expectedError: ":UNEXPECTED_RECORD:", |
| 1637 | }, |
| 1638 | { |
| 1639 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1640 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1641 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1642 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1643 | NextProtos: []string{"foo"}, |
| 1644 | Bugs: ProtocolBugs{ |
| 1645 | SkipNewSessionTicket: true, |
| 1646 | SkipChangeCipherSpec: true, |
| 1647 | SkipFinished: true, |
| 1648 | }, |
| 1649 | }, |
| 1650 | flags: []string{ |
| 1651 | "-implicit-handshake", |
| 1652 | "-false-start", |
| 1653 | "-handshake-never-done", |
| 1654 | "-advertise-alpn", "\x03foo", |
| 1655 | }, |
| 1656 | shouldFail: true, |
| 1657 | expectedError: ":UNEXPECTED_RECORD:", |
| 1658 | }, |
| 1659 | { |
| 1660 | testType: serverTest, |
| 1661 | name: "FailEarlyCallback", |
| 1662 | flags: []string{"-fail-early-callback"}, |
| 1663 | shouldFail: true, |
| 1664 | expectedError: ":CONNECTION_REJECTED:", |
| 1665 | expectedLocalError: "remote error: access denied", |
| 1666 | }, |
| 1667 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1668 | protocol: dtls, |
| 1669 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1670 | config: Config{ |
| 1671 | Bugs: ProtocolBugs{ |
| 1672 | MaxHandshakeRecordLength: 2, |
| 1673 | FragmentMessageTypeMismatch: true, |
| 1674 | }, |
| 1675 | }, |
| 1676 | shouldFail: true, |
| 1677 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1678 | }, |
| 1679 | { |
| 1680 | protocol: dtls, |
| 1681 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1682 | config: Config{ |
| 1683 | Bugs: ProtocolBugs{ |
| 1684 | MaxHandshakeRecordLength: 2, |
| 1685 | FragmentMessageLengthMismatch: true, |
| 1686 | }, |
| 1687 | }, |
| 1688 | shouldFail: true, |
| 1689 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1690 | }, |
| 1691 | { |
| 1692 | protocol: dtls, |
| 1693 | name: "SplitFragments-Header-DTLS", |
| 1694 | config: Config{ |
| 1695 | Bugs: ProtocolBugs{ |
| 1696 | SplitFragments: 2, |
| 1697 | }, |
| 1698 | }, |
| 1699 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1700 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1701 | }, |
| 1702 | { |
| 1703 | protocol: dtls, |
| 1704 | name: "SplitFragments-Boundary-DTLS", |
| 1705 | config: Config{ |
| 1706 | Bugs: ProtocolBugs{ |
| 1707 | SplitFragments: dtlsRecordHeaderLen, |
| 1708 | }, |
| 1709 | }, |
| 1710 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1711 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1712 | }, |
| 1713 | { |
| 1714 | protocol: dtls, |
| 1715 | name: "SplitFragments-Body-DTLS", |
| 1716 | config: Config{ |
| 1717 | Bugs: ProtocolBugs{ |
| 1718 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1719 | }, |
| 1720 | }, |
| 1721 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1722 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1723 | }, |
| 1724 | { |
| 1725 | protocol: dtls, |
| 1726 | name: "SendEmptyFragments-DTLS", |
| 1727 | config: Config{ |
| 1728 | Bugs: ProtocolBugs{ |
| 1729 | SendEmptyFragments: true, |
| 1730 | }, |
| 1731 | }, |
| 1732 | }, |
| 1733 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1734 | name: "BadFinished-Client", |
| 1735 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1736 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1737 | Bugs: ProtocolBugs{ |
| 1738 | BadFinished: true, |
| 1739 | }, |
| 1740 | }, |
| 1741 | shouldFail: true, |
| 1742 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1743 | }, |
| 1744 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1745 | name: "BadFinished-Client-TLS13", |
| 1746 | config: Config{ |
| 1747 | MaxVersion: VersionTLS13, |
| 1748 | Bugs: ProtocolBugs{ |
| 1749 | BadFinished: true, |
| 1750 | }, |
| 1751 | }, |
| 1752 | shouldFail: true, |
| 1753 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1754 | }, |
| 1755 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1756 | testType: serverTest, |
| 1757 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1758 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1759 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1760 | Bugs: ProtocolBugs{ |
| 1761 | BadFinished: true, |
| 1762 | }, |
| 1763 | }, |
| 1764 | shouldFail: true, |
| 1765 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1766 | }, |
| 1767 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1768 | testType: serverTest, |
| 1769 | name: "BadFinished-Server-TLS13", |
| 1770 | config: Config{ |
| 1771 | MaxVersion: VersionTLS13, |
| 1772 | Bugs: ProtocolBugs{ |
| 1773 | BadFinished: true, |
| 1774 | }, |
| 1775 | }, |
| 1776 | shouldFail: true, |
| 1777 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1778 | }, |
| 1779 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1780 | name: "FalseStart-BadFinished", |
| 1781 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1782 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1783 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1784 | NextProtos: []string{"foo"}, |
| 1785 | Bugs: ProtocolBugs{ |
| 1786 | BadFinished: true, |
| 1787 | ExpectFalseStart: true, |
| 1788 | }, |
| 1789 | }, |
| 1790 | flags: []string{ |
| 1791 | "-false-start", |
| 1792 | "-handshake-never-done", |
| 1793 | "-advertise-alpn", "\x03foo", |
| 1794 | }, |
| 1795 | shimWritesFirst: true, |
| 1796 | shouldFail: true, |
| 1797 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1798 | }, |
| 1799 | { |
| 1800 | name: "NoFalseStart-NoALPN", |
| 1801 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1802 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1803 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1804 | Bugs: ProtocolBugs{ |
| 1805 | ExpectFalseStart: true, |
| 1806 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1807 | }, |
| 1808 | }, |
| 1809 | flags: []string{ |
| 1810 | "-false-start", |
| 1811 | }, |
| 1812 | shimWritesFirst: true, |
| 1813 | shouldFail: true, |
| 1814 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1815 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1816 | }, |
| 1817 | { |
| 1818 | name: "NoFalseStart-NoAEAD", |
| 1819 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1820 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1821 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1822 | NextProtos: []string{"foo"}, |
| 1823 | Bugs: ProtocolBugs{ |
| 1824 | ExpectFalseStart: true, |
| 1825 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1826 | }, |
| 1827 | }, |
| 1828 | flags: []string{ |
| 1829 | "-false-start", |
| 1830 | "-advertise-alpn", "\x03foo", |
| 1831 | }, |
| 1832 | shimWritesFirst: true, |
| 1833 | shouldFail: true, |
| 1834 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1835 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1836 | }, |
| 1837 | { |
| 1838 | name: "NoFalseStart-RSA", |
| 1839 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1840 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1841 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1842 | NextProtos: []string{"foo"}, |
| 1843 | Bugs: ProtocolBugs{ |
| 1844 | ExpectFalseStart: true, |
| 1845 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1846 | }, |
| 1847 | }, |
| 1848 | flags: []string{ |
| 1849 | "-false-start", |
| 1850 | "-advertise-alpn", "\x03foo", |
| 1851 | }, |
| 1852 | shimWritesFirst: true, |
| 1853 | shouldFail: true, |
| 1854 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1855 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1856 | }, |
| 1857 | { |
| 1858 | name: "NoFalseStart-DHE_RSA", |
| 1859 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1860 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1862 | NextProtos: []string{"foo"}, |
| 1863 | Bugs: ProtocolBugs{ |
| 1864 | ExpectFalseStart: true, |
| 1865 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1866 | }, |
| 1867 | }, |
| 1868 | flags: []string{ |
| 1869 | "-false-start", |
| 1870 | "-advertise-alpn", "\x03foo", |
| 1871 | }, |
| 1872 | shimWritesFirst: true, |
| 1873 | shouldFail: true, |
| 1874 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1875 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1876 | }, |
| 1877 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1878 | protocol: dtls, |
| 1879 | name: "SendSplitAlert-Sync", |
| 1880 | config: Config{ |
| 1881 | Bugs: ProtocolBugs{ |
| 1882 | SendSplitAlert: true, |
| 1883 | }, |
| 1884 | }, |
| 1885 | }, |
| 1886 | { |
| 1887 | protocol: dtls, |
| 1888 | name: "SendSplitAlert-Async", |
| 1889 | config: Config{ |
| 1890 | Bugs: ProtocolBugs{ |
| 1891 | SendSplitAlert: true, |
| 1892 | }, |
| 1893 | }, |
| 1894 | flags: []string{"-async"}, |
| 1895 | }, |
| 1896 | { |
| 1897 | protocol: dtls, |
| 1898 | name: "PackDTLSHandshake", |
| 1899 | config: Config{ |
| 1900 | Bugs: ProtocolBugs{ |
| 1901 | MaxHandshakeRecordLength: 2, |
| 1902 | PackHandshakeFragments: 20, |
| 1903 | PackHandshakeRecords: 200, |
| 1904 | }, |
| 1905 | }, |
| 1906 | }, |
| 1907 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1908 | name: "SendEmptyRecords-Pass", |
| 1909 | sendEmptyRecords: 32, |
| 1910 | }, |
| 1911 | { |
| 1912 | name: "SendEmptyRecords", |
| 1913 | sendEmptyRecords: 33, |
| 1914 | shouldFail: true, |
| 1915 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1916 | }, |
| 1917 | { |
| 1918 | name: "SendEmptyRecords-Async", |
| 1919 | sendEmptyRecords: 33, |
| 1920 | flags: []string{"-async"}, |
| 1921 | shouldFail: true, |
| 1922 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1923 | }, |
| 1924 | { |
| 1925 | name: "SendWarningAlerts-Pass", |
| 1926 | sendWarningAlerts: 4, |
| 1927 | }, |
| 1928 | { |
| 1929 | protocol: dtls, |
| 1930 | name: "SendWarningAlerts-DTLS-Pass", |
| 1931 | sendWarningAlerts: 4, |
| 1932 | }, |
| 1933 | { |
| 1934 | name: "SendWarningAlerts", |
| 1935 | sendWarningAlerts: 5, |
| 1936 | shouldFail: true, |
| 1937 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1938 | }, |
| 1939 | { |
| 1940 | name: "SendWarningAlerts-Async", |
| 1941 | sendWarningAlerts: 5, |
| 1942 | flags: []string{"-async"}, |
| 1943 | shouldFail: true, |
| 1944 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 1945 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1946 | { |
| 1947 | name: "EmptySessionID", |
| 1948 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1949 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 1950 | SessionTicketsDisabled: true, |
| 1951 | }, |
| 1952 | noSessionCache: true, |
| 1953 | flags: []string{"-expect-no-session"}, |
| 1954 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1955 | { |
| 1956 | name: "Unclean-Shutdown", |
| 1957 | config: Config{ |
| 1958 | Bugs: ProtocolBugs{ |
| 1959 | NoCloseNotify: true, |
| 1960 | ExpectCloseNotify: true, |
| 1961 | }, |
| 1962 | }, |
| 1963 | shimShutsDown: true, |
| 1964 | flags: []string{"-check-close-notify"}, |
| 1965 | shouldFail: true, |
| 1966 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 1967 | }, |
| 1968 | { |
| 1969 | name: "Unclean-Shutdown-Ignored", |
| 1970 | config: Config{ |
| 1971 | Bugs: ProtocolBugs{ |
| 1972 | NoCloseNotify: true, |
| 1973 | }, |
| 1974 | }, |
| 1975 | shimShutsDown: true, |
| 1976 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 1977 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 1978 | name: "Unclean-Shutdown-Alert", |
| 1979 | config: Config{ |
| 1980 | Bugs: ProtocolBugs{ |
| 1981 | SendAlertOnShutdown: alertDecompressionFailure, |
| 1982 | ExpectCloseNotify: true, |
| 1983 | }, |
| 1984 | }, |
| 1985 | shimShutsDown: true, |
| 1986 | flags: []string{"-check-close-notify"}, |
| 1987 | shouldFail: true, |
| 1988 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 1989 | }, |
| 1990 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 1991 | name: "LargePlaintext", |
| 1992 | config: Config{ |
| 1993 | Bugs: ProtocolBugs{ |
| 1994 | SendLargeRecords: true, |
| 1995 | }, |
| 1996 | }, |
| 1997 | messageLen: maxPlaintext + 1, |
| 1998 | shouldFail: true, |
| 1999 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2000 | }, |
| 2001 | { |
| 2002 | protocol: dtls, |
| 2003 | name: "LargePlaintext-DTLS", |
| 2004 | config: Config{ |
| 2005 | Bugs: ProtocolBugs{ |
| 2006 | SendLargeRecords: true, |
| 2007 | }, |
| 2008 | }, |
| 2009 | messageLen: maxPlaintext + 1, |
| 2010 | shouldFail: true, |
| 2011 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2012 | }, |
| 2013 | { |
| 2014 | name: "LargeCiphertext", |
| 2015 | config: Config{ |
| 2016 | Bugs: ProtocolBugs{ |
| 2017 | SendLargeRecords: true, |
| 2018 | }, |
| 2019 | }, |
| 2020 | messageLen: maxPlaintext * 2, |
| 2021 | shouldFail: true, |
| 2022 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2023 | }, |
| 2024 | { |
| 2025 | protocol: dtls, |
| 2026 | name: "LargeCiphertext-DTLS", |
| 2027 | config: Config{ |
| 2028 | Bugs: ProtocolBugs{ |
| 2029 | SendLargeRecords: true, |
| 2030 | }, |
| 2031 | }, |
| 2032 | messageLen: maxPlaintext * 2, |
| 2033 | // Unlike the other four cases, DTLS drops records which |
| 2034 | // are invalid before authentication, so the connection |
| 2035 | // does not fail. |
| 2036 | expectMessageDropped: true, |
| 2037 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2038 | { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2039 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 2040 | // mean the server changed its mind on sending a ticket. |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2041 | name: "SendEmptySessionTicket", |
| 2042 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2043 | MaxVersion: VersionTLS12, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2044 | Bugs: ProtocolBugs{ |
| 2045 | SendEmptySessionTicket: true, |
| 2046 | FailIfSessionOffered: true, |
| 2047 | }, |
| 2048 | }, |
| 2049 | flags: []string{"-expect-no-session"}, |
| 2050 | resumeSession: true, |
| 2051 | expectResumeRejected: true, |
| 2052 | }, |
David Benjamin | 99fdfb9 | 2015-11-02 12:11:35 -0500 | [diff] [blame] | 2053 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2054 | name: "BadHelloRequest-1", |
| 2055 | renegotiate: 1, |
| 2056 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2057 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2058 | Bugs: ProtocolBugs{ |
| 2059 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2060 | }, |
| 2061 | }, |
| 2062 | flags: []string{ |
| 2063 | "-renegotiate-freely", |
| 2064 | "-expect-total-renegotiations", "1", |
| 2065 | }, |
| 2066 | shouldFail: true, |
| 2067 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2068 | }, |
| 2069 | { |
| 2070 | name: "BadHelloRequest-2", |
| 2071 | renegotiate: 1, |
| 2072 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2073 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2074 | Bugs: ProtocolBugs{ |
| 2075 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2076 | }, |
| 2077 | }, |
| 2078 | flags: []string{ |
| 2079 | "-renegotiate-freely", |
| 2080 | "-expect-total-renegotiations", "1", |
| 2081 | }, |
| 2082 | shouldFail: true, |
| 2083 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2084 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2085 | { |
| 2086 | testType: serverTest, |
| 2087 | name: "SupportTicketsWithSessionID", |
| 2088 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2089 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2090 | SessionTicketsDisabled: true, |
| 2091 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2092 | resumeConfig: &Config{ |
| 2093 | MaxVersion: VersionTLS12, |
| 2094 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2095 | resumeSession: true, |
| 2096 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2097 | { |
| 2098 | protocol: dtls, |
| 2099 | name: "DTLS-SendExtraFinished", |
| 2100 | config: Config{ |
| 2101 | Bugs: ProtocolBugs{ |
| 2102 | SendExtraFinished: true, |
| 2103 | }, |
| 2104 | }, |
| 2105 | shouldFail: true, |
| 2106 | expectedError: ":UNEXPECTED_RECORD:", |
| 2107 | }, |
| 2108 | { |
| 2109 | protocol: dtls, |
| 2110 | name: "DTLS-SendExtraFinished-Reordered", |
| 2111 | config: Config{ |
| 2112 | Bugs: ProtocolBugs{ |
| 2113 | MaxHandshakeRecordLength: 2, |
| 2114 | ReorderHandshakeFragments: true, |
| 2115 | SendExtraFinished: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | shouldFail: true, |
| 2119 | expectedError: ":UNEXPECTED_RECORD:", |
| 2120 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2121 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2122 | testCases = append(testCases, basicTests...) |
| 2123 | } |
| 2124 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2125 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2126 | const bogusCipher = 0xfe00 |
| 2127 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2128 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2129 | const psk = "12345" |
| 2130 | const pskIdentity = "luggage combo" |
| 2131 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2132 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2133 | var certFile string |
| 2134 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2135 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2136 | cert = ecdsaP256Certificate |
| 2137 | certFile = ecdsaP256CertificateFile |
| 2138 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2139 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2140 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2141 | certFile = rsaCertificateFile |
| 2142 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2143 | } |
| 2144 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2145 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2146 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2147 | flags = append(flags, |
| 2148 | "-psk", psk, |
| 2149 | "-psk-identity", pskIdentity) |
| 2150 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2151 | if hasComponent(suite.name, "NULL") { |
| 2152 | // NULL ciphers must be explicitly enabled. |
| 2153 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2154 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2155 | if hasComponent(suite.name, "CECPQ1") { |
| 2156 | // CECPQ1 ciphers must be explicitly enabled. |
| 2157 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2158 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2159 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2160 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2161 | for _, protocol := range []protocol{tls, dtls} { |
| 2162 | var prefix string |
| 2163 | if protocol == dtls { |
| 2164 | if !ver.hasDTLS { |
| 2165 | continue |
| 2166 | } |
| 2167 | prefix = "D" |
| 2168 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2169 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2170 | var shouldServerFail, shouldClientFail bool |
| 2171 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2172 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2173 | // a BoringSSL server will never select it |
| 2174 | // because the extension is missing. |
| 2175 | shouldServerFail = true |
| 2176 | } |
| 2177 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2178 | shouldClientFail = true |
| 2179 | shouldServerFail = true |
| 2180 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2181 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2182 | shouldClientFail = true |
| 2183 | shouldServerFail = true |
| 2184 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2185 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2186 | shouldClientFail = true |
| 2187 | shouldServerFail = true |
| 2188 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2189 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2190 | var expectedServerError, expectedClientError string |
| 2191 | if shouldServerFail { |
| 2192 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2193 | } |
| 2194 | if shouldClientFail { |
| 2195 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2196 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2197 | |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2198 | // TODO(davidben,svaldez): Implement resumption for TLS 1.3. |
| 2199 | resumeSession := ver.version < VersionTLS13 |
| 2200 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2201 | testCases = append(testCases, testCase{ |
| 2202 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2203 | protocol: protocol, |
| 2204 | |
| 2205 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2206 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2207 | MinVersion: ver.version, |
| 2208 | MaxVersion: ver.version, |
| 2209 | CipherSuites: []uint16{suite.id}, |
| 2210 | Certificates: []Certificate{cert}, |
| 2211 | PreSharedKey: []byte(psk), |
| 2212 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2213 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2214 | EnableAllCiphers: shouldServerFail, |
| 2215 | IgnorePeerCipherPreferences: shouldServerFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2216 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2217 | }, |
| 2218 | certFile: certFile, |
| 2219 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2220 | flags: flags, |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2221 | resumeSession: resumeSession, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2222 | shouldFail: shouldServerFail, |
| 2223 | expectedError: expectedServerError, |
| 2224 | }) |
| 2225 | |
| 2226 | testCases = append(testCases, testCase{ |
| 2227 | testType: clientTest, |
| 2228 | protocol: protocol, |
| 2229 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2230 | config: Config{ |
| 2231 | MinVersion: ver.version, |
| 2232 | MaxVersion: ver.version, |
| 2233 | CipherSuites: []uint16{suite.id}, |
| 2234 | Certificates: []Certificate{cert}, |
| 2235 | PreSharedKey: []byte(psk), |
| 2236 | PreSharedKeyIdentity: pskIdentity, |
| 2237 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2238 | EnableAllCiphers: shouldClientFail, |
| 2239 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2240 | }, |
| 2241 | }, |
| 2242 | flags: flags, |
David Benjamin | 9deb117 | 2016-07-13 17:13:49 -0400 | [diff] [blame] | 2243 | resumeSession: resumeSession, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2244 | shouldFail: shouldClientFail, |
| 2245 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2246 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2247 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2248 | if !shouldClientFail { |
| 2249 | // Ensure the maximum record size is accepted. |
| 2250 | testCases = append(testCases, testCase{ |
| 2251 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2252 | config: Config{ |
| 2253 | MinVersion: ver.version, |
| 2254 | MaxVersion: ver.version, |
| 2255 | CipherSuites: []uint16{suite.id}, |
| 2256 | Certificates: []Certificate{cert}, |
| 2257 | PreSharedKey: []byte(psk), |
| 2258 | PreSharedKeyIdentity: pskIdentity, |
| 2259 | }, |
| 2260 | flags: flags, |
| 2261 | messageLen: maxPlaintext, |
| 2262 | }) |
| 2263 | } |
| 2264 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2265 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2266 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2267 | |
| 2268 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2269 | name: "NoSharedCipher", |
| 2270 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2271 | MaxVersion: VersionTLS12, |
| 2272 | CipherSuites: []uint16{}, |
| 2273 | }, |
| 2274 | shouldFail: true, |
| 2275 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2276 | }) |
| 2277 | |
| 2278 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2279 | name: "NoSharedCipher-TLS13", |
| 2280 | config: Config{ |
| 2281 | MaxVersion: VersionTLS13, |
| 2282 | CipherSuites: []uint16{}, |
| 2283 | }, |
| 2284 | shouldFail: true, |
| 2285 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2286 | }) |
| 2287 | |
| 2288 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2289 | name: "UnsupportedCipherSuite", |
| 2290 | config: Config{ |
| 2291 | MaxVersion: VersionTLS12, |
| 2292 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 2293 | Bugs: ProtocolBugs{ |
| 2294 | IgnorePeerCipherPreferences: true, |
| 2295 | }, |
| 2296 | }, |
| 2297 | flags: []string{"-cipher", "DEFAULT:!RC4"}, |
| 2298 | shouldFail: true, |
| 2299 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2300 | }) |
| 2301 | |
| 2302 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2303 | name: "ServerHelloBogusCipher", |
| 2304 | config: Config{ |
| 2305 | MaxVersion: VersionTLS12, |
| 2306 | Bugs: ProtocolBugs{ |
| 2307 | SendCipherSuite: bogusCipher, |
| 2308 | }, |
| 2309 | }, |
| 2310 | shouldFail: true, |
| 2311 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2312 | }) |
| 2313 | testCases = append(testCases, testCase{ |
| 2314 | name: "ServerHelloBogusCipher-TLS13", |
| 2315 | config: Config{ |
| 2316 | MaxVersion: VersionTLS13, |
| 2317 | Bugs: ProtocolBugs{ |
| 2318 | SendCipherSuite: bogusCipher, |
| 2319 | }, |
| 2320 | }, |
| 2321 | shouldFail: true, |
| 2322 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2323 | }) |
| 2324 | |
| 2325 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2326 | name: "WeakDH", |
| 2327 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2328 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2329 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2330 | Bugs: ProtocolBugs{ |
| 2331 | // This is a 1023-bit prime number, generated |
| 2332 | // with: |
| 2333 | // openssl gendh 1023 | openssl asn1parse -i |
| 2334 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2335 | }, |
| 2336 | }, |
| 2337 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2338 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2339 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2340 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2341 | testCases = append(testCases, testCase{ |
| 2342 | name: "SillyDH", |
| 2343 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2344 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2345 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2346 | Bugs: ProtocolBugs{ |
| 2347 | // This is a 4097-bit prime number, generated |
| 2348 | // with: |
| 2349 | // openssl gendh 4097 | openssl asn1parse -i |
| 2350 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2351 | }, |
| 2352 | }, |
| 2353 | shouldFail: true, |
| 2354 | expectedError: ":DH_P_TOO_LONG:", |
| 2355 | }) |
| 2356 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2357 | // This test ensures that Diffie-Hellman public values are padded with |
| 2358 | // zeros so that they're the same length as the prime. This is to avoid |
| 2359 | // hitting a bug in yaSSL. |
| 2360 | testCases = append(testCases, testCase{ |
| 2361 | testType: serverTest, |
| 2362 | name: "DHPublicValuePadded", |
| 2363 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2364 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2365 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2366 | Bugs: ProtocolBugs{ |
| 2367 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2368 | }, |
| 2369 | }, |
| 2370 | flags: []string{"-use-sparse-dh-prime"}, |
| 2371 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2372 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2373 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2374 | testCases = append(testCases, testCase{ |
| 2375 | testType: serverTest, |
| 2376 | name: "UnknownCipher", |
| 2377 | config: Config{ |
| 2378 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2379 | }, |
| 2380 | }) |
| 2381 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2382 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2383 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2384 | // cipher lists and then a connection is made for each member of |
| 2385 | // expectations. The cipher suite that the server selects must match |
| 2386 | // the specified one. |
| 2387 | var versionSpecificCiphersTest = []struct { |
| 2388 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2389 | // expectations is a map from TLS version to cipher suite id. |
| 2390 | expectations map[uint16]uint16 |
| 2391 | }{ |
| 2392 | { |
| 2393 | // Test that the null case (where no version-specific ciphers are set) |
| 2394 | // works as expected. |
| 2395 | "RC4-SHA:AES128-SHA", // default ciphers |
| 2396 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2397 | "", // no ciphers specifically for TLS ≥ 1.1 |
| 2398 | map[uint16]uint16{ |
| 2399 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2400 | VersionTLS10: TLS_RSA_WITH_RC4_128_SHA, |
| 2401 | VersionTLS11: TLS_RSA_WITH_RC4_128_SHA, |
| 2402 | VersionTLS12: TLS_RSA_WITH_RC4_128_SHA, |
| 2403 | }, |
| 2404 | }, |
| 2405 | { |
| 2406 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2407 | // cipher. |
| 2408 | "RC4-SHA:AES128-SHA", // default |
| 2409 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2410 | "", // no ciphers specifically for TLS ≥ 1.1 |
| 2411 | map[uint16]uint16{ |
| 2412 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2413 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2414 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2415 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2416 | }, |
| 2417 | }, |
| 2418 | { |
| 2419 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2420 | // cipher. |
| 2421 | "RC4-SHA:AES128-SHA", // default |
| 2422 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2423 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
| 2424 | map[uint16]uint16{ |
| 2425 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2426 | VersionTLS10: TLS_RSA_WITH_RC4_128_SHA, |
| 2427 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2428 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2429 | }, |
| 2430 | }, |
| 2431 | { |
| 2432 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2433 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
| 2434 | "RC4-SHA:AES128-SHA", // default |
| 2435 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2436 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
| 2437 | map[uint16]uint16{ |
| 2438 | VersionSSL30: TLS_RSA_WITH_RC4_128_SHA, |
| 2439 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2440 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2441 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2442 | }, |
| 2443 | }, |
| 2444 | } |
| 2445 | |
| 2446 | for i, test := range versionSpecificCiphersTest { |
| 2447 | for version, expectedCipherSuite := range test.expectations { |
| 2448 | flags := []string{"-cipher", test.ciphersDefault} |
| 2449 | if len(test.ciphersTLS10) > 0 { |
| 2450 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2451 | } |
| 2452 | if len(test.ciphersTLS11) > 0 { |
| 2453 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2454 | } |
| 2455 | |
| 2456 | testCases = append(testCases, testCase{ |
| 2457 | testType: serverTest, |
| 2458 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2459 | config: Config{ |
| 2460 | MaxVersion: version, |
| 2461 | MinVersion: version, |
| 2462 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA}, |
| 2463 | }, |
| 2464 | flags: flags, |
| 2465 | expectedCipher: expectedCipherSuite, |
| 2466 | }) |
| 2467 | } |
| 2468 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2469 | } |
| 2470 | |
| 2471 | func addBadECDSASignatureTests() { |
| 2472 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2473 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2474 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2475 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2476 | config: Config{ |
| 2477 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2478 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2479 | Bugs: ProtocolBugs{ |
| 2480 | BadECDSAR: badR, |
| 2481 | BadECDSAS: badS, |
| 2482 | }, |
| 2483 | }, |
| 2484 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2485 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2486 | }) |
| 2487 | } |
| 2488 | } |
| 2489 | } |
| 2490 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2491 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2492 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2493 | name: "MaxCBCPadding", |
| 2494 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2495 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2496 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2497 | Bugs: ProtocolBugs{ |
| 2498 | MaxPadding: true, |
| 2499 | }, |
| 2500 | }, |
| 2501 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2502 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2503 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2504 | name: "BadCBCPadding", |
| 2505 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2506 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2507 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2508 | Bugs: ProtocolBugs{ |
| 2509 | PaddingFirstByteBad: true, |
| 2510 | }, |
| 2511 | }, |
| 2512 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2513 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2514 | }) |
| 2515 | // OpenSSL previously had an issue where the first byte of padding in |
| 2516 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2517 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2518 | name: "BadCBCPadding255", |
| 2519 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2520 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2521 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2522 | Bugs: ProtocolBugs{ |
| 2523 | MaxPadding: true, |
| 2524 | PaddingFirstByteBadIf255: true, |
| 2525 | }, |
| 2526 | }, |
| 2527 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2528 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2529 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2530 | }) |
| 2531 | } |
| 2532 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2533 | func addCBCSplittingTests() { |
| 2534 | testCases = append(testCases, testCase{ |
| 2535 | name: "CBCRecordSplitting", |
| 2536 | config: Config{ |
| 2537 | MaxVersion: VersionTLS10, |
| 2538 | MinVersion: VersionTLS10, |
| 2539 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2540 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2541 | messageLen: -1, // read until EOF |
| 2542 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2543 | flags: []string{ |
| 2544 | "-async", |
| 2545 | "-write-different-record-sizes", |
| 2546 | "-cbc-record-splitting", |
| 2547 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2548 | }) |
| 2549 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2550 | name: "CBCRecordSplittingPartialWrite", |
| 2551 | config: Config{ |
| 2552 | MaxVersion: VersionTLS10, |
| 2553 | MinVersion: VersionTLS10, |
| 2554 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2555 | }, |
| 2556 | messageLen: -1, // read until EOF |
| 2557 | flags: []string{ |
| 2558 | "-async", |
| 2559 | "-write-different-record-sizes", |
| 2560 | "-cbc-record-splitting", |
| 2561 | "-partial-write", |
| 2562 | }, |
| 2563 | }) |
| 2564 | } |
| 2565 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2566 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2567 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2568 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2569 | certPool := x509.NewCertPool() |
| 2570 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2571 | if err != nil { |
| 2572 | panic(err) |
| 2573 | } |
| 2574 | certPool.AddCert(cert) |
| 2575 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2576 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2577 | testCases = append(testCases, testCase{ |
| 2578 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2579 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2580 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2581 | MinVersion: ver.version, |
| 2582 | MaxVersion: ver.version, |
| 2583 | ClientAuth: RequireAnyClientCert, |
| 2584 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2585 | }, |
| 2586 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2587 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2588 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2589 | }, |
| 2590 | }) |
| 2591 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2592 | testType: serverTest, |
| 2593 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2594 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2595 | MinVersion: ver.version, |
| 2596 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2597 | Certificates: []Certificate{rsaCertificate}, |
| 2598 | }, |
| 2599 | flags: []string{"-require-any-client-certificate"}, |
| 2600 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2601 | if ver.version != VersionSSL30 { |
| 2602 | testCases = append(testCases, testCase{ |
| 2603 | testType: serverTest, |
| 2604 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2605 | config: Config{ |
| 2606 | MinVersion: ver.version, |
| 2607 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2608 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2609 | }, |
| 2610 | flags: []string{"-require-any-client-certificate"}, |
| 2611 | }) |
| 2612 | testCases = append(testCases, testCase{ |
| 2613 | testType: clientTest, |
| 2614 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2615 | config: Config{ |
| 2616 | MinVersion: ver.version, |
| 2617 | MaxVersion: ver.version, |
| 2618 | ClientAuth: RequireAnyClientCert, |
| 2619 | ClientCAs: certPool, |
| 2620 | }, |
| 2621 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2622 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2623 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2624 | }, |
| 2625 | }) |
| 2626 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2627 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2628 | |
| 2629 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2630 | name: "NoClientCertificate", |
| 2631 | config: Config{ |
| 2632 | MaxVersion: VersionTLS12, |
| 2633 | ClientAuth: RequireAnyClientCert, |
| 2634 | }, |
| 2635 | shouldFail: true, |
| 2636 | expectedLocalError: "client didn't provide a certificate", |
| 2637 | }) |
| 2638 | |
| 2639 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2640 | name: "NoClientCertificate-TLS13", |
| 2641 | config: Config{ |
| 2642 | MaxVersion: VersionTLS13, |
| 2643 | ClientAuth: RequireAnyClientCert, |
| 2644 | }, |
| 2645 | shouldFail: true, |
| 2646 | expectedLocalError: "client didn't provide a certificate", |
| 2647 | }) |
| 2648 | |
| 2649 | testCases = append(testCases, testCase{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2650 | testType: serverTest, |
| 2651 | name: "RequireAnyClientCertificate", |
| 2652 | config: Config{ |
| 2653 | MaxVersion: VersionTLS12, |
| 2654 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2655 | flags: []string{"-require-any-client-certificate"}, |
| 2656 | shouldFail: true, |
| 2657 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2658 | }) |
| 2659 | |
| 2660 | testCases = append(testCases, testCase{ |
| 2661 | testType: serverTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2662 | name: "RequireAnyClientCertificate-TLS13", |
| 2663 | config: Config{ |
| 2664 | MaxVersion: VersionTLS13, |
| 2665 | }, |
| 2666 | flags: []string{"-require-any-client-certificate"}, |
| 2667 | shouldFail: true, |
| 2668 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2669 | }) |
| 2670 | |
| 2671 | testCases = append(testCases, testCase{ |
| 2672 | testType: serverTest, |
David Benjamin | df28c3a | 2016-03-10 16:11:51 -0500 | [diff] [blame] | 2673 | name: "RequireAnyClientCertificate-SSL3", |
| 2674 | config: Config{ |
| 2675 | MaxVersion: VersionSSL30, |
| 2676 | }, |
| 2677 | flags: []string{"-require-any-client-certificate"}, |
| 2678 | shouldFail: true, |
| 2679 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2680 | }) |
| 2681 | |
| 2682 | testCases = append(testCases, testCase{ |
| 2683 | testType: serverTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2684 | name: "SkipClientCertificate", |
| 2685 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2686 | MaxVersion: VersionTLS12, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2687 | Bugs: ProtocolBugs{ |
| 2688 | SkipClientCertificate: true, |
| 2689 | }, |
| 2690 | }, |
| 2691 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2692 | flags: []string{"-verify-peer"}, |
| 2693 | shouldFail: true, |
David Benjamin | df28c3a | 2016-03-10 16:11:51 -0500 | [diff] [blame] | 2694 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2695 | }) |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2696 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2697 | testCases = append(testCases, testCase{ |
| 2698 | testType: serverTest, |
| 2699 | name: "SkipClientCertificate-TLS13", |
| 2700 | config: Config{ |
| 2701 | MaxVersion: VersionTLS13, |
| 2702 | Bugs: ProtocolBugs{ |
| 2703 | SkipClientCertificate: true, |
| 2704 | }, |
| 2705 | }, |
| 2706 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2707 | flags: []string{"-verify-peer"}, |
| 2708 | shouldFail: true, |
| 2709 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2710 | }) |
| 2711 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2712 | // Client auth is only legal in certificate-based ciphers. |
| 2713 | testCases = append(testCases, testCase{ |
| 2714 | testType: clientTest, |
| 2715 | name: "ClientAuth-PSK", |
| 2716 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2717 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2718 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2719 | PreSharedKey: []byte("secret"), |
| 2720 | ClientAuth: RequireAnyClientCert, |
| 2721 | }, |
| 2722 | flags: []string{ |
| 2723 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2724 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2725 | "-psk", "secret", |
| 2726 | }, |
| 2727 | shouldFail: true, |
| 2728 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2729 | }) |
| 2730 | testCases = append(testCases, testCase{ |
| 2731 | testType: clientTest, |
| 2732 | name: "ClientAuth-ECDHE_PSK", |
| 2733 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2734 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2735 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2736 | PreSharedKey: []byte("secret"), |
| 2737 | ClientAuth: RequireAnyClientCert, |
| 2738 | }, |
| 2739 | flags: []string{ |
| 2740 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2741 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2742 | "-psk", "secret", |
| 2743 | }, |
| 2744 | shouldFail: true, |
| 2745 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2746 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 2747 | |
| 2748 | // Regression test for a bug where the client CA list, if explicitly |
| 2749 | // set to NULL, was mis-encoded. |
| 2750 | testCases = append(testCases, testCase{ |
| 2751 | testType: serverTest, |
| 2752 | name: "Null-Client-CA-List", |
| 2753 | config: Config{ |
| 2754 | MaxVersion: VersionTLS12, |
| 2755 | Certificates: []Certificate{rsaCertificate}, |
| 2756 | }, |
| 2757 | flags: []string{ |
| 2758 | "-require-any-client-certificate", |
| 2759 | "-use-null-client-ca-list", |
| 2760 | }, |
| 2761 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2762 | } |
| 2763 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2764 | func addExtendedMasterSecretTests() { |
| 2765 | const expectEMSFlag = "-expect-extended-master-secret" |
| 2766 | |
| 2767 | for _, with := range []bool{false, true} { |
| 2768 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2769 | if with { |
| 2770 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2771 | } |
| 2772 | |
| 2773 | for _, isClient := range []bool{false, true} { |
| 2774 | suffix := "-Server" |
| 2775 | testType := serverTest |
| 2776 | if isClient { |
| 2777 | suffix = "-Client" |
| 2778 | testType = clientTest |
| 2779 | } |
| 2780 | |
| 2781 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2782 | // In TLS 1.3, the extension is irrelevant and |
| 2783 | // always reports as enabled. |
| 2784 | var flags []string |
| 2785 | if with || ver.version >= VersionTLS13 { |
| 2786 | flags = []string{expectEMSFlag} |
| 2787 | } |
| 2788 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2789 | test := testCase{ |
| 2790 | testType: testType, |
| 2791 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 2792 | config: Config{ |
| 2793 | MinVersion: ver.version, |
| 2794 | MaxVersion: ver.version, |
| 2795 | Bugs: ProtocolBugs{ |
| 2796 | NoExtendedMasterSecret: !with, |
| 2797 | RequireExtendedMasterSecret: with, |
| 2798 | }, |
| 2799 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2800 | flags: flags, |
| 2801 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2802 | } |
| 2803 | if test.shouldFail { |
| 2804 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 2805 | } |
| 2806 | testCases = append(testCases, test) |
| 2807 | } |
| 2808 | } |
| 2809 | } |
| 2810 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2811 | for _, isClient := range []bool{false, true} { |
| 2812 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 2813 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 2814 | boolToWord := func(b bool) string { |
| 2815 | if b { |
| 2816 | return "Yes" |
| 2817 | } |
| 2818 | return "No" |
| 2819 | } |
| 2820 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 2821 | if isClient { |
| 2822 | suffix += "Client" |
| 2823 | } else { |
| 2824 | suffix += "Server" |
| 2825 | } |
| 2826 | |
| 2827 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2828 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2829 | Bugs: ProtocolBugs{ |
| 2830 | RequireExtendedMasterSecret: true, |
| 2831 | }, |
| 2832 | } |
| 2833 | |
| 2834 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2835 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 2836 | Bugs: ProtocolBugs{ |
| 2837 | NoExtendedMasterSecret: true, |
| 2838 | }, |
| 2839 | } |
| 2840 | |
| 2841 | test := testCase{ |
| 2842 | name: "ExtendedMasterSecret-" + suffix, |
| 2843 | resumeSession: true, |
| 2844 | } |
| 2845 | |
| 2846 | if !isClient { |
| 2847 | test.testType = serverTest |
| 2848 | } |
| 2849 | |
| 2850 | if supportedInFirstConnection { |
| 2851 | test.config = supportedConfig |
| 2852 | } else { |
| 2853 | test.config = noSupportConfig |
| 2854 | } |
| 2855 | |
| 2856 | if supportedInResumeConnection { |
| 2857 | test.resumeConfig = &supportedConfig |
| 2858 | } else { |
| 2859 | test.resumeConfig = &noSupportConfig |
| 2860 | } |
| 2861 | |
| 2862 | switch suffix { |
| 2863 | case "YesToYes-Client", "YesToYes-Server": |
| 2864 | // When a session is resumed, it should |
| 2865 | // still be aware that its master |
| 2866 | // secret was generated via EMS and |
| 2867 | // thus it's safe to use tls-unique. |
| 2868 | test.flags = []string{expectEMSFlag} |
| 2869 | case "NoToYes-Server": |
| 2870 | // If an original connection did not |
| 2871 | // contain EMS, but a resumption |
| 2872 | // handshake does, then a server should |
| 2873 | // not resume the session. |
| 2874 | test.expectResumeRejected = true |
| 2875 | case "YesToNo-Server": |
| 2876 | // Resuming an EMS session without the |
| 2877 | // EMS extension should cause the |
| 2878 | // server to abort the connection. |
| 2879 | test.shouldFail = true |
| 2880 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 2881 | case "NoToYes-Client": |
| 2882 | // A client should abort a connection |
| 2883 | // where the server resumed a non-EMS |
| 2884 | // session but echoed the EMS |
| 2885 | // extension. |
| 2886 | test.shouldFail = true |
| 2887 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 2888 | case "YesToNo-Client": |
| 2889 | // A client should abort a connection |
| 2890 | // where the server didn't echo EMS |
| 2891 | // when the session used it. |
| 2892 | test.shouldFail = true |
| 2893 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 2894 | } |
| 2895 | |
| 2896 | testCases = append(testCases, test) |
| 2897 | } |
| 2898 | } |
| 2899 | } |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2900 | } |
| 2901 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 2902 | type stateMachineTestConfig struct { |
| 2903 | protocol protocol |
| 2904 | async bool |
| 2905 | splitHandshake, packHandshakeFlight bool |
| 2906 | } |
| 2907 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 2908 | // Adds tests that try to cover the range of the handshake state machine, under |
| 2909 | // various conditions. Some of these are redundant with other tests, but they |
| 2910 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 2911 | func addAllStateMachineCoverageTests() { |
| 2912 | for _, async := range []bool{false, true} { |
| 2913 | for _, protocol := range []protocol{tls, dtls} { |
| 2914 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2915 | protocol: protocol, |
| 2916 | async: async, |
| 2917 | }) |
| 2918 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2919 | protocol: protocol, |
| 2920 | async: async, |
| 2921 | splitHandshake: true, |
| 2922 | }) |
| 2923 | if protocol == tls { |
| 2924 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 2925 | protocol: protocol, |
| 2926 | async: async, |
| 2927 | packHandshakeFlight: true, |
| 2928 | }) |
| 2929 | } |
| 2930 | } |
| 2931 | } |
| 2932 | } |
| 2933 | |
| 2934 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2935 | var tests []testCase |
| 2936 | |
| 2937 | // Basic handshake, with resumption. Client and server, |
| 2938 | // session ID and session ticket. |
| 2939 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2940 | name: "Basic-Client", |
| 2941 | config: Config{ |
| 2942 | MaxVersion: VersionTLS12, |
| 2943 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2944 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2945 | // Ensure session tickets are used, not session IDs. |
| 2946 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2947 | }) |
| 2948 | tests = append(tests, testCase{ |
| 2949 | name: "Basic-Client-RenewTicket", |
| 2950 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2951 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2952 | Bugs: ProtocolBugs{ |
| 2953 | RenewTicketOnResume: true, |
| 2954 | }, |
| 2955 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2956 | flags: []string{"-expect-ticket-renewal"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2957 | resumeSession: true, |
| 2958 | }) |
| 2959 | tests = append(tests, testCase{ |
| 2960 | name: "Basic-Client-NoTicket", |
| 2961 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2962 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2963 | SessionTicketsDisabled: true, |
| 2964 | }, |
| 2965 | resumeSession: true, |
| 2966 | }) |
| 2967 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2968 | name: "Basic-Client-Implicit", |
| 2969 | config: Config{ |
| 2970 | MaxVersion: VersionTLS12, |
| 2971 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2972 | flags: []string{"-implicit-handshake"}, |
| 2973 | resumeSession: true, |
| 2974 | }) |
| 2975 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2976 | testType: serverTest, |
| 2977 | name: "Basic-Server", |
| 2978 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2979 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2980 | Bugs: ProtocolBugs{ |
| 2981 | RequireSessionTickets: true, |
| 2982 | }, |
| 2983 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2984 | resumeSession: true, |
| 2985 | }) |
| 2986 | tests = append(tests, testCase{ |
| 2987 | testType: serverTest, |
| 2988 | name: "Basic-Server-NoTickets", |
| 2989 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2990 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 2991 | SessionTicketsDisabled: true, |
| 2992 | }, |
| 2993 | resumeSession: true, |
| 2994 | }) |
| 2995 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2996 | testType: serverTest, |
| 2997 | name: "Basic-Server-Implicit", |
| 2998 | config: Config{ |
| 2999 | MaxVersion: VersionTLS12, |
| 3000 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3001 | flags: []string{"-implicit-handshake"}, |
| 3002 | resumeSession: true, |
| 3003 | }) |
| 3004 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3005 | testType: serverTest, |
| 3006 | name: "Basic-Server-EarlyCallback", |
| 3007 | config: Config{ |
| 3008 | MaxVersion: VersionTLS12, |
| 3009 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3010 | flags: []string{"-use-early-callback"}, |
| 3011 | resumeSession: true, |
| 3012 | }) |
| 3013 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3014 | // TLS 1.3 basic handshake shapes. |
| 3015 | tests = append(tests, testCase{ |
| 3016 | name: "TLS13-1RTT-Client", |
| 3017 | config: Config{ |
| 3018 | MaxVersion: VersionTLS13, |
| 3019 | }, |
| 3020 | }) |
| 3021 | tests = append(tests, testCase{ |
| 3022 | testType: serverTest, |
| 3023 | name: "TLS13-1RTT-Server", |
| 3024 | config: Config{ |
| 3025 | MaxVersion: VersionTLS13, |
| 3026 | }, |
| 3027 | }) |
| 3028 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3029 | // TLS client auth. |
| 3030 | tests = append(tests, testCase{ |
| 3031 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3032 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3033 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3034 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3035 | ClientAuth: RequestClientCert, |
| 3036 | }, |
| 3037 | }) |
| 3038 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3039 | testType: serverTest, |
| 3040 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3041 | config: Config{ |
| 3042 | MaxVersion: VersionTLS12, |
| 3043 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3044 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3045 | flags: []string{"-verify-peer"}, |
| 3046 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3047 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3048 | tests = append(tests, testCase{ |
| 3049 | testType: clientTest, |
| 3050 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3051 | config: Config{ |
| 3052 | MaxVersion: VersionSSL30, |
| 3053 | ClientAuth: RequestClientCert, |
| 3054 | }, |
| 3055 | }) |
| 3056 | tests = append(tests, testCase{ |
| 3057 | testType: serverTest, |
| 3058 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3059 | config: Config{ |
| 3060 | MaxVersion: VersionSSL30, |
| 3061 | }, |
| 3062 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3063 | flags: []string{"-verify-peer"}, |
| 3064 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3065 | tests = append(tests, testCase{ |
| 3066 | testType: clientTest, |
| 3067 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3068 | config: Config{ |
| 3069 | MaxVersion: VersionTLS13, |
| 3070 | ClientAuth: RequestClientCert, |
| 3071 | }, |
| 3072 | }) |
| 3073 | tests = append(tests, testCase{ |
| 3074 | testType: serverTest, |
| 3075 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3076 | config: Config{ |
| 3077 | MaxVersion: VersionTLS13, |
| 3078 | }, |
| 3079 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3080 | flags: []string{"-verify-peer"}, |
| 3081 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3082 | } |
| 3083 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3084 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3085 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3086 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3087 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3088 | ClientAuth: RequireAnyClientCert, |
| 3089 | }, |
| 3090 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3091 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3092 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3093 | }, |
| 3094 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3095 | tests = append(tests, testCase{ |
| 3096 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3097 | name: "ClientAuth-RSA-Client-TLS13", |
| 3098 | config: Config{ |
| 3099 | MaxVersion: VersionTLS13, |
| 3100 | ClientAuth: RequireAnyClientCert, |
| 3101 | }, |
| 3102 | flags: []string{ |
| 3103 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3104 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3105 | }, |
| 3106 | }) |
| 3107 | tests = append(tests, testCase{ |
| 3108 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3109 | name: "ClientAuth-ECDSA-Client", |
| 3110 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3111 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3112 | ClientAuth: RequireAnyClientCert, |
| 3113 | }, |
| 3114 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3115 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3116 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3117 | }, |
| 3118 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3119 | tests = append(tests, testCase{ |
| 3120 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3121 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3122 | config: Config{ |
| 3123 | MaxVersion: VersionTLS13, |
| 3124 | ClientAuth: RequireAnyClientCert, |
| 3125 | }, |
| 3126 | flags: []string{ |
| 3127 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3128 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3129 | }, |
| 3130 | }) |
| 3131 | tests = append(tests, testCase{ |
| 3132 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3133 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3134 | config: Config{ |
| 3135 | MaxVersion: VersionTLS12, |
| 3136 | ClientAuth: RequestClientCert, |
| 3137 | }, |
| 3138 | flags: []string{"-use-old-client-cert-callback"}, |
| 3139 | }) |
| 3140 | tests = append(tests, testCase{ |
| 3141 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3142 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3143 | config: Config{ |
| 3144 | MaxVersion: VersionTLS13, |
| 3145 | ClientAuth: RequestClientCert, |
| 3146 | }, |
| 3147 | flags: []string{"-use-old-client-cert-callback"}, |
| 3148 | }) |
| 3149 | tests = append(tests, testCase{ |
| 3150 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3151 | name: "ClientAuth-OldCallback", |
| 3152 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3153 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3154 | ClientAuth: RequireAnyClientCert, |
| 3155 | }, |
| 3156 | flags: []string{ |
| 3157 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3158 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3159 | "-use-old-client-cert-callback", |
| 3160 | }, |
| 3161 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3162 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3163 | testType: clientTest, |
| 3164 | name: "ClientAuth-OldCallback-TLS13", |
| 3165 | config: Config{ |
| 3166 | MaxVersion: VersionTLS13, |
| 3167 | ClientAuth: RequireAnyClientCert, |
| 3168 | }, |
| 3169 | flags: []string{ |
| 3170 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3171 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3172 | "-use-old-client-cert-callback", |
| 3173 | }, |
| 3174 | }) |
| 3175 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3176 | testType: serverTest, |
| 3177 | name: "ClientAuth-Server", |
| 3178 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3179 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3180 | Certificates: []Certificate{rsaCertificate}, |
| 3181 | }, |
| 3182 | flags: []string{"-require-any-client-certificate"}, |
| 3183 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3184 | tests = append(tests, testCase{ |
| 3185 | testType: serverTest, |
| 3186 | name: "ClientAuth-Server-TLS13", |
| 3187 | config: Config{ |
| 3188 | MaxVersion: VersionTLS13, |
| 3189 | Certificates: []Certificate{rsaCertificate}, |
| 3190 | }, |
| 3191 | flags: []string{"-require-any-client-certificate"}, |
| 3192 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3193 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3194 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3195 | tests = append(tests, testCase{ |
| 3196 | testType: serverTest, |
| 3197 | name: "Basic-Server-RSA", |
| 3198 | config: Config{ |
| 3199 | MaxVersion: VersionTLS12, |
| 3200 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3201 | }, |
| 3202 | flags: []string{ |
| 3203 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3204 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3205 | }, |
| 3206 | }) |
| 3207 | tests = append(tests, testCase{ |
| 3208 | testType: serverTest, |
| 3209 | name: "Basic-Server-ECDHE-RSA", |
| 3210 | config: Config{ |
| 3211 | MaxVersion: VersionTLS12, |
| 3212 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3213 | }, |
| 3214 | flags: []string{ |
| 3215 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3216 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3217 | }, |
| 3218 | }) |
| 3219 | tests = append(tests, testCase{ |
| 3220 | testType: serverTest, |
| 3221 | name: "Basic-Server-ECDHE-ECDSA", |
| 3222 | config: Config{ |
| 3223 | MaxVersion: VersionTLS12, |
| 3224 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3225 | }, |
| 3226 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3227 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3228 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3229 | }, |
| 3230 | }) |
| 3231 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3232 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3233 | tests = append(tests, testCase{ |
| 3234 | name: "SessionTicketsDisabled-Client", |
| 3235 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3236 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3237 | SessionTicketsDisabled: true, |
| 3238 | }, |
| 3239 | }) |
| 3240 | tests = append(tests, testCase{ |
| 3241 | testType: serverTest, |
| 3242 | name: "SessionTicketsDisabled-Server", |
| 3243 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3244 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3245 | SessionTicketsDisabled: true, |
| 3246 | }, |
| 3247 | }) |
| 3248 | |
| 3249 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3250 | // identity hint. |
| 3251 | tests = append(tests, testCase{ |
| 3252 | name: "EmptyPSKHint-Client", |
| 3253 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3254 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3255 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3256 | PreSharedKey: []byte("secret"), |
| 3257 | }, |
| 3258 | flags: []string{"-psk", "secret"}, |
| 3259 | }) |
| 3260 | tests = append(tests, testCase{ |
| 3261 | testType: serverTest, |
| 3262 | name: "EmptyPSKHint-Server", |
| 3263 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3264 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3265 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3266 | PreSharedKey: []byte("secret"), |
| 3267 | }, |
| 3268 | flags: []string{"-psk", "secret"}, |
| 3269 | }) |
| 3270 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3271 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3272 | tests = append(tests, testCase{ |
| 3273 | testType: clientTest, |
| 3274 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3275 | config: Config{ |
| 3276 | MaxVersion: VersionTLS12, |
| 3277 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3278 | flags: []string{ |
| 3279 | "-enable-ocsp-stapling", |
| 3280 | "-expect-ocsp-response", |
| 3281 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3282 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3283 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3284 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3285 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3286 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3287 | testType: serverTest, |
| 3288 | name: "OCSPStapling-Server", |
| 3289 | config: Config{ |
| 3290 | MaxVersion: VersionTLS12, |
| 3291 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3292 | expectedOCSPResponse: testOCSPResponse, |
| 3293 | flags: []string{ |
| 3294 | "-ocsp-response", |
| 3295 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3296 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3297 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3298 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3299 | tests = append(tests, testCase{ |
| 3300 | testType: clientTest, |
| 3301 | name: "OCSPStapling-Client-TLS13", |
| 3302 | config: Config{ |
| 3303 | MaxVersion: VersionTLS13, |
| 3304 | }, |
| 3305 | flags: []string{ |
| 3306 | "-enable-ocsp-stapling", |
| 3307 | "-expect-ocsp-response", |
| 3308 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3309 | "-verify-peer", |
| 3310 | }, |
| 3311 | // TODO(davidben): Enable this when resumption is implemented |
| 3312 | // in TLS 1.3. |
| 3313 | resumeSession: false, |
| 3314 | }) |
| 3315 | tests = append(tests, testCase{ |
| 3316 | testType: serverTest, |
| 3317 | name: "OCSPStapling-Server-TLS13", |
| 3318 | config: Config{ |
| 3319 | MaxVersion: VersionTLS13, |
| 3320 | }, |
| 3321 | expectedOCSPResponse: testOCSPResponse, |
| 3322 | flags: []string{ |
| 3323 | "-ocsp-response", |
| 3324 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3325 | }, |
| 3326 | // TODO(davidben): Enable this when resumption is implemented |
| 3327 | // in TLS 1.3. |
| 3328 | resumeSession: false, |
| 3329 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3330 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3331 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3332 | for _, vers := range tlsVersions { |
| 3333 | if config.protocol == dtls && !vers.hasDTLS { |
| 3334 | continue |
| 3335 | } |
| 3336 | tests = append(tests, testCase{ |
| 3337 | testType: clientTest, |
| 3338 | name: "CertificateVerificationSucceed-" + vers.name, |
| 3339 | config: Config{ |
| 3340 | MaxVersion: vers.version, |
| 3341 | }, |
| 3342 | flags: []string{ |
| 3343 | "-verify-peer", |
| 3344 | }, |
| 3345 | }) |
| 3346 | tests = append(tests, testCase{ |
| 3347 | testType: clientTest, |
| 3348 | name: "CertificateVerificationFail-" + vers.name, |
| 3349 | config: Config{ |
| 3350 | MaxVersion: vers.version, |
| 3351 | }, |
| 3352 | flags: []string{ |
| 3353 | "-verify-fail", |
| 3354 | "-verify-peer", |
| 3355 | }, |
| 3356 | shouldFail: true, |
| 3357 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3358 | }) |
| 3359 | tests = append(tests, testCase{ |
| 3360 | testType: clientTest, |
| 3361 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3362 | config: Config{ |
| 3363 | MaxVersion: vers.version, |
| 3364 | }, |
| 3365 | flags: []string{ |
| 3366 | "-verify-fail", |
| 3367 | "-expect-verify-result", |
| 3368 | }, |
| 3369 | }) |
| 3370 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3371 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3372 | tests = append(tests, testCase{ |
| 3373 | name: "ShimSendAlert", |
| 3374 | flags: []string{"-send-alert"}, |
| 3375 | shimWritesFirst: true, |
| 3376 | shouldFail: true, |
| 3377 | expectedLocalError: "remote error: decompression failure", |
| 3378 | }) |
| 3379 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3380 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3381 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3382 | name: "Renegotiate-Client", |
| 3383 | config: Config{ |
| 3384 | MaxVersion: VersionTLS12, |
| 3385 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3386 | renegotiate: 1, |
| 3387 | flags: []string{ |
| 3388 | "-renegotiate-freely", |
| 3389 | "-expect-total-renegotiations", "1", |
| 3390 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3391 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3392 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3393 | tests = append(tests, testCase{ |
| 3394 | name: "SendHalfHelloRequest", |
| 3395 | config: Config{ |
| 3396 | MaxVersion: VersionTLS12, |
| 3397 | Bugs: ProtocolBugs{ |
| 3398 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3399 | }, |
| 3400 | }, |
| 3401 | sendHalfHelloRequest: true, |
| 3402 | flags: []string{"-renegotiate-ignore"}, |
| 3403 | shouldFail: true, |
| 3404 | expectedError: ":UNEXPECTED_RECORD:", |
| 3405 | }) |
| 3406 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3407 | // NPN on client and server; results in post-handshake message. |
| 3408 | tests = append(tests, testCase{ |
| 3409 | name: "NPN-Client", |
| 3410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3411 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3412 | NextProtos: []string{"foo"}, |
| 3413 | }, |
| 3414 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3415 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3416 | expectedNextProto: "foo", |
| 3417 | expectedNextProtoType: npn, |
| 3418 | }) |
| 3419 | tests = append(tests, testCase{ |
| 3420 | testType: serverTest, |
| 3421 | name: "NPN-Server", |
| 3422 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3423 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3424 | NextProtos: []string{"bar"}, |
| 3425 | }, |
| 3426 | flags: []string{ |
| 3427 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3428 | "-expect-next-proto", "bar", |
| 3429 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3430 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3431 | expectedNextProto: "bar", |
| 3432 | expectedNextProtoType: npn, |
| 3433 | }) |
| 3434 | |
| 3435 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3436 | |
| 3437 | // Client does False Start and negotiates NPN. |
| 3438 | tests = append(tests, testCase{ |
| 3439 | name: "FalseStart", |
| 3440 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3441 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3442 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3443 | NextProtos: []string{"foo"}, |
| 3444 | Bugs: ProtocolBugs{ |
| 3445 | ExpectFalseStart: true, |
| 3446 | }, |
| 3447 | }, |
| 3448 | flags: []string{ |
| 3449 | "-false-start", |
| 3450 | "-select-next-proto", "foo", |
| 3451 | }, |
| 3452 | shimWritesFirst: true, |
| 3453 | resumeSession: true, |
| 3454 | }) |
| 3455 | |
| 3456 | // Client does False Start and negotiates ALPN. |
| 3457 | tests = append(tests, testCase{ |
| 3458 | name: "FalseStart-ALPN", |
| 3459 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3460 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3461 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3462 | NextProtos: []string{"foo"}, |
| 3463 | Bugs: ProtocolBugs{ |
| 3464 | ExpectFalseStart: true, |
| 3465 | }, |
| 3466 | }, |
| 3467 | flags: []string{ |
| 3468 | "-false-start", |
| 3469 | "-advertise-alpn", "\x03foo", |
| 3470 | }, |
| 3471 | shimWritesFirst: true, |
| 3472 | resumeSession: true, |
| 3473 | }) |
| 3474 | |
| 3475 | // Client does False Start but doesn't explicitly call |
| 3476 | // SSL_connect. |
| 3477 | tests = append(tests, testCase{ |
| 3478 | name: "FalseStart-Implicit", |
| 3479 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3480 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3481 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3482 | NextProtos: []string{"foo"}, |
| 3483 | }, |
| 3484 | flags: []string{ |
| 3485 | "-implicit-handshake", |
| 3486 | "-false-start", |
| 3487 | "-advertise-alpn", "\x03foo", |
| 3488 | }, |
| 3489 | }) |
| 3490 | |
| 3491 | // False Start without session tickets. |
| 3492 | tests = append(tests, testCase{ |
| 3493 | name: "FalseStart-SessionTicketsDisabled", |
| 3494 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3495 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3496 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3497 | NextProtos: []string{"foo"}, |
| 3498 | SessionTicketsDisabled: true, |
| 3499 | Bugs: ProtocolBugs{ |
| 3500 | ExpectFalseStart: true, |
| 3501 | }, |
| 3502 | }, |
| 3503 | flags: []string{ |
| 3504 | "-false-start", |
| 3505 | "-select-next-proto", "foo", |
| 3506 | }, |
| 3507 | shimWritesFirst: true, |
| 3508 | }) |
| 3509 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 3510 | tests = append(tests, testCase{ |
| 3511 | name: "FalseStart-CECPQ1", |
| 3512 | config: Config{ |
| 3513 | MaxVersion: VersionTLS12, |
| 3514 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 3515 | NextProtos: []string{"foo"}, |
| 3516 | Bugs: ProtocolBugs{ |
| 3517 | ExpectFalseStart: true, |
| 3518 | }, |
| 3519 | }, |
| 3520 | flags: []string{ |
| 3521 | "-false-start", |
| 3522 | "-cipher", "DEFAULT:kCECPQ1", |
| 3523 | "-select-next-proto", "foo", |
| 3524 | }, |
| 3525 | shimWritesFirst: true, |
| 3526 | resumeSession: true, |
| 3527 | }) |
| 3528 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3529 | // Server parses a V2ClientHello. |
| 3530 | tests = append(tests, testCase{ |
| 3531 | testType: serverTest, |
| 3532 | name: "SendV2ClientHello", |
| 3533 | config: Config{ |
| 3534 | // Choose a cipher suite that does not involve |
| 3535 | // elliptic curves, so no extensions are |
| 3536 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3537 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3538 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 3539 | Bugs: ProtocolBugs{ |
| 3540 | SendV2ClientHello: true, |
| 3541 | }, |
| 3542 | }, |
| 3543 | }) |
| 3544 | |
| 3545 | // Client sends a Channel ID. |
| 3546 | tests = append(tests, testCase{ |
| 3547 | name: "ChannelID-Client", |
| 3548 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3549 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3550 | RequestChannelID: true, |
| 3551 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3552 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3553 | resumeSession: true, |
| 3554 | expectChannelID: true, |
| 3555 | }) |
| 3556 | |
| 3557 | // Server accepts a Channel ID. |
| 3558 | tests = append(tests, testCase{ |
| 3559 | testType: serverTest, |
| 3560 | name: "ChannelID-Server", |
| 3561 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3562 | MaxVersion: VersionTLS12, |
| 3563 | ChannelID: channelIDKey, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3564 | }, |
| 3565 | flags: []string{ |
| 3566 | "-expect-channel-id", |
| 3567 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3568 | }, |
| 3569 | resumeSession: true, |
| 3570 | expectChannelID: true, |
| 3571 | }) |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3572 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3573 | // Channel ID and NPN at the same time, to ensure their relative |
| 3574 | // ordering is correct. |
| 3575 | tests = append(tests, testCase{ |
| 3576 | name: "ChannelID-NPN-Client", |
| 3577 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3578 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3579 | RequestChannelID: true, |
| 3580 | NextProtos: []string{"foo"}, |
| 3581 | }, |
| 3582 | flags: []string{ |
| 3583 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 3584 | "-select-next-proto", "foo", |
| 3585 | }, |
| 3586 | resumeSession: true, |
| 3587 | expectChannelID: true, |
| 3588 | expectedNextProto: "foo", |
| 3589 | expectedNextProtoType: npn, |
| 3590 | }) |
| 3591 | tests = append(tests, testCase{ |
| 3592 | testType: serverTest, |
| 3593 | name: "ChannelID-NPN-Server", |
| 3594 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3595 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3596 | ChannelID: channelIDKey, |
| 3597 | NextProtos: []string{"bar"}, |
| 3598 | }, |
| 3599 | flags: []string{ |
| 3600 | "-expect-channel-id", |
| 3601 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3602 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3603 | "-expect-next-proto", "bar", |
| 3604 | }, |
| 3605 | resumeSession: true, |
| 3606 | expectChannelID: true, |
| 3607 | expectedNextProto: "bar", |
| 3608 | expectedNextProtoType: npn, |
| 3609 | }) |
| 3610 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3611 | // Bidirectional shutdown with the runner initiating. |
| 3612 | tests = append(tests, testCase{ |
| 3613 | name: "Shutdown-Runner", |
| 3614 | config: Config{ |
| 3615 | Bugs: ProtocolBugs{ |
| 3616 | ExpectCloseNotify: true, |
| 3617 | }, |
| 3618 | }, |
| 3619 | flags: []string{"-check-close-notify"}, |
| 3620 | }) |
| 3621 | |
| 3622 | // Bidirectional shutdown with the shim initiating. The runner, |
| 3623 | // in the meantime, sends garbage before the close_notify which |
| 3624 | // the shim must ignore. |
| 3625 | tests = append(tests, testCase{ |
| 3626 | name: "Shutdown-Shim", |
| 3627 | config: Config{ |
| 3628 | Bugs: ProtocolBugs{ |
| 3629 | ExpectCloseNotify: true, |
| 3630 | }, |
| 3631 | }, |
| 3632 | shimShutsDown: true, |
| 3633 | sendEmptyRecords: 1, |
| 3634 | sendWarningAlerts: 1, |
| 3635 | flags: []string{"-check-close-notify"}, |
| 3636 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3637 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3638 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 3639 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3640 | tests = append(tests, testCase{ |
| 3641 | name: "SkipHelloVerifyRequest", |
| 3642 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3643 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3644 | Bugs: ProtocolBugs{ |
| 3645 | SkipHelloVerifyRequest: true, |
| 3646 | }, |
| 3647 | }, |
| 3648 | }) |
| 3649 | } |
| 3650 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3651 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3652 | test.protocol = config.protocol |
| 3653 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3654 | test.name += "-DTLS" |
| 3655 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3656 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3657 | test.name += "-Async" |
| 3658 | test.flags = append(test.flags, "-async") |
| 3659 | } else { |
| 3660 | test.name += "-Sync" |
| 3661 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3662 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3663 | test.name += "-SplitHandshakeRecords" |
| 3664 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3665 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3666 | test.config.Bugs.MaxPacketLength = 256 |
| 3667 | test.flags = append(test.flags, "-mtu", "256") |
| 3668 | } |
| 3669 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3670 | if config.packHandshakeFlight { |
| 3671 | test.name += "-PackHandshakeFlight" |
| 3672 | test.config.Bugs.PackHandshakeFlight = true |
| 3673 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3674 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 3675 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3676 | } |
| 3677 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3678 | func addDDoSCallbackTests() { |
| 3679 | // DDoS callback. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3680 | // TODO(davidben): Implement DDoS resumption tests for TLS 1.3. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3681 | for _, resume := range []bool{false, true} { |
| 3682 | suffix := "Resume" |
| 3683 | if resume { |
| 3684 | suffix = "No" + suffix |
| 3685 | } |
| 3686 | |
| 3687 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3688 | testType: serverTest, |
| 3689 | name: "Server-DDoS-OK-" + suffix, |
| 3690 | config: Config{ |
| 3691 | MaxVersion: VersionTLS12, |
| 3692 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3693 | flags: []string{"-install-ddos-callback"}, |
| 3694 | resumeSession: resume, |
| 3695 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3696 | if !resume { |
| 3697 | testCases = append(testCases, testCase{ |
| 3698 | testType: serverTest, |
| 3699 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 3700 | config: Config{ |
| 3701 | MaxVersion: VersionTLS13, |
| 3702 | }, |
| 3703 | flags: []string{"-install-ddos-callback"}, |
| 3704 | resumeSession: resume, |
| 3705 | }) |
| 3706 | } |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3707 | |
| 3708 | failFlag := "-fail-ddos-callback" |
| 3709 | if resume { |
| 3710 | failFlag = "-fail-second-ddos-callback" |
| 3711 | } |
| 3712 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3713 | testType: serverTest, |
| 3714 | name: "Server-DDoS-Reject-" + suffix, |
| 3715 | config: Config{ |
| 3716 | MaxVersion: VersionTLS12, |
| 3717 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3718 | flags: []string{"-install-ddos-callback", failFlag}, |
| 3719 | resumeSession: resume, |
| 3720 | shouldFail: true, |
| 3721 | expectedError: ":CONNECTION_REJECTED:", |
| 3722 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3723 | if !resume { |
| 3724 | testCases = append(testCases, testCase{ |
| 3725 | testType: serverTest, |
| 3726 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 3727 | config: Config{ |
| 3728 | MaxVersion: VersionTLS13, |
| 3729 | }, |
| 3730 | flags: []string{"-install-ddos-callback", failFlag}, |
| 3731 | resumeSession: resume, |
| 3732 | shouldFail: true, |
| 3733 | expectedError: ":CONNECTION_REJECTED:", |
| 3734 | }) |
| 3735 | } |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 3736 | } |
| 3737 | } |
| 3738 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3739 | func addVersionNegotiationTests() { |
| 3740 | for i, shimVers := range tlsVersions { |
| 3741 | // Assemble flags to disable all newer versions on the shim. |
| 3742 | var flags []string |
| 3743 | for _, vers := range tlsVersions[i+1:] { |
| 3744 | flags = append(flags, vers.flag) |
| 3745 | } |
| 3746 | |
| 3747 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3748 | protocols := []protocol{tls} |
| 3749 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 3750 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3751 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3752 | for _, protocol := range protocols { |
| 3753 | expectedVersion := shimVers.version |
| 3754 | if runnerVers.version < shimVers.version { |
| 3755 | expectedVersion = runnerVers.version |
| 3756 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3757 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3758 | suffix := shimVers.name + "-" + runnerVers.name |
| 3759 | if protocol == dtls { |
| 3760 | suffix += "-DTLS" |
| 3761 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3762 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3763 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 3764 | |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3765 | clientVers := shimVers.version |
| 3766 | if clientVers > VersionTLS10 { |
| 3767 | clientVers = VersionTLS10 |
| 3768 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3769 | serverVers := expectedVersion |
| 3770 | if expectedVersion >= VersionTLS13 { |
| 3771 | serverVers = VersionTLS10 |
| 3772 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3773 | testCases = append(testCases, testCase{ |
| 3774 | protocol: protocol, |
| 3775 | testType: clientTest, |
| 3776 | name: "VersionNegotiation-Client-" + suffix, |
| 3777 | config: Config{ |
| 3778 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3779 | Bugs: ProtocolBugs{ |
| 3780 | ExpectInitialRecordVersion: clientVers, |
| 3781 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3782 | }, |
| 3783 | flags: flags, |
| 3784 | expectedVersion: expectedVersion, |
| 3785 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3786 | testCases = append(testCases, testCase{ |
| 3787 | protocol: protocol, |
| 3788 | testType: clientTest, |
| 3789 | name: "VersionNegotiation-Client2-" + suffix, |
| 3790 | config: Config{ |
| 3791 | MaxVersion: runnerVers.version, |
| 3792 | Bugs: ProtocolBugs{ |
| 3793 | ExpectInitialRecordVersion: clientVers, |
| 3794 | }, |
| 3795 | }, |
| 3796 | flags: []string{"-max-version", shimVersFlag}, |
| 3797 | expectedVersion: expectedVersion, |
| 3798 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3799 | |
| 3800 | testCases = append(testCases, testCase{ |
| 3801 | protocol: protocol, |
| 3802 | testType: serverTest, |
| 3803 | name: "VersionNegotiation-Server-" + suffix, |
| 3804 | config: Config{ |
| 3805 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3806 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3807 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 3808 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3809 | }, |
| 3810 | flags: flags, |
| 3811 | expectedVersion: expectedVersion, |
| 3812 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3813 | testCases = append(testCases, testCase{ |
| 3814 | protocol: protocol, |
| 3815 | testType: serverTest, |
| 3816 | name: "VersionNegotiation-Server2-" + suffix, |
| 3817 | config: Config{ |
| 3818 | MaxVersion: runnerVers.version, |
| 3819 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3820 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 3821 | }, |
| 3822 | }, |
| 3823 | flags: []string{"-max-version", shimVersFlag}, |
| 3824 | expectedVersion: expectedVersion, |
| 3825 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 3826 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3827 | } |
| 3828 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 3829 | |
| 3830 | // Test for version tolerance. |
| 3831 | testCases = append(testCases, testCase{ |
| 3832 | testType: serverTest, |
| 3833 | name: "MinorVersionTolerance", |
| 3834 | config: Config{ |
| 3835 | Bugs: ProtocolBugs{ |
| 3836 | SendClientVersion: 0x03ff, |
| 3837 | }, |
| 3838 | }, |
| 3839 | expectedVersion: VersionTLS13, |
| 3840 | }) |
| 3841 | testCases = append(testCases, testCase{ |
| 3842 | testType: serverTest, |
| 3843 | name: "MajorVersionTolerance", |
| 3844 | config: Config{ |
| 3845 | Bugs: ProtocolBugs{ |
| 3846 | SendClientVersion: 0x0400, |
| 3847 | }, |
| 3848 | }, |
| 3849 | expectedVersion: VersionTLS13, |
| 3850 | }) |
| 3851 | testCases = append(testCases, testCase{ |
| 3852 | protocol: dtls, |
| 3853 | testType: serverTest, |
| 3854 | name: "MinorVersionTolerance-DTLS", |
| 3855 | config: Config{ |
| 3856 | Bugs: ProtocolBugs{ |
| 3857 | SendClientVersion: 0x03ff, |
| 3858 | }, |
| 3859 | }, |
| 3860 | expectedVersion: VersionTLS12, |
| 3861 | }) |
| 3862 | testCases = append(testCases, testCase{ |
| 3863 | protocol: dtls, |
| 3864 | testType: serverTest, |
| 3865 | name: "MajorVersionTolerance-DTLS", |
| 3866 | config: Config{ |
| 3867 | Bugs: ProtocolBugs{ |
| 3868 | SendClientVersion: 0x0400, |
| 3869 | }, |
| 3870 | }, |
| 3871 | expectedVersion: VersionTLS12, |
| 3872 | }) |
| 3873 | |
| 3874 | // Test that versions below 3.0 are rejected. |
| 3875 | testCases = append(testCases, testCase{ |
| 3876 | testType: serverTest, |
| 3877 | name: "VersionTooLow", |
| 3878 | config: Config{ |
| 3879 | Bugs: ProtocolBugs{ |
| 3880 | SendClientVersion: 0x0200, |
| 3881 | }, |
| 3882 | }, |
| 3883 | shouldFail: true, |
| 3884 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 3885 | }) |
| 3886 | testCases = append(testCases, testCase{ |
| 3887 | protocol: dtls, |
| 3888 | testType: serverTest, |
| 3889 | name: "VersionTooLow-DTLS", |
| 3890 | config: Config{ |
| 3891 | Bugs: ProtocolBugs{ |
| 3892 | // 0x0201 is the lowest version expressable in |
| 3893 | // DTLS. |
| 3894 | SendClientVersion: 0x0201, |
| 3895 | }, |
| 3896 | }, |
| 3897 | shouldFail: true, |
| 3898 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 3899 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 3900 | |
| 3901 | // Test TLS 1.3's downgrade signal. |
| 3902 | testCases = append(testCases, testCase{ |
| 3903 | name: "Downgrade-TLS12-Client", |
| 3904 | config: Config{ |
| 3905 | Bugs: ProtocolBugs{ |
| 3906 | NegotiateVersion: VersionTLS12, |
| 3907 | }, |
| 3908 | }, |
| 3909 | shouldFail: true, |
| 3910 | expectedError: ":DOWNGRADE_DETECTED:", |
| 3911 | }) |
| 3912 | testCases = append(testCases, testCase{ |
| 3913 | testType: serverTest, |
| 3914 | name: "Downgrade-TLS12-Server", |
| 3915 | config: Config{ |
| 3916 | Bugs: ProtocolBugs{ |
| 3917 | SendClientVersion: VersionTLS12, |
| 3918 | }, |
| 3919 | }, |
| 3920 | shouldFail: true, |
| 3921 | expectedLocalError: "tls: downgrade from TLS 1.3 detected", |
| 3922 | }) |
David Benjamin | 5e7e7cc | 2016-07-21 12:55:28 +0200 | [diff] [blame] | 3923 | |
| 3924 | // Test that FALLBACK_SCSV is sent and that the downgrade signal works |
| 3925 | // behave correctly when both real maximum and fallback versions are |
| 3926 | // set. |
| 3927 | testCases = append(testCases, testCase{ |
| 3928 | name: "Downgrade-TLS12-Client-Fallback", |
| 3929 | config: Config{ |
| 3930 | Bugs: ProtocolBugs{ |
| 3931 | FailIfNotFallbackSCSV: true, |
| 3932 | }, |
| 3933 | }, |
| 3934 | flags: []string{ |
| 3935 | "-max-version", strconv.Itoa(VersionTLS13), |
| 3936 | "-fallback-version", strconv.Itoa(VersionTLS12), |
| 3937 | }, |
| 3938 | shouldFail: true, |
| 3939 | expectedError: ":DOWNGRADE_DETECTED:", |
| 3940 | }) |
| 3941 | testCases = append(testCases, testCase{ |
| 3942 | name: "Downgrade-TLS12-Client-FallbackEqualsMax", |
| 3943 | flags: []string{ |
| 3944 | "-max-version", strconv.Itoa(VersionTLS12), |
| 3945 | "-fallback-version", strconv.Itoa(VersionTLS12), |
| 3946 | }, |
| 3947 | }) |
| 3948 | |
| 3949 | // On TLS 1.2 fallback, 1.3 ServerHellos are forbidden. (We would rather |
| 3950 | // just have such connections fail than risk getting confused because we |
| 3951 | // didn't sent the 1.3 ClientHello.) |
| 3952 | testCases = append(testCases, testCase{ |
| 3953 | name: "Downgrade-TLS12-Fallback-CheckVersion", |
| 3954 | config: Config{ |
| 3955 | Bugs: ProtocolBugs{ |
| 3956 | NegotiateVersion: VersionTLS13, |
| 3957 | FailIfNotFallbackSCSV: true, |
| 3958 | }, |
| 3959 | }, |
| 3960 | flags: []string{ |
| 3961 | "-max-version", strconv.Itoa(VersionTLS13), |
| 3962 | "-fallback-version", strconv.Itoa(VersionTLS12), |
| 3963 | }, |
| 3964 | shouldFail: true, |
| 3965 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 3966 | }) |
| 3967 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 3968 | } |
| 3969 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3970 | func addMinimumVersionTests() { |
| 3971 | for i, shimVers := range tlsVersions { |
| 3972 | // Assemble flags to disable all older versions on the shim. |
| 3973 | var flags []string |
| 3974 | for _, vers := range tlsVersions[:i] { |
| 3975 | flags = append(flags, vers.flag) |
| 3976 | } |
| 3977 | |
| 3978 | for _, runnerVers := range tlsVersions { |
| 3979 | protocols := []protocol{tls} |
| 3980 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 3981 | protocols = append(protocols, dtls) |
| 3982 | } |
| 3983 | for _, protocol := range protocols { |
| 3984 | suffix := shimVers.name + "-" + runnerVers.name |
| 3985 | if protocol == dtls { |
| 3986 | suffix += "-DTLS" |
| 3987 | } |
| 3988 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 3989 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3990 | var expectedVersion uint16 |
| 3991 | var shouldFail bool |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3992 | var expectedClientError, expectedServerError string |
| 3993 | var expectedClientLocalError, expectedServerLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 3994 | if runnerVers.version >= shimVers.version { |
| 3995 | expectedVersion = runnerVers.version |
| 3996 | } else { |
| 3997 | shouldFail = true |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 3998 | expectedServerError = ":UNSUPPORTED_PROTOCOL:" |
| 3999 | expectedServerLocalError = "remote error: protocol version not supported" |
| 4000 | if shimVers.version >= VersionTLS13 && runnerVers.version <= VersionTLS11 { |
| 4001 | // If the client's minimum version is TLS 1.3 and the runner's |
| 4002 | // maximum is below TLS 1.2, the runner will fail to select a |
| 4003 | // cipher before the shim rejects the selected version. |
| 4004 | expectedClientError = ":SSLV3_ALERT_HANDSHAKE_FAILURE:" |
| 4005 | expectedClientLocalError = "tls: no cipher suite supported by both client and server" |
| 4006 | } else { |
| 4007 | expectedClientError = expectedServerError |
| 4008 | expectedClientLocalError = expectedServerLocalError |
| 4009 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4010 | } |
| 4011 | |
| 4012 | testCases = append(testCases, testCase{ |
| 4013 | protocol: protocol, |
| 4014 | testType: clientTest, |
| 4015 | name: "MinimumVersion-Client-" + suffix, |
| 4016 | config: Config{ |
| 4017 | MaxVersion: runnerVers.version, |
| 4018 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4019 | flags: flags, |
| 4020 | expectedVersion: expectedVersion, |
| 4021 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4022 | expectedError: expectedClientError, |
| 4023 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4024 | }) |
| 4025 | testCases = append(testCases, testCase{ |
| 4026 | protocol: protocol, |
| 4027 | testType: clientTest, |
| 4028 | name: "MinimumVersion-Client2-" + suffix, |
| 4029 | config: Config{ |
| 4030 | MaxVersion: runnerVers.version, |
| 4031 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4032 | flags: []string{"-min-version", shimVersFlag}, |
| 4033 | expectedVersion: expectedVersion, |
| 4034 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4035 | expectedError: expectedClientError, |
| 4036 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4037 | }) |
| 4038 | |
| 4039 | testCases = append(testCases, testCase{ |
| 4040 | protocol: protocol, |
| 4041 | testType: serverTest, |
| 4042 | name: "MinimumVersion-Server-" + suffix, |
| 4043 | config: Config{ |
| 4044 | MaxVersion: runnerVers.version, |
| 4045 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4046 | flags: flags, |
| 4047 | expectedVersion: expectedVersion, |
| 4048 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4049 | expectedError: expectedServerError, |
| 4050 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4051 | }) |
| 4052 | testCases = append(testCases, testCase{ |
| 4053 | protocol: protocol, |
| 4054 | testType: serverTest, |
| 4055 | name: "MinimumVersion-Server2-" + suffix, |
| 4056 | config: Config{ |
| 4057 | MaxVersion: runnerVers.version, |
| 4058 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4059 | flags: []string{"-min-version", shimVersFlag}, |
| 4060 | expectedVersion: expectedVersion, |
| 4061 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4062 | expectedError: expectedServerError, |
| 4063 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4064 | }) |
| 4065 | } |
| 4066 | } |
| 4067 | } |
| 4068 | } |
| 4069 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4070 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4071 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4072 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4073 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4074 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4075 | // Repeat extensions tests all versions except SSL 3.0. |
| 4076 | for _, ver := range tlsVersions { |
| 4077 | if ver.version == VersionSSL30 { |
| 4078 | continue |
| 4079 | } |
| 4080 | |
| 4081 | // TODO(davidben): Implement resumption in TLS 1.3. |
| 4082 | resumeSession := ver.version < VersionTLS13 |
| 4083 | |
| 4084 | // Test that duplicate extensions are rejected. |
| 4085 | testCases = append(testCases, testCase{ |
| 4086 | testType: clientTest, |
| 4087 | name: "DuplicateExtensionClient-" + ver.name, |
| 4088 | config: Config{ |
| 4089 | MaxVersion: ver.version, |
| 4090 | Bugs: ProtocolBugs{ |
| 4091 | DuplicateExtension: true, |
| 4092 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4093 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4094 | shouldFail: true, |
| 4095 | expectedLocalError: "remote error: error decoding message", |
| 4096 | }) |
| 4097 | testCases = append(testCases, testCase{ |
| 4098 | testType: serverTest, |
| 4099 | name: "DuplicateExtensionServer-" + ver.name, |
| 4100 | config: Config{ |
| 4101 | MaxVersion: ver.version, |
| 4102 | Bugs: ProtocolBugs{ |
| 4103 | DuplicateExtension: true, |
| 4104 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4105 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4106 | shouldFail: true, |
| 4107 | expectedLocalError: "remote error: error decoding message", |
| 4108 | }) |
| 4109 | |
| 4110 | // Test SNI. |
| 4111 | testCases = append(testCases, testCase{ |
| 4112 | testType: clientTest, |
| 4113 | name: "ServerNameExtensionClient-" + ver.name, |
| 4114 | config: Config{ |
| 4115 | MaxVersion: ver.version, |
| 4116 | Bugs: ProtocolBugs{ |
| 4117 | ExpectServerName: "example.com", |
| 4118 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4119 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4120 | flags: []string{"-host-name", "example.com"}, |
| 4121 | }) |
| 4122 | testCases = append(testCases, testCase{ |
| 4123 | testType: clientTest, |
| 4124 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4125 | config: Config{ |
| 4126 | MaxVersion: ver.version, |
| 4127 | Bugs: ProtocolBugs{ |
| 4128 | ExpectServerName: "mismatch.com", |
| 4129 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4130 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4131 | flags: []string{"-host-name", "example.com"}, |
| 4132 | shouldFail: true, |
| 4133 | expectedLocalError: "tls: unexpected server name", |
| 4134 | }) |
| 4135 | testCases = append(testCases, testCase{ |
| 4136 | testType: clientTest, |
| 4137 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4138 | config: Config{ |
| 4139 | MaxVersion: ver.version, |
| 4140 | Bugs: ProtocolBugs{ |
| 4141 | ExpectServerName: "missing.com", |
| 4142 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4143 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4144 | shouldFail: true, |
| 4145 | expectedLocalError: "tls: unexpected server name", |
| 4146 | }) |
| 4147 | testCases = append(testCases, testCase{ |
| 4148 | testType: serverTest, |
| 4149 | name: "ServerNameExtensionServer-" + ver.name, |
| 4150 | config: Config{ |
| 4151 | MaxVersion: ver.version, |
| 4152 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4153 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4154 | flags: []string{"-expect-server-name", "example.com"}, |
| 4155 | resumeSession: resumeSession, |
| 4156 | }) |
| 4157 | |
| 4158 | // Test ALPN. |
| 4159 | testCases = append(testCases, testCase{ |
| 4160 | testType: clientTest, |
| 4161 | name: "ALPNClient-" + ver.name, |
| 4162 | config: Config{ |
| 4163 | MaxVersion: ver.version, |
| 4164 | NextProtos: []string{"foo"}, |
| 4165 | }, |
| 4166 | flags: []string{ |
| 4167 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4168 | "-expect-alpn", "foo", |
| 4169 | }, |
| 4170 | expectedNextProto: "foo", |
| 4171 | expectedNextProtoType: alpn, |
| 4172 | resumeSession: resumeSession, |
| 4173 | }) |
| 4174 | testCases = append(testCases, testCase{ |
| 4175 | testType: serverTest, |
| 4176 | name: "ALPNServer-" + ver.name, |
| 4177 | config: Config{ |
| 4178 | MaxVersion: ver.version, |
| 4179 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4180 | }, |
| 4181 | flags: []string{ |
| 4182 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4183 | "-select-alpn", "foo", |
| 4184 | }, |
| 4185 | expectedNextProto: "foo", |
| 4186 | expectedNextProtoType: alpn, |
| 4187 | resumeSession: resumeSession, |
| 4188 | }) |
| 4189 | testCases = append(testCases, testCase{ |
| 4190 | testType: serverTest, |
| 4191 | name: "ALPNServer-Decline-" + ver.name, |
| 4192 | config: Config{ |
| 4193 | MaxVersion: ver.version, |
| 4194 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4195 | }, |
| 4196 | flags: []string{"-decline-alpn"}, |
| 4197 | expectNoNextProto: true, |
| 4198 | resumeSession: resumeSession, |
| 4199 | }) |
| 4200 | |
| 4201 | var emptyString string |
| 4202 | testCases = append(testCases, testCase{ |
| 4203 | testType: clientTest, |
| 4204 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4205 | config: Config{ |
| 4206 | MaxVersion: ver.version, |
| 4207 | NextProtos: []string{""}, |
| 4208 | Bugs: ProtocolBugs{ |
| 4209 | // A server returning an empty ALPN protocol |
| 4210 | // should be rejected. |
| 4211 | ALPNProtocol: &emptyString, |
| 4212 | }, |
| 4213 | }, |
| 4214 | flags: []string{ |
| 4215 | "-advertise-alpn", "\x03foo", |
| 4216 | }, |
| 4217 | shouldFail: true, |
| 4218 | expectedError: ":PARSE_TLSEXT:", |
| 4219 | }) |
| 4220 | testCases = append(testCases, testCase{ |
| 4221 | testType: serverTest, |
| 4222 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4223 | config: Config{ |
| 4224 | MaxVersion: ver.version, |
| 4225 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4226 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4227 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4228 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4229 | flags: []string{ |
| 4230 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4231 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4232 | shouldFail: true, |
| 4233 | expectedError: ":PARSE_TLSEXT:", |
| 4234 | }) |
| 4235 | |
| 4236 | // Test NPN and the interaction with ALPN. |
| 4237 | if ver.version < VersionTLS13 { |
| 4238 | // Test that the server prefers ALPN over NPN. |
| 4239 | testCases = append(testCases, testCase{ |
| 4240 | testType: serverTest, |
| 4241 | name: "ALPNServer-Preferred-" + ver.name, |
| 4242 | config: Config{ |
| 4243 | MaxVersion: ver.version, |
| 4244 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4245 | }, |
| 4246 | flags: []string{ |
| 4247 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4248 | "-select-alpn", "foo", |
| 4249 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4250 | }, |
| 4251 | expectedNextProto: "foo", |
| 4252 | expectedNextProtoType: alpn, |
| 4253 | resumeSession: resumeSession, |
| 4254 | }) |
| 4255 | testCases = append(testCases, testCase{ |
| 4256 | testType: serverTest, |
| 4257 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4258 | config: Config{ |
| 4259 | MaxVersion: ver.version, |
| 4260 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4261 | Bugs: ProtocolBugs{ |
| 4262 | SwapNPNAndALPN: true, |
| 4263 | }, |
| 4264 | }, |
| 4265 | flags: []string{ |
| 4266 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4267 | "-select-alpn", "foo", |
| 4268 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4269 | }, |
| 4270 | expectedNextProto: "foo", |
| 4271 | expectedNextProtoType: alpn, |
| 4272 | resumeSession: resumeSession, |
| 4273 | }) |
| 4274 | |
| 4275 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4276 | testCases = append(testCases, testCase{ |
| 4277 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4278 | config: Config{ |
| 4279 | MaxVersion: ver.version, |
| 4280 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4281 | Bugs: ProtocolBugs{ |
| 4282 | NegotiateALPNAndNPN: true, |
| 4283 | }, |
| 4284 | }, |
| 4285 | flags: []string{ |
| 4286 | "-advertise-alpn", "\x03foo", |
| 4287 | "-select-next-proto", "foo", |
| 4288 | }, |
| 4289 | shouldFail: true, |
| 4290 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4291 | }) |
| 4292 | testCases = append(testCases, testCase{ |
| 4293 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4294 | config: Config{ |
| 4295 | MaxVersion: ver.version, |
| 4296 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4297 | Bugs: ProtocolBugs{ |
| 4298 | NegotiateALPNAndNPN: true, |
| 4299 | SwapNPNAndALPN: true, |
| 4300 | }, |
| 4301 | }, |
| 4302 | flags: []string{ |
| 4303 | "-advertise-alpn", "\x03foo", |
| 4304 | "-select-next-proto", "foo", |
| 4305 | }, |
| 4306 | shouldFail: true, |
| 4307 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4308 | }) |
| 4309 | |
| 4310 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4311 | testCases = append(testCases, testCase{ |
| 4312 | name: "DisableNPN-" + ver.name, |
| 4313 | config: Config{ |
| 4314 | MaxVersion: ver.version, |
| 4315 | NextProtos: []string{"foo"}, |
| 4316 | }, |
| 4317 | flags: []string{ |
| 4318 | "-select-next-proto", "foo", |
| 4319 | "-disable-npn", |
| 4320 | }, |
| 4321 | expectNoNextProto: true, |
| 4322 | }) |
| 4323 | } |
| 4324 | |
| 4325 | // Test ticket behavior. |
| 4326 | // |
| 4327 | // TODO(davidben): Add TLS 1.3 versions of these. |
| 4328 | if ver.version < VersionTLS13 { |
| 4329 | // Resume with a corrupt ticket. |
| 4330 | testCases = append(testCases, testCase{ |
| 4331 | testType: serverTest, |
| 4332 | name: "CorruptTicket-" + ver.name, |
| 4333 | config: Config{ |
| 4334 | MaxVersion: ver.version, |
| 4335 | Bugs: ProtocolBugs{ |
| 4336 | CorruptTicket: true, |
| 4337 | }, |
| 4338 | }, |
| 4339 | resumeSession: true, |
| 4340 | expectResumeRejected: true, |
| 4341 | }) |
| 4342 | // Test the ticket callback, with and without renewal. |
| 4343 | testCases = append(testCases, testCase{ |
| 4344 | testType: serverTest, |
| 4345 | name: "TicketCallback-" + ver.name, |
| 4346 | config: Config{ |
| 4347 | MaxVersion: ver.version, |
| 4348 | }, |
| 4349 | resumeSession: true, |
| 4350 | flags: []string{"-use-ticket-callback"}, |
| 4351 | }) |
| 4352 | testCases = append(testCases, testCase{ |
| 4353 | testType: serverTest, |
| 4354 | name: "TicketCallback-Renew-" + ver.name, |
| 4355 | config: Config{ |
| 4356 | MaxVersion: ver.version, |
| 4357 | Bugs: ProtocolBugs{ |
| 4358 | ExpectNewTicket: true, |
| 4359 | }, |
| 4360 | }, |
| 4361 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4362 | resumeSession: true, |
| 4363 | }) |
| 4364 | |
| 4365 | // Resume with an oversized session id. |
| 4366 | testCases = append(testCases, testCase{ |
| 4367 | testType: serverTest, |
| 4368 | name: "OversizedSessionId-" + ver.name, |
| 4369 | config: Config{ |
| 4370 | MaxVersion: ver.version, |
| 4371 | Bugs: ProtocolBugs{ |
| 4372 | OversizedSessionId: true, |
| 4373 | }, |
| 4374 | }, |
| 4375 | resumeSession: true, |
| 4376 | shouldFail: true, |
| 4377 | expectedError: ":DECODE_ERROR:", |
| 4378 | }) |
| 4379 | } |
| 4380 | |
| 4381 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4382 | // are ignored. |
| 4383 | if ver.hasDTLS { |
| 4384 | testCases = append(testCases, testCase{ |
| 4385 | protocol: dtls, |
| 4386 | name: "SRTP-Client-" + ver.name, |
| 4387 | config: Config{ |
| 4388 | MaxVersion: ver.version, |
| 4389 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4390 | }, |
| 4391 | flags: []string{ |
| 4392 | "-srtp-profiles", |
| 4393 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4394 | }, |
| 4395 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4396 | }) |
| 4397 | testCases = append(testCases, testCase{ |
| 4398 | protocol: dtls, |
| 4399 | testType: serverTest, |
| 4400 | name: "SRTP-Server-" + ver.name, |
| 4401 | config: Config{ |
| 4402 | MaxVersion: ver.version, |
| 4403 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4404 | }, |
| 4405 | flags: []string{ |
| 4406 | "-srtp-profiles", |
| 4407 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4408 | }, |
| 4409 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4410 | }) |
| 4411 | // Test that the MKI is ignored. |
| 4412 | testCases = append(testCases, testCase{ |
| 4413 | protocol: dtls, |
| 4414 | testType: serverTest, |
| 4415 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 4416 | config: Config{ |
| 4417 | MaxVersion: ver.version, |
| 4418 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 4419 | Bugs: ProtocolBugs{ |
| 4420 | SRTPMasterKeyIdentifer: "bogus", |
| 4421 | }, |
| 4422 | }, |
| 4423 | flags: []string{ |
| 4424 | "-srtp-profiles", |
| 4425 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4426 | }, |
| 4427 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4428 | }) |
| 4429 | // Test that SRTP isn't negotiated on the server if there were |
| 4430 | // no matching profiles. |
| 4431 | testCases = append(testCases, testCase{ |
| 4432 | protocol: dtls, |
| 4433 | testType: serverTest, |
| 4434 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 4435 | config: Config{ |
| 4436 | MaxVersion: ver.version, |
| 4437 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 4438 | }, |
| 4439 | flags: []string{ |
| 4440 | "-srtp-profiles", |
| 4441 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4442 | }, |
| 4443 | expectedSRTPProtectionProfile: 0, |
| 4444 | }) |
| 4445 | // Test that the server returning an invalid SRTP profile is |
| 4446 | // flagged as an error by the client. |
| 4447 | testCases = append(testCases, testCase{ |
| 4448 | protocol: dtls, |
| 4449 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 4450 | config: Config{ |
| 4451 | MaxVersion: ver.version, |
| 4452 | Bugs: ProtocolBugs{ |
| 4453 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 4454 | }, |
| 4455 | }, |
| 4456 | flags: []string{ |
| 4457 | "-srtp-profiles", |
| 4458 | "SRTP_AES128_CM_SHA1_80", |
| 4459 | }, |
| 4460 | shouldFail: true, |
| 4461 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 4462 | }) |
| 4463 | } |
| 4464 | |
| 4465 | // Test SCT list. |
| 4466 | testCases = append(testCases, testCase{ |
| 4467 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 4468 | testType: clientTest, |
| 4469 | config: Config{ |
| 4470 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4471 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4472 | flags: []string{ |
| 4473 | "-enable-signed-cert-timestamps", |
| 4474 | "-expect-signed-cert-timestamps", |
| 4475 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4476 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4477 | resumeSession: resumeSession, |
| 4478 | }) |
| 4479 | testCases = append(testCases, testCase{ |
| 4480 | name: "SendSCTListOnResume-" + ver.name, |
| 4481 | config: Config{ |
| 4482 | MaxVersion: ver.version, |
| 4483 | Bugs: ProtocolBugs{ |
| 4484 | SendSCTListOnResume: []byte("bogus"), |
| 4485 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 4486 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4487 | flags: []string{ |
| 4488 | "-enable-signed-cert-timestamps", |
| 4489 | "-expect-signed-cert-timestamps", |
| 4490 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4491 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4492 | resumeSession: resumeSession, |
| 4493 | }) |
| 4494 | testCases = append(testCases, testCase{ |
| 4495 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 4496 | testType: serverTest, |
| 4497 | config: Config{ |
| 4498 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4499 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4500 | flags: []string{ |
| 4501 | "-signed-cert-timestamps", |
| 4502 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4503 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4504 | expectedSCTList: testSCTList, |
| 4505 | resumeSession: resumeSession, |
| 4506 | }) |
| 4507 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4508 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 4509 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 4510 | testType: clientTest, |
| 4511 | name: "ClientHelloPadding", |
| 4512 | config: Config{ |
| 4513 | Bugs: ProtocolBugs{ |
| 4514 | RequireClientHelloSize: 512, |
| 4515 | }, |
| 4516 | }, |
| 4517 | // This hostname just needs to be long enough to push the |
| 4518 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 4519 | // long. |
| 4520 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 4521 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 4522 | |
| 4523 | // Extensions should not function in SSL 3.0. |
| 4524 | testCases = append(testCases, testCase{ |
| 4525 | testType: serverTest, |
| 4526 | name: "SSLv3Extensions-NoALPN", |
| 4527 | config: Config{ |
| 4528 | MaxVersion: VersionSSL30, |
| 4529 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4530 | }, |
| 4531 | flags: []string{ |
| 4532 | "-select-alpn", "foo", |
| 4533 | }, |
| 4534 | expectNoNextProto: true, |
| 4535 | }) |
| 4536 | |
| 4537 | // Test session tickets separately as they follow a different codepath. |
| 4538 | testCases = append(testCases, testCase{ |
| 4539 | testType: serverTest, |
| 4540 | name: "SSLv3Extensions-NoTickets", |
| 4541 | config: Config{ |
| 4542 | MaxVersion: VersionSSL30, |
| 4543 | Bugs: ProtocolBugs{ |
| 4544 | // Historically, session tickets in SSL 3.0 |
| 4545 | // failed in different ways depending on whether |
| 4546 | // the client supported renegotiation_info. |
| 4547 | NoRenegotiationInfo: true, |
| 4548 | }, |
| 4549 | }, |
| 4550 | resumeSession: true, |
| 4551 | }) |
| 4552 | testCases = append(testCases, testCase{ |
| 4553 | testType: serverTest, |
| 4554 | name: "SSLv3Extensions-NoTickets2", |
| 4555 | config: Config{ |
| 4556 | MaxVersion: VersionSSL30, |
| 4557 | }, |
| 4558 | resumeSession: true, |
| 4559 | }) |
| 4560 | |
| 4561 | // But SSL 3.0 does send and process renegotiation_info. |
| 4562 | testCases = append(testCases, testCase{ |
| 4563 | testType: serverTest, |
| 4564 | name: "SSLv3Extensions-RenegotiationInfo", |
| 4565 | config: Config{ |
| 4566 | MaxVersion: VersionSSL30, |
| 4567 | Bugs: ProtocolBugs{ |
| 4568 | RequireRenegotiationInfo: true, |
| 4569 | }, |
| 4570 | }, |
| 4571 | }) |
| 4572 | testCases = append(testCases, testCase{ |
| 4573 | testType: serverTest, |
| 4574 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 4575 | config: Config{ |
| 4576 | MaxVersion: VersionSSL30, |
| 4577 | Bugs: ProtocolBugs{ |
| 4578 | NoRenegotiationInfo: true, |
| 4579 | SendRenegotiationSCSV: true, |
| 4580 | RequireRenegotiationInfo: true, |
| 4581 | }, |
| 4582 | }, |
| 4583 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4584 | |
| 4585 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 4586 | // in ServerHello. |
| 4587 | testCases = append(testCases, testCase{ |
| 4588 | name: "NPN-Forbidden-TLS13", |
| 4589 | config: Config{ |
| 4590 | MaxVersion: VersionTLS13, |
| 4591 | NextProtos: []string{"foo"}, |
| 4592 | Bugs: ProtocolBugs{ |
| 4593 | NegotiateNPNAtAllVersions: true, |
| 4594 | }, |
| 4595 | }, |
| 4596 | flags: []string{"-select-next-proto", "foo"}, |
| 4597 | shouldFail: true, |
| 4598 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4599 | }) |
| 4600 | testCases = append(testCases, testCase{ |
| 4601 | name: "EMS-Forbidden-TLS13", |
| 4602 | config: Config{ |
| 4603 | MaxVersion: VersionTLS13, |
| 4604 | Bugs: ProtocolBugs{ |
| 4605 | NegotiateEMSAtAllVersions: true, |
| 4606 | }, |
| 4607 | }, |
| 4608 | shouldFail: true, |
| 4609 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4610 | }) |
| 4611 | testCases = append(testCases, testCase{ |
| 4612 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 4613 | config: Config{ |
| 4614 | MaxVersion: VersionTLS13, |
| 4615 | Bugs: ProtocolBugs{ |
| 4616 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 4617 | }, |
| 4618 | }, |
| 4619 | shouldFail: true, |
| 4620 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4621 | }) |
| 4622 | testCases = append(testCases, testCase{ |
| 4623 | name: "ChannelID-Forbidden-TLS13", |
| 4624 | config: Config{ |
| 4625 | MaxVersion: VersionTLS13, |
| 4626 | RequestChannelID: true, |
| 4627 | Bugs: ProtocolBugs{ |
| 4628 | NegotiateChannelIDAtAllVersions: true, |
| 4629 | }, |
| 4630 | }, |
| 4631 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4632 | shouldFail: true, |
| 4633 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4634 | }) |
| 4635 | testCases = append(testCases, testCase{ |
| 4636 | name: "Ticket-Forbidden-TLS13", |
| 4637 | config: Config{ |
| 4638 | MaxVersion: VersionTLS12, |
| 4639 | }, |
| 4640 | resumeConfig: &Config{ |
| 4641 | MaxVersion: VersionTLS13, |
| 4642 | Bugs: ProtocolBugs{ |
| 4643 | AdvertiseTicketExtension: true, |
| 4644 | }, |
| 4645 | }, |
| 4646 | resumeSession: true, |
| 4647 | shouldFail: true, |
| 4648 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4649 | }) |
| 4650 | |
| 4651 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 4652 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 4653 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 4654 | // implicit in every test.) |
| 4655 | testCases = append(testCases, testCase{ |
| 4656 | testType: serverTest, |
| 4657 | name: "ChannelID-Declined-TLS13", |
| 4658 | config: Config{ |
| 4659 | MaxVersion: VersionTLS13, |
| 4660 | ChannelID: channelIDKey, |
| 4661 | }, |
| 4662 | flags: []string{"-enable-channel-id"}, |
| 4663 | }) |
| 4664 | testCases = append(testCases, testCase{ |
| 4665 | testType: serverTest, |
| 4666 | name: "NPN-Server", |
| 4667 | config: Config{ |
| 4668 | MaxVersion: VersionTLS13, |
| 4669 | NextProtos: []string{"bar"}, |
| 4670 | }, |
| 4671 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 4672 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4673 | } |
| 4674 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4675 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4676 | for _, sessionVers := range tlsVersions { |
David Benjamin | 6e6abe1 | 2016-07-13 20:57:22 -0400 | [diff] [blame] | 4677 | // TODO(davidben,svaldez): Implement resumption in TLS 1.3. |
| 4678 | if sessionVers.version >= VersionTLS13 { |
| 4679 | continue |
| 4680 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4681 | for _, resumeVers := range tlsVersions { |
David Benjamin | 6e6abe1 | 2016-07-13 20:57:22 -0400 | [diff] [blame] | 4682 | if resumeVers.version >= VersionTLS13 { |
| 4683 | continue |
| 4684 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4685 | cipher := TLS_RSA_WITH_AES_128_CBC_SHA |
| 4686 | if sessionVers.version >= VersionTLS13 || resumeVers.version >= VersionTLS13 { |
| 4687 | // TLS 1.3 only shares ciphers with TLS 1.2, so |
| 4688 | // we skip certain combinations and use a |
| 4689 | // different cipher to test with. |
| 4690 | cipher = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
| 4691 | if sessionVers.version < VersionTLS12 || resumeVers.version < VersionTLS12 { |
| 4692 | continue |
| 4693 | } |
| 4694 | } |
| 4695 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4696 | protocols := []protocol{tls} |
| 4697 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 4698 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 4699 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4700 | for _, protocol := range protocols { |
| 4701 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 4702 | if protocol == dtls { |
| 4703 | suffix += "-DTLS" |
| 4704 | } |
| 4705 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4706 | if sessionVers.version == resumeVers.version { |
| 4707 | testCases = append(testCases, testCase{ |
| 4708 | protocol: protocol, |
| 4709 | name: "Resume-Client" + suffix, |
| 4710 | resumeSession: true, |
| 4711 | config: Config{ |
| 4712 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4713 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4714 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4715 | expectedVersion: sessionVers.version, |
| 4716 | expectedResumeVersion: resumeVers.version, |
| 4717 | }) |
| 4718 | } else { |
| 4719 | testCases = append(testCases, testCase{ |
| 4720 | protocol: protocol, |
| 4721 | name: "Resume-Client-Mismatch" + suffix, |
| 4722 | resumeSession: true, |
| 4723 | config: Config{ |
| 4724 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4725 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4726 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4727 | expectedVersion: sessionVers.version, |
| 4728 | resumeConfig: &Config{ |
| 4729 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4730 | CipherSuites: []uint16{cipher}, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4731 | Bugs: ProtocolBugs{ |
| 4732 | AllowSessionVersionMismatch: true, |
| 4733 | }, |
| 4734 | }, |
| 4735 | expectedResumeVersion: resumeVers.version, |
| 4736 | shouldFail: true, |
| 4737 | expectedError: ":OLD_SESSION_VERSION_NOT_RETURNED:", |
| 4738 | }) |
| 4739 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4740 | |
| 4741 | testCases = append(testCases, testCase{ |
| 4742 | protocol: protocol, |
| 4743 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4744 | resumeSession: true, |
| 4745 | config: Config{ |
| 4746 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4747 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4748 | }, |
| 4749 | expectedVersion: sessionVers.version, |
| 4750 | resumeConfig: &Config{ |
| 4751 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4752 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4753 | }, |
| 4754 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 4755 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4756 | expectedResumeVersion: resumeVers.version, |
| 4757 | }) |
| 4758 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4759 | testCases = append(testCases, testCase{ |
| 4760 | protocol: protocol, |
| 4761 | testType: serverTest, |
| 4762 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4763 | resumeSession: true, |
| 4764 | config: Config{ |
| 4765 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4766 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4767 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 4768 | expectedVersion: sessionVers.version, |
| 4769 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4770 | resumeConfig: &Config{ |
| 4771 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4772 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4773 | }, |
| 4774 | expectedResumeVersion: resumeVers.version, |
| 4775 | }) |
| 4776 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4777 | } |
| 4778 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4779 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4780 | // TODO(davidben): This test should have a TLS 1.3 variant later. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4781 | testCases = append(testCases, testCase{ |
| 4782 | name: "Resume-Client-CipherMismatch", |
| 4783 | resumeSession: true, |
| 4784 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4785 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4786 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4787 | }, |
| 4788 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4789 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 4790 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4791 | Bugs: ProtocolBugs{ |
| 4792 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 4793 | }, |
| 4794 | }, |
| 4795 | shouldFail: true, |
| 4796 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 4797 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 4798 | } |
| 4799 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 4800 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 4801 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4802 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4803 | testType: serverTest, |
| 4804 | name: "Renegotiate-Server-Forbidden", |
| 4805 | config: Config{ |
| 4806 | MaxVersion: VersionTLS12, |
| 4807 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4808 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4809 | shouldFail: true, |
| 4810 | expectedError: ":NO_RENEGOTIATION:", |
| 4811 | expectedLocalError: "remote error: no renegotiation", |
| 4812 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4813 | // The server shouldn't echo the renegotiation extension unless |
| 4814 | // requested by the client. |
| 4815 | testCases = append(testCases, testCase{ |
| 4816 | testType: serverTest, |
| 4817 | name: "Renegotiate-Server-NoExt", |
| 4818 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4819 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4820 | Bugs: ProtocolBugs{ |
| 4821 | NoRenegotiationInfo: true, |
| 4822 | RequireRenegotiationInfo: true, |
| 4823 | }, |
| 4824 | }, |
| 4825 | shouldFail: true, |
| 4826 | expectedLocalError: "renegotiation extension missing", |
| 4827 | }) |
| 4828 | // The renegotiation SCSV should be sufficient for the server to echo |
| 4829 | // the extension. |
| 4830 | testCases = append(testCases, testCase{ |
| 4831 | testType: serverTest, |
| 4832 | name: "Renegotiate-Server-NoExt-SCSV", |
| 4833 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4834 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 4835 | Bugs: ProtocolBugs{ |
| 4836 | NoRenegotiationInfo: true, |
| 4837 | SendRenegotiationSCSV: true, |
| 4838 | RequireRenegotiationInfo: true, |
| 4839 | }, |
| 4840 | }, |
| 4841 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4842 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 4843 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4844 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4845 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4846 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 4847 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4848 | }, |
| 4849 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4850 | renegotiate: 1, |
| 4851 | flags: []string{ |
| 4852 | "-renegotiate-freely", |
| 4853 | "-expect-total-renegotiations", "1", |
| 4854 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 4855 | }) |
| 4856 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4857 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4858 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4859 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4860 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4861 | Bugs: ProtocolBugs{ |
| 4862 | EmptyRenegotiationInfo: true, |
| 4863 | }, |
| 4864 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4865 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4866 | shouldFail: true, |
| 4867 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4868 | }) |
| 4869 | testCases = append(testCases, testCase{ |
| 4870 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4871 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4872 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4873 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4874 | Bugs: ProtocolBugs{ |
| 4875 | BadRenegotiationInfo: true, |
| 4876 | }, |
| 4877 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4878 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4879 | shouldFail: true, |
| 4880 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4881 | }) |
| 4882 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4883 | name: "Renegotiate-Client-Downgrade", |
| 4884 | renegotiate: 1, |
| 4885 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4886 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4887 | Bugs: ProtocolBugs{ |
| 4888 | NoRenegotiationInfoAfterInitial: true, |
| 4889 | }, |
| 4890 | }, |
| 4891 | flags: []string{"-renegotiate-freely"}, |
| 4892 | shouldFail: true, |
| 4893 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4894 | }) |
| 4895 | testCases = append(testCases, testCase{ |
| 4896 | name: "Renegotiate-Client-Upgrade", |
| 4897 | renegotiate: 1, |
| 4898 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4899 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 4900 | Bugs: ProtocolBugs{ |
| 4901 | NoRenegotiationInfoInInitial: true, |
| 4902 | }, |
| 4903 | }, |
| 4904 | flags: []string{"-renegotiate-freely"}, |
| 4905 | shouldFail: true, |
| 4906 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 4907 | }) |
| 4908 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4909 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4910 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4911 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4912 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4913 | Bugs: ProtocolBugs{ |
| 4914 | NoRenegotiationInfo: true, |
| 4915 | }, |
| 4916 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4917 | flags: []string{ |
| 4918 | "-renegotiate-freely", |
| 4919 | "-expect-total-renegotiations", "1", |
| 4920 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 4921 | }) |
| 4922 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4923 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4924 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4925 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4926 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4927 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 4928 | }, |
| 4929 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4930 | flags: []string{ |
| 4931 | "-renegotiate-freely", |
| 4932 | "-expect-total-renegotiations", "1", |
| 4933 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4934 | }) |
| 4935 | testCases = append(testCases, testCase{ |
| 4936 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4937 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4938 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4939 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 4940 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4941 | }, |
| 4942 | renegotiateCiphers: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4943 | flags: []string{ |
| 4944 | "-renegotiate-freely", |
| 4945 | "-expect-total-renegotiations", "1", |
| 4946 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 4947 | }) |
| 4948 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4949 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4950 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4951 | config: Config{ |
| 4952 | MaxVersion: VersionTLS10, |
| 4953 | Bugs: ProtocolBugs{ |
| 4954 | RequireSameRenegoClientVersion: true, |
| 4955 | }, |
| 4956 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4957 | flags: []string{ |
| 4958 | "-renegotiate-freely", |
| 4959 | "-expect-total-renegotiations", "1", |
| 4960 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 4961 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4962 | testCases = append(testCases, testCase{ |
| 4963 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4964 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4965 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4966 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4967 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4968 | NextProtos: []string{"foo"}, |
| 4969 | }, |
| 4970 | flags: []string{ |
| 4971 | "-false-start", |
| 4972 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4973 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 4974 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 4975 | }, |
| 4976 | shimWritesFirst: true, |
| 4977 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4978 | |
| 4979 | // Client-side renegotiation controls. |
| 4980 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4981 | name: "Renegotiate-Client-Forbidden-1", |
| 4982 | config: Config{ |
| 4983 | MaxVersion: VersionTLS12, |
| 4984 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4985 | renegotiate: 1, |
| 4986 | shouldFail: true, |
| 4987 | expectedError: ":NO_RENEGOTIATION:", |
| 4988 | expectedLocalError: "remote error: no renegotiation", |
| 4989 | }) |
| 4990 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4991 | name: "Renegotiate-Client-Once-1", |
| 4992 | config: Config{ |
| 4993 | MaxVersion: VersionTLS12, |
| 4994 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4995 | renegotiate: 1, |
| 4996 | flags: []string{ |
| 4997 | "-renegotiate-once", |
| 4998 | "-expect-total-renegotiations", "1", |
| 4999 | }, |
| 5000 | }) |
| 5001 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5002 | name: "Renegotiate-Client-Freely-1", |
| 5003 | config: Config{ |
| 5004 | MaxVersion: VersionTLS12, |
| 5005 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5006 | renegotiate: 1, |
| 5007 | flags: []string{ |
| 5008 | "-renegotiate-freely", |
| 5009 | "-expect-total-renegotiations", "1", |
| 5010 | }, |
| 5011 | }) |
| 5012 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5013 | name: "Renegotiate-Client-Once-2", |
| 5014 | config: Config{ |
| 5015 | MaxVersion: VersionTLS12, |
| 5016 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5017 | renegotiate: 2, |
| 5018 | flags: []string{"-renegotiate-once"}, |
| 5019 | shouldFail: true, |
| 5020 | expectedError: ":NO_RENEGOTIATION:", |
| 5021 | expectedLocalError: "remote error: no renegotiation", |
| 5022 | }) |
| 5023 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5024 | name: "Renegotiate-Client-Freely-2", |
| 5025 | config: Config{ |
| 5026 | MaxVersion: VersionTLS12, |
| 5027 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5028 | renegotiate: 2, |
| 5029 | flags: []string{ |
| 5030 | "-renegotiate-freely", |
| 5031 | "-expect-total-renegotiations", "2", |
| 5032 | }, |
| 5033 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5034 | testCases = append(testCases, testCase{ |
| 5035 | name: "Renegotiate-Client-NoIgnore", |
| 5036 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5037 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5038 | Bugs: ProtocolBugs{ |
| 5039 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5040 | }, |
| 5041 | }, |
| 5042 | shouldFail: true, |
| 5043 | expectedError: ":NO_RENEGOTIATION:", |
| 5044 | }) |
| 5045 | testCases = append(testCases, testCase{ |
| 5046 | name: "Renegotiate-Client-Ignore", |
| 5047 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5048 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5049 | Bugs: ProtocolBugs{ |
| 5050 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5051 | }, |
| 5052 | }, |
| 5053 | flags: []string{ |
| 5054 | "-renegotiate-ignore", |
| 5055 | "-expect-total-renegotiations", "0", |
| 5056 | }, |
| 5057 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5058 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5059 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 5060 | testCases = append(testCases, testCase{ |
| 5061 | name: "StrayHelloRequest", |
| 5062 | config: Config{ |
| 5063 | MaxVersion: VersionTLS12, |
| 5064 | Bugs: ProtocolBugs{ |
| 5065 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5066 | }, |
| 5067 | }, |
| 5068 | }) |
| 5069 | testCases = append(testCases, testCase{ |
| 5070 | name: "StrayHelloRequest-Packed", |
| 5071 | config: Config{ |
| 5072 | MaxVersion: VersionTLS12, |
| 5073 | Bugs: ProtocolBugs{ |
| 5074 | PackHandshakeFlight: true, |
| 5075 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5076 | }, |
| 5077 | }, |
| 5078 | }) |
| 5079 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 5080 | // Test renegotiation works if HelloRequest and server Finished come in |
| 5081 | // the same record. |
| 5082 | testCases = append(testCases, testCase{ |
| 5083 | name: "Renegotiate-Client-Packed", |
| 5084 | config: Config{ |
| 5085 | MaxVersion: VersionTLS12, |
| 5086 | Bugs: ProtocolBugs{ |
| 5087 | PackHandshakeFlight: true, |
| 5088 | PackHelloRequestWithFinished: true, |
| 5089 | }, |
| 5090 | }, |
| 5091 | renegotiate: 1, |
| 5092 | flags: []string{ |
| 5093 | "-renegotiate-freely", |
| 5094 | "-expect-total-renegotiations", "1", |
| 5095 | }, |
| 5096 | }) |
| 5097 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5098 | // Renegotiation is forbidden in TLS 1.3. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5099 | // |
| 5100 | // TODO(davidben): This test current asserts that we ignore |
| 5101 | // HelloRequests, but we actually should hard reject them. Fix this |
| 5102 | // test once we actually parse post-handshake messages. |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5103 | testCases = append(testCases, testCase{ |
| 5104 | name: "Renegotiate-Client-TLS13", |
| 5105 | config: Config{ |
| 5106 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5107 | Bugs: ProtocolBugs{ |
| 5108 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5109 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5110 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5111 | flags: []string{ |
| 5112 | "-renegotiate-freely", |
| 5113 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5114 | }) |
| 5115 | |
| 5116 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 5117 | testCases = append(testCases, testCase{ |
| 5118 | name: "StrayHelloRequest-TLS13", |
| 5119 | config: Config{ |
| 5120 | MaxVersion: VersionTLS13, |
| 5121 | Bugs: ProtocolBugs{ |
| 5122 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5123 | }, |
| 5124 | }, |
| 5125 | shouldFail: true, |
| 5126 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 5127 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5128 | } |
| 5129 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5130 | func addDTLSReplayTests() { |
| 5131 | // Test that sequence number replays are detected. |
| 5132 | testCases = append(testCases, testCase{ |
| 5133 | protocol: dtls, |
| 5134 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5135 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5136 | replayWrites: true, |
| 5137 | }) |
| 5138 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5139 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5140 | // than the retransmit window. |
| 5141 | testCases = append(testCases, testCase{ |
| 5142 | protocol: dtls, |
| 5143 | name: "DTLS-Replay-LargeGaps", |
| 5144 | config: Config{ |
| 5145 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5146 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5147 | return in * 127 |
| 5148 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5149 | }, |
| 5150 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5151 | messageCount: 200, |
| 5152 | replayWrites: true, |
| 5153 | }) |
| 5154 | |
| 5155 | // Test the incoming sequence number changing non-monotonically. |
| 5156 | testCases = append(testCases, testCase{ |
| 5157 | protocol: dtls, |
| 5158 | name: "DTLS-Replay-NonMonotonic", |
| 5159 | config: Config{ |
| 5160 | Bugs: ProtocolBugs{ |
| 5161 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5162 | return in ^ 31 |
| 5163 | }, |
| 5164 | }, |
| 5165 | }, |
| 5166 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5167 | replayWrites: true, |
| 5168 | }) |
| 5169 | } |
| 5170 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5171 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5172 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5173 | id signatureAlgorithm |
| 5174 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5175 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5176 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 5177 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 5178 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 5179 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5180 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5181 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 5182 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 5183 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5184 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 5185 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 5186 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5187 | // Tests for key types prior to TLS 1.2. |
| 5188 | {"RSA", 0, testCertRSA}, |
| 5189 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5190 | } |
| 5191 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5192 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 5193 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 5194 | |
| 5195 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5196 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 5197 | // versions a signing cipher. |
| 5198 | signingCiphers := []uint16{ |
| 5199 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 5200 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 5201 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 5202 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 5203 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 5204 | } |
| 5205 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5206 | var allAlgorithms []signatureAlgorithm |
| 5207 | for _, alg := range testSignatureAlgorithms { |
| 5208 | if alg.id != 0 { |
| 5209 | allAlgorithms = append(allAlgorithms, alg.id) |
| 5210 | } |
| 5211 | } |
| 5212 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5213 | // Make sure each signature algorithm works. Include some fake values in |
| 5214 | // the list and ensure they're ignored. |
| 5215 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5216 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5217 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 5218 | continue |
| 5219 | } |
| 5220 | |
| 5221 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 5222 | // or remove it in C. |
| 5223 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5224 | continue |
| 5225 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5226 | |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5227 | var shouldFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5228 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5229 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
| 5230 | shouldFail = true |
| 5231 | } |
| 5232 | // RSA-PSS does not exist in TLS 1.2. |
| 5233 | if ver.version == VersionTLS12 && hasComponent(alg.name, "PSS") { |
| 5234 | shouldFail = true |
| 5235 | } |
| 5236 | |
| 5237 | var signError, verifyError string |
| 5238 | if shouldFail { |
| 5239 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
| 5240 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5241 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5242 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5243 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 5244 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5245 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5246 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5247 | config: Config{ |
| 5248 | MaxVersion: ver.version, |
| 5249 | ClientAuth: RequireAnyClientCert, |
| 5250 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5251 | fakeSigAlg1, |
| 5252 | alg.id, |
| 5253 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5254 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5255 | }, |
| 5256 | flags: []string{ |
| 5257 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5258 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5259 | "-enable-all-curves", |
| 5260 | }, |
| 5261 | shouldFail: shouldFail, |
| 5262 | expectedError: signError, |
| 5263 | expectedPeerSignatureAlgorithm: alg.id, |
| 5264 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5265 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5266 | testCases = append(testCases, testCase{ |
| 5267 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5268 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5269 | config: Config{ |
| 5270 | MaxVersion: ver.version, |
| 5271 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5272 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5273 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5274 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5275 | Bugs: ProtocolBugs{ |
| 5276 | SkipECDSACurveCheck: shouldFail, |
| 5277 | IgnoreSignatureVersionChecks: shouldFail, |
| 5278 | // The client won't advertise 1.3-only algorithms after |
| 5279 | // version negotiation. |
| 5280 | IgnorePeerSignatureAlgorithmPreferences: shouldFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5281 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5282 | }, |
| 5283 | flags: []string{ |
| 5284 | "-require-any-client-certificate", |
| 5285 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5286 | "-enable-all-curves", |
| 5287 | }, |
| 5288 | shouldFail: shouldFail, |
| 5289 | expectedError: verifyError, |
| 5290 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5291 | |
| 5292 | testCases = append(testCases, testCase{ |
| 5293 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5294 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5295 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5296 | MaxVersion: ver.version, |
| 5297 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5298 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5299 | fakeSigAlg1, |
| 5300 | alg.id, |
| 5301 | fakeSigAlg2, |
| 5302 | }, |
| 5303 | }, |
| 5304 | flags: []string{ |
| 5305 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5306 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5307 | "-enable-all-curves", |
| 5308 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5309 | shouldFail: shouldFail, |
| 5310 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5311 | expectedPeerSignatureAlgorithm: alg.id, |
| 5312 | }) |
| 5313 | |
| 5314 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5315 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5316 | config: Config{ |
| 5317 | MaxVersion: ver.version, |
| 5318 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5319 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5320 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5321 | alg.id, |
| 5322 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5323 | Bugs: ProtocolBugs{ |
| 5324 | SkipECDSACurveCheck: shouldFail, |
| 5325 | IgnoreSignatureVersionChecks: shouldFail, |
| 5326 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5327 | }, |
| 5328 | flags: []string{ |
| 5329 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5330 | "-enable-all-curves", |
| 5331 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5332 | shouldFail: shouldFail, |
| 5333 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5334 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5335 | |
| 5336 | if !shouldFail { |
| 5337 | testCases = append(testCases, testCase{ |
| 5338 | testType: serverTest, |
| 5339 | name: "ClientAuth-InvalidSignature" + suffix, |
| 5340 | config: Config{ |
| 5341 | MaxVersion: ver.version, |
| 5342 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5343 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5344 | alg.id, |
| 5345 | }, |
| 5346 | Bugs: ProtocolBugs{ |
| 5347 | InvalidSignature: true, |
| 5348 | }, |
| 5349 | }, |
| 5350 | flags: []string{ |
| 5351 | "-require-any-client-certificate", |
| 5352 | "-enable-all-curves", |
| 5353 | }, |
| 5354 | shouldFail: true, |
| 5355 | expectedError: ":BAD_SIGNATURE:", |
| 5356 | }) |
| 5357 | |
| 5358 | testCases = append(testCases, testCase{ |
| 5359 | name: "ServerAuth-InvalidSignature" + suffix, |
| 5360 | config: Config{ |
| 5361 | MaxVersion: ver.version, |
| 5362 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5363 | CipherSuites: signingCiphers, |
| 5364 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5365 | alg.id, |
| 5366 | }, |
| 5367 | Bugs: ProtocolBugs{ |
| 5368 | InvalidSignature: true, |
| 5369 | }, |
| 5370 | }, |
| 5371 | flags: []string{"-enable-all-curves"}, |
| 5372 | shouldFail: true, |
| 5373 | expectedError: ":BAD_SIGNATURE:", |
| 5374 | }) |
| 5375 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5376 | |
| 5377 | if ver.version >= VersionTLS12 && !shouldFail { |
| 5378 | testCases = append(testCases, testCase{ |
| 5379 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 5380 | config: Config{ |
| 5381 | MaxVersion: ver.version, |
| 5382 | ClientAuth: RequireAnyClientCert, |
| 5383 | VerifySignatureAlgorithms: allAlgorithms, |
| 5384 | }, |
| 5385 | flags: []string{ |
| 5386 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5387 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5388 | "-enable-all-curves", |
| 5389 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5390 | }, |
| 5391 | expectedPeerSignatureAlgorithm: alg.id, |
| 5392 | }) |
| 5393 | |
| 5394 | testCases = append(testCases, testCase{ |
| 5395 | testType: serverTest, |
| 5396 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 5397 | config: Config{ |
| 5398 | MaxVersion: ver.version, |
| 5399 | CipherSuites: signingCiphers, |
| 5400 | VerifySignatureAlgorithms: allAlgorithms, |
| 5401 | }, |
| 5402 | flags: []string{ |
| 5403 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5404 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5405 | "-enable-all-curves", |
| 5406 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5407 | }, |
| 5408 | expectedPeerSignatureAlgorithm: alg.id, |
| 5409 | }) |
| 5410 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5411 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5412 | } |
| 5413 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5414 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5415 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5416 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5417 | config: Config{ |
| 5418 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5419 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5420 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5421 | signatureECDSAWithP521AndSHA512, |
| 5422 | signatureRSAPKCS1WithSHA384, |
| 5423 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5424 | }, |
| 5425 | }, |
| 5426 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5427 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5428 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5429 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5430 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5431 | }) |
| 5432 | |
| 5433 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5434 | name: "ClientAuth-SignatureType-TLS13", |
| 5435 | config: Config{ |
| 5436 | ClientAuth: RequireAnyClientCert, |
| 5437 | MaxVersion: VersionTLS13, |
| 5438 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5439 | signatureECDSAWithP521AndSHA512, |
| 5440 | signatureRSAPKCS1WithSHA384, |
| 5441 | signatureRSAPSSWithSHA384, |
| 5442 | signatureECDSAWithSHA1, |
| 5443 | }, |
| 5444 | }, |
| 5445 | flags: []string{ |
| 5446 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5447 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5448 | }, |
| 5449 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5450 | }) |
| 5451 | |
| 5452 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5453 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5454 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5455 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5456 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5457 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5458 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5459 | signatureECDSAWithP521AndSHA512, |
| 5460 | signatureRSAPKCS1WithSHA384, |
| 5461 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5462 | }, |
| 5463 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5464 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5465 | }) |
| 5466 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5467 | testCases = append(testCases, testCase{ |
| 5468 | testType: serverTest, |
| 5469 | name: "ServerAuth-SignatureType-TLS13", |
| 5470 | config: Config{ |
| 5471 | MaxVersion: VersionTLS13, |
| 5472 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5473 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5474 | signatureECDSAWithP521AndSHA512, |
| 5475 | signatureRSAPKCS1WithSHA384, |
| 5476 | signatureRSAPSSWithSHA384, |
| 5477 | signatureECDSAWithSHA1, |
| 5478 | }, |
| 5479 | }, |
| 5480 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5481 | }) |
| 5482 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5483 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5484 | testCases = append(testCases, testCase{ |
| 5485 | testType: serverTest, |
| 5486 | name: "Verify-ClientAuth-SignatureType", |
| 5487 | config: Config{ |
| 5488 | MaxVersion: VersionTLS12, |
| 5489 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5490 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5491 | signatureRSAPKCS1WithSHA256, |
| 5492 | }, |
| 5493 | Bugs: ProtocolBugs{ |
| 5494 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5495 | }, |
| 5496 | }, |
| 5497 | flags: []string{ |
| 5498 | "-require-any-client-certificate", |
| 5499 | }, |
| 5500 | shouldFail: true, |
| 5501 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5502 | }) |
| 5503 | |
| 5504 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5505 | testType: serverTest, |
| 5506 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 5507 | config: Config{ |
| 5508 | MaxVersion: VersionTLS13, |
| 5509 | Certificates: []Certificate{rsaCertificate}, |
| 5510 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5511 | signatureRSAPSSWithSHA256, |
| 5512 | }, |
| 5513 | Bugs: ProtocolBugs{ |
| 5514 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5515 | }, |
| 5516 | }, |
| 5517 | flags: []string{ |
| 5518 | "-require-any-client-certificate", |
| 5519 | }, |
| 5520 | shouldFail: true, |
| 5521 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5522 | }) |
| 5523 | |
| 5524 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5525 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5526 | config: Config{ |
| 5527 | MaxVersion: VersionTLS12, |
| 5528 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5529 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5530 | signatureRSAPKCS1WithSHA256, |
| 5531 | }, |
| 5532 | Bugs: ProtocolBugs{ |
| 5533 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5534 | }, |
| 5535 | }, |
| 5536 | shouldFail: true, |
| 5537 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5538 | }) |
| 5539 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5540 | testCases = append(testCases, testCase{ |
| 5541 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 5542 | config: Config{ |
| 5543 | MaxVersion: VersionTLS13, |
| 5544 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5545 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5546 | signatureRSAPSSWithSHA256, |
| 5547 | }, |
| 5548 | Bugs: ProtocolBugs{ |
| 5549 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5550 | }, |
| 5551 | }, |
| 5552 | shouldFail: true, |
| 5553 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5554 | }) |
| 5555 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5556 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 5557 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5558 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5559 | name: "ClientAuth-SHA1-Fallback", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5560 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5561 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5562 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5563 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5564 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5565 | }, |
| 5566 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5567 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5568 | }, |
| 5569 | }, |
| 5570 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5571 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5572 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5573 | }, |
| 5574 | }) |
| 5575 | |
| 5576 | testCases = append(testCases, testCase{ |
| 5577 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5578 | name: "ServerAuth-SHA1-Fallback", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5579 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5580 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5581 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5582 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5583 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5584 | }, |
| 5585 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5586 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5587 | }, |
| 5588 | }, |
| 5589 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5590 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5591 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5592 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5593 | config: Config{ |
| 5594 | MaxVersion: VersionTLS13, |
| 5595 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5596 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5597 | signatureRSAPKCS1WithSHA1, |
| 5598 | }, |
| 5599 | Bugs: ProtocolBugs{ |
| 5600 | NoSignatureAlgorithms: true, |
| 5601 | }, |
| 5602 | }, |
| 5603 | flags: []string{ |
| 5604 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5605 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5606 | }, |
| 5607 | shouldFail: true, |
| 5608 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5609 | }) |
| 5610 | |
| 5611 | testCases = append(testCases, testCase{ |
| 5612 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5613 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5614 | config: Config{ |
| 5615 | MaxVersion: VersionTLS13, |
| 5616 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5617 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5618 | signatureRSAPKCS1WithSHA1, |
| 5619 | }, |
| 5620 | Bugs: ProtocolBugs{ |
| 5621 | NoSignatureAlgorithms: true, |
| 5622 | }, |
| 5623 | }, |
| 5624 | shouldFail: true, |
| 5625 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5626 | }) |
| 5627 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 5628 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 5629 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5630 | testCases = append(testCases, testCase{ |
| 5631 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5632 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5633 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5634 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5635 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5636 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5637 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5638 | }, |
| 5639 | Bugs: ProtocolBugs{ |
| 5640 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5641 | }, |
| 5642 | }, |
| 5643 | flags: []string{"-require-any-client-certificate"}, |
| 5644 | shouldFail: true, |
| 5645 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5646 | }) |
| 5647 | |
| 5648 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5649 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5650 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5651 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5652 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5653 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5654 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 5655 | }, |
| 5656 | Bugs: ProtocolBugs{ |
| 5657 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5658 | }, |
| 5659 | }, |
| 5660 | shouldFail: true, |
| 5661 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5662 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 5663 | testCases = append(testCases, testCase{ |
| 5664 | testType: serverTest, |
| 5665 | name: "ClientAuth-Enforced-TLS13", |
| 5666 | config: Config{ |
| 5667 | MaxVersion: VersionTLS13, |
| 5668 | Certificates: []Certificate{rsaCertificate}, |
| 5669 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5670 | signatureRSAPKCS1WithMD5, |
| 5671 | }, |
| 5672 | Bugs: ProtocolBugs{ |
| 5673 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5674 | IgnoreSignatureVersionChecks: true, |
| 5675 | }, |
| 5676 | }, |
| 5677 | flags: []string{"-require-any-client-certificate"}, |
| 5678 | shouldFail: true, |
| 5679 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5680 | }) |
| 5681 | |
| 5682 | testCases = append(testCases, testCase{ |
| 5683 | name: "ServerAuth-Enforced-TLS13", |
| 5684 | config: Config{ |
| 5685 | MaxVersion: VersionTLS13, |
| 5686 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5687 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5688 | signatureRSAPKCS1WithMD5, |
| 5689 | }, |
| 5690 | Bugs: ProtocolBugs{ |
| 5691 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 5692 | IgnoreSignatureVersionChecks: true, |
| 5693 | }, |
| 5694 | }, |
| 5695 | shouldFail: true, |
| 5696 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5697 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5698 | |
| 5699 | // Test that the agreed upon digest respects the client preferences and |
| 5700 | // the server digests. |
| 5701 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5702 | name: "NoCommonAlgorithms-Digests", |
| 5703 | config: Config{ |
| 5704 | MaxVersion: VersionTLS12, |
| 5705 | ClientAuth: RequireAnyClientCert, |
| 5706 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5707 | signatureRSAPKCS1WithSHA512, |
| 5708 | signatureRSAPKCS1WithSHA1, |
| 5709 | }, |
| 5710 | }, |
| 5711 | flags: []string{ |
| 5712 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5713 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5714 | "-digest-prefs", "SHA256", |
| 5715 | }, |
| 5716 | shouldFail: true, |
| 5717 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5718 | }) |
| 5719 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 5720 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5721 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5722 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5723 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5724 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5725 | signatureRSAPKCS1WithSHA512, |
| 5726 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5727 | }, |
| 5728 | }, |
| 5729 | flags: []string{ |
| 5730 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5731 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5732 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5733 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5734 | shouldFail: true, |
| 5735 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5736 | }) |
| 5737 | testCases = append(testCases, testCase{ |
| 5738 | name: "NoCommonAlgorithms-TLS13", |
| 5739 | config: Config{ |
| 5740 | MaxVersion: VersionTLS13, |
| 5741 | ClientAuth: RequireAnyClientCert, |
| 5742 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5743 | signatureRSAPSSWithSHA512, |
| 5744 | signatureRSAPSSWithSHA384, |
| 5745 | }, |
| 5746 | }, |
| 5747 | flags: []string{ |
| 5748 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5749 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5750 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 5751 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 5752 | shouldFail: true, |
| 5753 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5754 | }) |
| 5755 | testCases = append(testCases, testCase{ |
| 5756 | name: "Agree-Digest-SHA256", |
| 5757 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5758 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5759 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5760 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5761 | signatureRSAPKCS1WithSHA1, |
| 5762 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5763 | }, |
| 5764 | }, |
| 5765 | flags: []string{ |
| 5766 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5767 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5768 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5769 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5770 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5771 | }) |
| 5772 | testCases = append(testCases, testCase{ |
| 5773 | name: "Agree-Digest-SHA1", |
| 5774 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5775 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5776 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5777 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5778 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5779 | }, |
| 5780 | }, |
| 5781 | flags: []string{ |
| 5782 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5783 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5784 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5785 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5786 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5787 | }) |
| 5788 | testCases = append(testCases, testCase{ |
| 5789 | name: "Agree-Digest-Default", |
| 5790 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5791 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5792 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5793 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5794 | signatureRSAPKCS1WithSHA256, |
| 5795 | signatureECDSAWithP256AndSHA256, |
| 5796 | signatureRSAPKCS1WithSHA1, |
| 5797 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5798 | }, |
| 5799 | }, |
| 5800 | flags: []string{ |
| 5801 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5802 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5803 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5804 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 5805 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5806 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5807 | // Test that the signing preference list may include extra algorithms |
| 5808 | // without negotiation problems. |
| 5809 | testCases = append(testCases, testCase{ |
| 5810 | testType: serverTest, |
| 5811 | name: "FilterExtraAlgorithms", |
| 5812 | config: Config{ |
| 5813 | MaxVersion: VersionTLS12, |
| 5814 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5815 | signatureRSAPKCS1WithSHA256, |
| 5816 | }, |
| 5817 | }, |
| 5818 | flags: []string{ |
| 5819 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5820 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5821 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 5822 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 5823 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 5824 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 5825 | }, |
| 5826 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 5827 | }) |
| 5828 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5829 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 5830 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5831 | testCases = append(testCases, testCase{ |
| 5832 | name: "CheckLeafCurve", |
| 5833 | config: Config{ |
| 5834 | MaxVersion: VersionTLS12, |
| 5835 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5836 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5837 | }, |
| 5838 | flags: []string{"-p384-only"}, |
| 5839 | shouldFail: true, |
| 5840 | expectedError: ":BAD_ECC_CERT:", |
| 5841 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 5842 | |
| 5843 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 5844 | testCases = append(testCases, testCase{ |
| 5845 | name: "CheckLeafCurve-TLS13", |
| 5846 | config: Config{ |
| 5847 | MaxVersion: VersionTLS13, |
| 5848 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5849 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 5850 | }, |
| 5851 | flags: []string{"-p384-only"}, |
| 5852 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5853 | |
| 5854 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 5855 | testCases = append(testCases, testCase{ |
| 5856 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 5857 | config: Config{ |
| 5858 | MaxVersion: VersionTLS12, |
| 5859 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5860 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5861 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5862 | signatureECDSAWithP384AndSHA384, |
| 5863 | }, |
| 5864 | }, |
| 5865 | }) |
| 5866 | |
| 5867 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 5868 | testCases = append(testCases, testCase{ |
| 5869 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 5870 | config: Config{ |
| 5871 | MaxVersion: VersionTLS13, |
| 5872 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 5873 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5874 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5875 | signatureECDSAWithP384AndSHA384, |
| 5876 | }, |
| 5877 | Bugs: ProtocolBugs{ |
| 5878 | SkipECDSACurveCheck: true, |
| 5879 | }, |
| 5880 | }, |
| 5881 | shouldFail: true, |
| 5882 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5883 | }) |
| 5884 | |
| 5885 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 5886 | // account. |
| 5887 | testCases = append(testCases, testCase{ |
| 5888 | testType: serverTest, |
| 5889 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 5890 | config: Config{ |
| 5891 | MaxVersion: VersionTLS13, |
| 5892 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5893 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5894 | signatureECDSAWithP384AndSHA384, |
| 5895 | signatureECDSAWithP256AndSHA256, |
| 5896 | }, |
| 5897 | }, |
| 5898 | flags: []string{ |
| 5899 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 5900 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 5901 | }, |
| 5902 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5903 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 5904 | |
| 5905 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 5906 | // server does not attempt to sign in that case. |
| 5907 | testCases = append(testCases, testCase{ |
| 5908 | testType: serverTest, |
| 5909 | name: "RSA-PSS-Large", |
| 5910 | config: Config{ |
| 5911 | MaxVersion: VersionTLS13, |
| 5912 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5913 | signatureRSAPSSWithSHA512, |
| 5914 | }, |
| 5915 | }, |
| 5916 | flags: []string{ |
| 5917 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 5918 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 5919 | }, |
| 5920 | shouldFail: true, |
| 5921 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 5922 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5923 | } |
| 5924 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5925 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 5926 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 5927 | var timeouts = []time.Duration{ |
| 5928 | 1 * time.Second, |
| 5929 | 2 * time.Second, |
| 5930 | 4 * time.Second, |
| 5931 | 8 * time.Second, |
| 5932 | 16 * time.Second, |
| 5933 | 32 * time.Second, |
| 5934 | 60 * time.Second, |
| 5935 | 60 * time.Second, |
| 5936 | 60 * time.Second, |
| 5937 | 60 * time.Second, |
| 5938 | 60 * time.Second, |
| 5939 | 60 * time.Second, |
| 5940 | 60 * time.Second, |
| 5941 | } |
| 5942 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 5943 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 5944 | // initial timeout duration was set to 250ms. |
| 5945 | var shortTimeouts = []time.Duration{ |
| 5946 | 250 * time.Millisecond, |
| 5947 | 500 * time.Millisecond, |
| 5948 | 1 * time.Second, |
| 5949 | 2 * time.Second, |
| 5950 | 4 * time.Second, |
| 5951 | 8 * time.Second, |
| 5952 | 16 * time.Second, |
| 5953 | 32 * time.Second, |
| 5954 | 60 * time.Second, |
| 5955 | 60 * time.Second, |
| 5956 | 60 * time.Second, |
| 5957 | 60 * time.Second, |
| 5958 | 60 * time.Second, |
| 5959 | } |
| 5960 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 5961 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5962 | // These tests work by coordinating some behavior on both the shim and |
| 5963 | // the runner. |
| 5964 | // |
| 5965 | // TimeoutSchedule configures the runner to send a series of timeout |
| 5966 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 5967 | // each peer handshake flight N. The timeout opcode both simulates a |
| 5968 | // timeout in the shim and acts as a synchronization point to help the |
| 5969 | // runner bracket each handshake flight. |
| 5970 | // |
| 5971 | // We assume the shim does not read from the channel eagerly. It must |
| 5972 | // first wait until it has sent flight N and is ready to receive |
| 5973 | // handshake flight N+1. At this point, it will process the timeout |
| 5974 | // opcode. It must then immediately respond with a timeout ACK and act |
| 5975 | // as if the shim was idle for the specified amount of time. |
| 5976 | // |
| 5977 | // The runner then drops all packets received before the ACK and |
| 5978 | // continues waiting for flight N. This ordering results in one attempt |
| 5979 | // at sending flight N to be dropped. For the test to complete, the |
| 5980 | // shim must send flight N again, testing that the shim implements DTLS |
| 5981 | // retransmit on a timeout. |
| 5982 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5983 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5984 | // likely be more epochs to cross and the final message's retransmit may |
| 5985 | // be more complex. |
| 5986 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5987 | for _, async := range []bool{true, false} { |
| 5988 | var tests []testCase |
| 5989 | |
| 5990 | // Test that this is indeed the timeout schedule. Stress all |
| 5991 | // four patterns of handshake. |
| 5992 | for i := 1; i < len(timeouts); i++ { |
| 5993 | number := strconv.Itoa(i) |
| 5994 | tests = append(tests, testCase{ |
| 5995 | protocol: dtls, |
| 5996 | name: "DTLS-Retransmit-Client-" + number, |
| 5997 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5998 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 5999 | Bugs: ProtocolBugs{ |
| 6000 | TimeoutSchedule: timeouts[:i], |
| 6001 | }, |
| 6002 | }, |
| 6003 | resumeSession: true, |
| 6004 | }) |
| 6005 | tests = append(tests, testCase{ |
| 6006 | protocol: dtls, |
| 6007 | testType: serverTest, |
| 6008 | name: "DTLS-Retransmit-Server-" + number, |
| 6009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6010 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6011 | Bugs: ProtocolBugs{ |
| 6012 | TimeoutSchedule: timeouts[:i], |
| 6013 | }, |
| 6014 | }, |
| 6015 | resumeSession: true, |
| 6016 | }) |
| 6017 | } |
| 6018 | |
| 6019 | // Test that exceeding the timeout schedule hits a read |
| 6020 | // timeout. |
| 6021 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6022 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6023 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6024 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6025 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6026 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6027 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6028 | }, |
| 6029 | }, |
| 6030 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6031 | shouldFail: true, |
| 6032 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6033 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6034 | |
| 6035 | if async { |
| 6036 | // Test that timeout handling has a fudge factor, due to API |
| 6037 | // problems. |
| 6038 | tests = append(tests, testCase{ |
| 6039 | protocol: dtls, |
| 6040 | name: "DTLS-Retransmit-Fudge", |
| 6041 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6042 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6043 | Bugs: ProtocolBugs{ |
| 6044 | TimeoutSchedule: []time.Duration{ |
| 6045 | timeouts[0] - 10*time.Millisecond, |
| 6046 | }, |
| 6047 | }, |
| 6048 | }, |
| 6049 | resumeSession: true, |
| 6050 | }) |
| 6051 | } |
| 6052 | |
| 6053 | // Test that the final Finished retransmitting isn't |
| 6054 | // duplicated if the peer badly fragments everything. |
| 6055 | tests = append(tests, testCase{ |
| 6056 | testType: serverTest, |
| 6057 | protocol: dtls, |
| 6058 | name: "DTLS-Retransmit-Fragmented", |
| 6059 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6060 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6061 | Bugs: ProtocolBugs{ |
| 6062 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 6063 | MaxHandshakeRecordLength: 2, |
| 6064 | }, |
| 6065 | }, |
| 6066 | }) |
| 6067 | |
| 6068 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 6069 | tests = append(tests, testCase{ |
| 6070 | protocol: dtls, |
| 6071 | name: "DTLS-Retransmit-Short-Client", |
| 6072 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6073 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6074 | Bugs: ProtocolBugs{ |
| 6075 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 6076 | }, |
| 6077 | }, |
| 6078 | resumeSession: true, |
| 6079 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 6080 | }) |
| 6081 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6082 | protocol: dtls, |
| 6083 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6084 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6085 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6086 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6087 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6088 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6089 | }, |
| 6090 | }, |
| 6091 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6092 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6093 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6094 | |
| 6095 | for _, test := range tests { |
| 6096 | if async { |
| 6097 | test.name += "-Async" |
| 6098 | test.flags = append(test.flags, "-async") |
| 6099 | } |
| 6100 | |
| 6101 | testCases = append(testCases, test) |
| 6102 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6103 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6104 | } |
| 6105 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 6106 | func addExportKeyingMaterialTests() { |
| 6107 | for _, vers := range tlsVersions { |
| 6108 | if vers.version == VersionSSL30 { |
| 6109 | continue |
| 6110 | } |
| 6111 | testCases = append(testCases, testCase{ |
| 6112 | name: "ExportKeyingMaterial-" + vers.name, |
| 6113 | config: Config{ |
| 6114 | MaxVersion: vers.version, |
| 6115 | }, |
| 6116 | exportKeyingMaterial: 1024, |
| 6117 | exportLabel: "label", |
| 6118 | exportContext: "context", |
| 6119 | useExportContext: true, |
| 6120 | }) |
| 6121 | testCases = append(testCases, testCase{ |
| 6122 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 6123 | config: Config{ |
| 6124 | MaxVersion: vers.version, |
| 6125 | }, |
| 6126 | exportKeyingMaterial: 1024, |
| 6127 | }) |
| 6128 | testCases = append(testCases, testCase{ |
| 6129 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 6130 | config: Config{ |
| 6131 | MaxVersion: vers.version, |
| 6132 | }, |
| 6133 | exportKeyingMaterial: 1024, |
| 6134 | useExportContext: true, |
| 6135 | }) |
| 6136 | testCases = append(testCases, testCase{ |
| 6137 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 6138 | config: Config{ |
| 6139 | MaxVersion: vers.version, |
| 6140 | }, |
| 6141 | exportKeyingMaterial: 1, |
| 6142 | exportLabel: "label", |
| 6143 | exportContext: "context", |
| 6144 | useExportContext: true, |
| 6145 | }) |
| 6146 | } |
| 6147 | testCases = append(testCases, testCase{ |
| 6148 | name: "ExportKeyingMaterial-SSL3", |
| 6149 | config: Config{ |
| 6150 | MaxVersion: VersionSSL30, |
| 6151 | }, |
| 6152 | exportKeyingMaterial: 1024, |
| 6153 | exportLabel: "label", |
| 6154 | exportContext: "context", |
| 6155 | useExportContext: true, |
| 6156 | shouldFail: true, |
| 6157 | expectedError: "failed to export keying material", |
| 6158 | }) |
| 6159 | } |
| 6160 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6161 | func addTLSUniqueTests() { |
| 6162 | for _, isClient := range []bool{false, true} { |
| 6163 | for _, isResumption := range []bool{false, true} { |
| 6164 | for _, hasEMS := range []bool{false, true} { |
| 6165 | var suffix string |
| 6166 | if isResumption { |
| 6167 | suffix = "Resume-" |
| 6168 | } else { |
| 6169 | suffix = "Full-" |
| 6170 | } |
| 6171 | |
| 6172 | if hasEMS { |
| 6173 | suffix += "EMS-" |
| 6174 | } else { |
| 6175 | suffix += "NoEMS-" |
| 6176 | } |
| 6177 | |
| 6178 | if isClient { |
| 6179 | suffix += "Client" |
| 6180 | } else { |
| 6181 | suffix += "Server" |
| 6182 | } |
| 6183 | |
| 6184 | test := testCase{ |
| 6185 | name: "TLSUnique-" + suffix, |
| 6186 | testTLSUnique: true, |
| 6187 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6188 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6189 | Bugs: ProtocolBugs{ |
| 6190 | NoExtendedMasterSecret: !hasEMS, |
| 6191 | }, |
| 6192 | }, |
| 6193 | } |
| 6194 | |
| 6195 | if isResumption { |
| 6196 | test.resumeSession = true |
| 6197 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6198 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6199 | Bugs: ProtocolBugs{ |
| 6200 | NoExtendedMasterSecret: !hasEMS, |
| 6201 | }, |
| 6202 | } |
| 6203 | } |
| 6204 | |
| 6205 | if isResumption && !hasEMS { |
| 6206 | test.shouldFail = true |
| 6207 | test.expectedError = "failed to get tls-unique" |
| 6208 | } |
| 6209 | |
| 6210 | testCases = append(testCases, test) |
| 6211 | } |
| 6212 | } |
| 6213 | } |
| 6214 | } |
| 6215 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6216 | func addCustomExtensionTests() { |
| 6217 | expectedContents := "custom extension" |
| 6218 | emptyString := "" |
| 6219 | |
| 6220 | for _, isClient := range []bool{false, true} { |
| 6221 | suffix := "Server" |
| 6222 | flag := "-enable-server-custom-extension" |
| 6223 | testType := serverTest |
| 6224 | if isClient { |
| 6225 | suffix = "Client" |
| 6226 | flag = "-enable-client-custom-extension" |
| 6227 | testType = clientTest |
| 6228 | } |
| 6229 | |
| 6230 | testCases = append(testCases, testCase{ |
| 6231 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6232 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6233 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6234 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6235 | Bugs: ProtocolBugs{ |
| 6236 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6237 | ExpectedCustomExtension: &expectedContents, |
| 6238 | }, |
| 6239 | }, |
| 6240 | flags: []string{flag}, |
| 6241 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6242 | testCases = append(testCases, testCase{ |
| 6243 | testType: testType, |
| 6244 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 6245 | config: Config{ |
| 6246 | MaxVersion: VersionTLS13, |
| 6247 | Bugs: ProtocolBugs{ |
| 6248 | CustomExtension: expectedContents, |
| 6249 | ExpectedCustomExtension: &expectedContents, |
| 6250 | }, |
| 6251 | }, |
| 6252 | flags: []string{flag}, |
| 6253 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6254 | |
| 6255 | // If the parse callback fails, the handshake should also fail. |
| 6256 | testCases = append(testCases, testCase{ |
| 6257 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6258 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6259 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6260 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6261 | Bugs: ProtocolBugs{ |
| 6262 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6263 | ExpectedCustomExtension: &expectedContents, |
| 6264 | }, |
| 6265 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6266 | flags: []string{flag}, |
| 6267 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6268 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6269 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6270 | testCases = append(testCases, testCase{ |
| 6271 | testType: testType, |
| 6272 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 6273 | config: Config{ |
| 6274 | MaxVersion: VersionTLS13, |
| 6275 | Bugs: ProtocolBugs{ |
| 6276 | CustomExtension: expectedContents + "foo", |
| 6277 | ExpectedCustomExtension: &expectedContents, |
| 6278 | }, |
| 6279 | }, |
| 6280 | flags: []string{flag}, |
| 6281 | shouldFail: true, |
| 6282 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6283 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6284 | |
| 6285 | // If the add callback fails, the handshake should also fail. |
| 6286 | testCases = append(testCases, testCase{ |
| 6287 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6288 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6289 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6290 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6291 | Bugs: ProtocolBugs{ |
| 6292 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6293 | ExpectedCustomExtension: &expectedContents, |
| 6294 | }, |
| 6295 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6296 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6297 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6298 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6299 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6300 | testCases = append(testCases, testCase{ |
| 6301 | testType: testType, |
| 6302 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 6303 | config: Config{ |
| 6304 | MaxVersion: VersionTLS13, |
| 6305 | Bugs: ProtocolBugs{ |
| 6306 | CustomExtension: expectedContents, |
| 6307 | ExpectedCustomExtension: &expectedContents, |
| 6308 | }, |
| 6309 | }, |
| 6310 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6311 | shouldFail: true, |
| 6312 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6313 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6314 | |
| 6315 | // If the add callback returns zero, no extension should be |
| 6316 | // added. |
| 6317 | skipCustomExtension := expectedContents |
| 6318 | if isClient { |
| 6319 | // For the case where the client skips sending the |
| 6320 | // custom extension, the server must not “echo” it. |
| 6321 | skipCustomExtension = "" |
| 6322 | } |
| 6323 | testCases = append(testCases, testCase{ |
| 6324 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6325 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6326 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6327 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6328 | Bugs: ProtocolBugs{ |
| 6329 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6330 | ExpectedCustomExtension: &emptyString, |
| 6331 | }, |
| 6332 | }, |
| 6333 | flags: []string{flag, "-custom-extension-skip"}, |
| 6334 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6335 | testCases = append(testCases, testCase{ |
| 6336 | testType: testType, |
| 6337 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 6338 | config: Config{ |
| 6339 | MaxVersion: VersionTLS13, |
| 6340 | Bugs: ProtocolBugs{ |
| 6341 | CustomExtension: skipCustomExtension, |
| 6342 | ExpectedCustomExtension: &emptyString, |
| 6343 | }, |
| 6344 | }, |
| 6345 | flags: []string{flag, "-custom-extension-skip"}, |
| 6346 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6347 | } |
| 6348 | |
| 6349 | // The custom extension add callback should not be called if the client |
| 6350 | // doesn't send the extension. |
| 6351 | testCases = append(testCases, testCase{ |
| 6352 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6353 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6354 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6355 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6356 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6357 | ExpectedCustomExtension: &emptyString, |
| 6358 | }, |
| 6359 | }, |
| 6360 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6361 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6362 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6363 | testCases = append(testCases, testCase{ |
| 6364 | testType: serverTest, |
| 6365 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 6366 | config: Config{ |
| 6367 | MaxVersion: VersionTLS13, |
| 6368 | Bugs: ProtocolBugs{ |
| 6369 | ExpectedCustomExtension: &emptyString, |
| 6370 | }, |
| 6371 | }, |
| 6372 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6373 | }) |
| 6374 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6375 | // Test an unknown extension from the server. |
| 6376 | testCases = append(testCases, testCase{ |
| 6377 | testType: clientTest, |
| 6378 | name: "UnknownExtension-Client", |
| 6379 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6380 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6381 | Bugs: ProtocolBugs{ |
| 6382 | CustomExtension: expectedContents, |
| 6383 | }, |
| 6384 | }, |
| 6385 | shouldFail: true, |
| 6386 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6387 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6388 | testCases = append(testCases, testCase{ |
| 6389 | testType: clientTest, |
| 6390 | name: "UnknownExtension-Client-TLS13", |
| 6391 | config: Config{ |
| 6392 | MaxVersion: VersionTLS13, |
| 6393 | Bugs: ProtocolBugs{ |
| 6394 | CustomExtension: expectedContents, |
| 6395 | }, |
| 6396 | }, |
| 6397 | shouldFail: true, |
| 6398 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6399 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6400 | } |
| 6401 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6402 | func addRSAClientKeyExchangeTests() { |
| 6403 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 6404 | testCases = append(testCases, testCase{ |
| 6405 | testType: serverTest, |
| 6406 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 6407 | config: Config{ |
| 6408 | // Ensure the ClientHello version and final |
| 6409 | // version are different, to detect if the |
| 6410 | // server uses the wrong one. |
| 6411 | MaxVersion: VersionTLS11, |
| 6412 | CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, |
| 6413 | Bugs: ProtocolBugs{ |
| 6414 | BadRSAClientKeyExchange: bad, |
| 6415 | }, |
| 6416 | }, |
| 6417 | shouldFail: true, |
| 6418 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6419 | }) |
| 6420 | } |
| 6421 | } |
| 6422 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6423 | var testCurves = []struct { |
| 6424 | name string |
| 6425 | id CurveID |
| 6426 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6427 | {"P-256", CurveP256}, |
| 6428 | {"P-384", CurveP384}, |
| 6429 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 6430 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6431 | } |
| 6432 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6433 | const bogusCurve = 0x1234 |
| 6434 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6435 | func addCurveTests() { |
| 6436 | for _, curve := range testCurves { |
| 6437 | testCases = append(testCases, testCase{ |
| 6438 | name: "CurveTest-Client-" + curve.name, |
| 6439 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6440 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6441 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6442 | CurvePreferences: []CurveID{curve.id}, |
| 6443 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6444 | flags: []string{"-enable-all-curves"}, |
| 6445 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6446 | }) |
| 6447 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6448 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 6449 | config: Config{ |
| 6450 | MaxVersion: VersionTLS13, |
| 6451 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6452 | CurvePreferences: []CurveID{curve.id}, |
| 6453 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6454 | flags: []string{"-enable-all-curves"}, |
| 6455 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6456 | }) |
| 6457 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6458 | testType: serverTest, |
| 6459 | name: "CurveTest-Server-" + curve.name, |
| 6460 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6461 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6462 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6463 | CurvePreferences: []CurveID{curve.id}, |
| 6464 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6465 | flags: []string{"-enable-all-curves"}, |
| 6466 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6467 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6468 | testCases = append(testCases, testCase{ |
| 6469 | testType: serverTest, |
| 6470 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 6471 | config: Config{ |
| 6472 | MaxVersion: VersionTLS13, |
| 6473 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6474 | CurvePreferences: []CurveID{curve.id}, |
| 6475 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6476 | flags: []string{"-enable-all-curves"}, |
| 6477 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6478 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6479 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 6480 | |
| 6481 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 6482 | testCases = append(testCases, testCase{ |
| 6483 | testType: serverTest, |
| 6484 | name: "UnknownCurve", |
| 6485 | config: Config{ |
| 6486 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6487 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 6488 | }, |
| 6489 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6490 | |
| 6491 | // The server must not consider ECDHE ciphers when there are no |
| 6492 | // supported curves. |
| 6493 | testCases = append(testCases, testCase{ |
| 6494 | testType: serverTest, |
| 6495 | name: "NoSupportedCurves", |
| 6496 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6497 | MaxVersion: VersionTLS12, |
| 6498 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6499 | Bugs: ProtocolBugs{ |
| 6500 | NoSupportedCurves: true, |
| 6501 | }, |
| 6502 | }, |
| 6503 | shouldFail: true, |
| 6504 | expectedError: ":NO_SHARED_CIPHER:", |
| 6505 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6506 | testCases = append(testCases, testCase{ |
| 6507 | testType: serverTest, |
| 6508 | name: "NoSupportedCurves-TLS13", |
| 6509 | config: Config{ |
| 6510 | MaxVersion: VersionTLS13, |
| 6511 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6512 | Bugs: ProtocolBugs{ |
| 6513 | NoSupportedCurves: true, |
| 6514 | }, |
| 6515 | }, |
| 6516 | shouldFail: true, |
| 6517 | expectedError: ":NO_SHARED_CIPHER:", |
| 6518 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6519 | |
| 6520 | // The server must fall back to another cipher when there are no |
| 6521 | // supported curves. |
| 6522 | testCases = append(testCases, testCase{ |
| 6523 | testType: serverTest, |
| 6524 | name: "NoCommonCurves", |
| 6525 | config: Config{ |
| 6526 | MaxVersion: VersionTLS12, |
| 6527 | CipherSuites: []uint16{ |
| 6528 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6529 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6530 | }, |
| 6531 | CurvePreferences: []CurveID{CurveP224}, |
| 6532 | }, |
| 6533 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6534 | }) |
| 6535 | |
| 6536 | // The client must reject bogus curves and disabled curves. |
| 6537 | testCases = append(testCases, testCase{ |
| 6538 | name: "BadECDHECurve", |
| 6539 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6540 | MaxVersion: VersionTLS12, |
| 6541 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6542 | Bugs: ProtocolBugs{ |
| 6543 | SendCurve: bogusCurve, |
| 6544 | }, |
| 6545 | }, |
| 6546 | shouldFail: true, |
| 6547 | expectedError: ":WRONG_CURVE:", |
| 6548 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6549 | testCases = append(testCases, testCase{ |
| 6550 | name: "BadECDHECurve-TLS13", |
| 6551 | config: Config{ |
| 6552 | MaxVersion: VersionTLS13, |
| 6553 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6554 | Bugs: ProtocolBugs{ |
| 6555 | SendCurve: bogusCurve, |
| 6556 | }, |
| 6557 | }, |
| 6558 | shouldFail: true, |
| 6559 | expectedError: ":WRONG_CURVE:", |
| 6560 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6561 | |
| 6562 | testCases = append(testCases, testCase{ |
| 6563 | name: "UnsupportedCurve", |
| 6564 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6565 | MaxVersion: VersionTLS12, |
| 6566 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6567 | CurvePreferences: []CurveID{CurveP256}, |
| 6568 | Bugs: ProtocolBugs{ |
| 6569 | IgnorePeerCurvePreferences: true, |
| 6570 | }, |
| 6571 | }, |
| 6572 | flags: []string{"-p384-only"}, |
| 6573 | shouldFail: true, |
| 6574 | expectedError: ":WRONG_CURVE:", |
| 6575 | }) |
| 6576 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 6577 | testCases = append(testCases, testCase{ |
| 6578 | // TODO(davidben): Add a TLS 1.3 version where |
| 6579 | // HelloRetryRequest requests an unsupported curve. |
| 6580 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 6581 | config: Config{ |
| 6582 | MaxVersion: VersionTLS12, |
| 6583 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6584 | CurvePreferences: []CurveID{CurveP384}, |
| 6585 | Bugs: ProtocolBugs{ |
| 6586 | SendCurve: CurveP256, |
| 6587 | }, |
| 6588 | }, |
| 6589 | flags: []string{"-p384-only"}, |
| 6590 | shouldFail: true, |
| 6591 | expectedError: ":WRONG_CURVE:", |
| 6592 | }) |
| 6593 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6594 | // Test invalid curve points. |
| 6595 | testCases = append(testCases, testCase{ |
| 6596 | name: "InvalidECDHPoint-Client", |
| 6597 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6598 | MaxVersion: VersionTLS12, |
| 6599 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6600 | CurvePreferences: []CurveID{CurveP256}, |
| 6601 | Bugs: ProtocolBugs{ |
| 6602 | InvalidECDHPoint: true, |
| 6603 | }, |
| 6604 | }, |
| 6605 | shouldFail: true, |
| 6606 | expectedError: ":INVALID_ENCODING:", |
| 6607 | }) |
| 6608 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6609 | name: "InvalidECDHPoint-Client-TLS13", |
| 6610 | config: Config{ |
| 6611 | MaxVersion: VersionTLS13, |
| 6612 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6613 | CurvePreferences: []CurveID{CurveP256}, |
| 6614 | Bugs: ProtocolBugs{ |
| 6615 | InvalidECDHPoint: true, |
| 6616 | }, |
| 6617 | }, |
| 6618 | shouldFail: true, |
| 6619 | expectedError: ":INVALID_ENCODING:", |
| 6620 | }) |
| 6621 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6622 | testType: serverTest, |
| 6623 | name: "InvalidECDHPoint-Server", |
| 6624 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6625 | MaxVersion: VersionTLS12, |
| 6626 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6627 | CurvePreferences: []CurveID{CurveP256}, |
| 6628 | Bugs: ProtocolBugs{ |
| 6629 | InvalidECDHPoint: true, |
| 6630 | }, |
| 6631 | }, |
| 6632 | shouldFail: true, |
| 6633 | expectedError: ":INVALID_ENCODING:", |
| 6634 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6635 | testCases = append(testCases, testCase{ |
| 6636 | testType: serverTest, |
| 6637 | name: "InvalidECDHPoint-Server-TLS13", |
| 6638 | config: Config{ |
| 6639 | MaxVersion: VersionTLS13, |
| 6640 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6641 | CurvePreferences: []CurveID{CurveP256}, |
| 6642 | Bugs: ProtocolBugs{ |
| 6643 | InvalidECDHPoint: true, |
| 6644 | }, |
| 6645 | }, |
| 6646 | shouldFail: true, |
| 6647 | expectedError: ":INVALID_ENCODING:", |
| 6648 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6649 | } |
| 6650 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6651 | func addCECPQ1Tests() { |
| 6652 | testCases = append(testCases, testCase{ |
| 6653 | testType: clientTest, |
| 6654 | name: "CECPQ1-Client-BadX25519Part", |
| 6655 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6656 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6657 | MinVersion: VersionTLS12, |
| 6658 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6659 | Bugs: ProtocolBugs{ |
| 6660 | CECPQ1BadX25519Part: true, |
| 6661 | }, |
| 6662 | }, |
| 6663 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6664 | shouldFail: true, |
| 6665 | expectedLocalError: "local error: bad record MAC", |
| 6666 | }) |
| 6667 | testCases = append(testCases, testCase{ |
| 6668 | testType: clientTest, |
| 6669 | name: "CECPQ1-Client-BadNewhopePart", |
| 6670 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6671 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6672 | MinVersion: VersionTLS12, |
| 6673 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6674 | Bugs: ProtocolBugs{ |
| 6675 | CECPQ1BadNewhopePart: true, |
| 6676 | }, |
| 6677 | }, |
| 6678 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6679 | shouldFail: true, |
| 6680 | expectedLocalError: "local error: bad record MAC", |
| 6681 | }) |
| 6682 | testCases = append(testCases, testCase{ |
| 6683 | testType: serverTest, |
| 6684 | name: "CECPQ1-Server-BadX25519Part", |
| 6685 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6686 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6687 | MinVersion: VersionTLS12, |
| 6688 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6689 | Bugs: ProtocolBugs{ |
| 6690 | CECPQ1BadX25519Part: true, |
| 6691 | }, |
| 6692 | }, |
| 6693 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6694 | shouldFail: true, |
| 6695 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6696 | }) |
| 6697 | testCases = append(testCases, testCase{ |
| 6698 | testType: serverTest, |
| 6699 | name: "CECPQ1-Server-BadNewhopePart", |
| 6700 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6701 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 6702 | MinVersion: VersionTLS12, |
| 6703 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 6704 | Bugs: ProtocolBugs{ |
| 6705 | CECPQ1BadNewhopePart: true, |
| 6706 | }, |
| 6707 | }, |
| 6708 | flags: []string{"-cipher", "kCECPQ1"}, |
| 6709 | shouldFail: true, |
| 6710 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6711 | }) |
| 6712 | } |
| 6713 | |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6714 | func addKeyExchangeInfoTests() { |
| 6715 | testCases = append(testCases, testCase{ |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6716 | name: "KeyExchangeInfo-DHE-Client", |
| 6717 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6718 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6719 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6720 | Bugs: ProtocolBugs{ |
| 6721 | // This is a 1234-bit prime number, generated |
| 6722 | // with: |
| 6723 | // openssl gendh 1234 | openssl asn1parse -i |
| 6724 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 6725 | }, |
| 6726 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6727 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6728 | }) |
| 6729 | testCases = append(testCases, testCase{ |
| 6730 | testType: serverTest, |
| 6731 | name: "KeyExchangeInfo-DHE-Server", |
| 6732 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6733 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6734 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6735 | }, |
| 6736 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6737 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6738 | }) |
| 6739 | |
| 6740 | testCases = append(testCases, testCase{ |
| 6741 | name: "KeyExchangeInfo-ECDHE-Client", |
| 6742 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6743 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6744 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6745 | CurvePreferences: []CurveID{CurveX25519}, |
| 6746 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6747 | flags: []string{"-expect-curve-id", "29", "-enable-all-curves"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6748 | }) |
| 6749 | testCases = append(testCases, testCase{ |
| 6750 | testType: serverTest, |
| 6751 | name: "KeyExchangeInfo-ECDHE-Server", |
| 6752 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6753 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6754 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6755 | CurvePreferences: []CurveID{CurveX25519}, |
| 6756 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 6757 | flags: []string{"-expect-curve-id", "29", "-enable-all-curves"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 6758 | }) |
| 6759 | } |
| 6760 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 6761 | func addTLS13RecordTests() { |
| 6762 | testCases = append(testCases, testCase{ |
| 6763 | name: "TLS13-RecordPadding", |
| 6764 | config: Config{ |
| 6765 | MaxVersion: VersionTLS13, |
| 6766 | MinVersion: VersionTLS13, |
| 6767 | Bugs: ProtocolBugs{ |
| 6768 | RecordPadding: 10, |
| 6769 | }, |
| 6770 | }, |
| 6771 | }) |
| 6772 | |
| 6773 | testCases = append(testCases, testCase{ |
| 6774 | name: "TLS13-EmptyRecords", |
| 6775 | config: Config{ |
| 6776 | MaxVersion: VersionTLS13, |
| 6777 | MinVersion: VersionTLS13, |
| 6778 | Bugs: ProtocolBugs{ |
| 6779 | OmitRecordContents: true, |
| 6780 | }, |
| 6781 | }, |
| 6782 | shouldFail: true, |
| 6783 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6784 | }) |
| 6785 | |
| 6786 | testCases = append(testCases, testCase{ |
| 6787 | name: "TLS13-OnlyPadding", |
| 6788 | config: Config{ |
| 6789 | MaxVersion: VersionTLS13, |
| 6790 | MinVersion: VersionTLS13, |
| 6791 | Bugs: ProtocolBugs{ |
| 6792 | OmitRecordContents: true, |
| 6793 | RecordPadding: 10, |
| 6794 | }, |
| 6795 | }, |
| 6796 | shouldFail: true, |
| 6797 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6798 | }) |
| 6799 | |
| 6800 | testCases = append(testCases, testCase{ |
| 6801 | name: "TLS13-WrongOuterRecord", |
| 6802 | config: Config{ |
| 6803 | MaxVersion: VersionTLS13, |
| 6804 | MinVersion: VersionTLS13, |
| 6805 | Bugs: ProtocolBugs{ |
| 6806 | OuterRecordType: recordTypeHandshake, |
| 6807 | }, |
| 6808 | }, |
| 6809 | shouldFail: true, |
| 6810 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 6811 | }) |
| 6812 | } |
| 6813 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6814 | func addChangeCipherSpecTests() { |
| 6815 | // Test missing ChangeCipherSpecs. |
| 6816 | testCases = append(testCases, testCase{ |
| 6817 | name: "SkipChangeCipherSpec-Client", |
| 6818 | config: Config{ |
| 6819 | MaxVersion: VersionTLS12, |
| 6820 | Bugs: ProtocolBugs{ |
| 6821 | SkipChangeCipherSpec: true, |
| 6822 | }, |
| 6823 | }, |
| 6824 | shouldFail: true, |
| 6825 | expectedError: ":UNEXPECTED_RECORD:", |
| 6826 | }) |
| 6827 | testCases = append(testCases, testCase{ |
| 6828 | testType: serverTest, |
| 6829 | name: "SkipChangeCipherSpec-Server", |
| 6830 | config: Config{ |
| 6831 | MaxVersion: VersionTLS12, |
| 6832 | Bugs: ProtocolBugs{ |
| 6833 | SkipChangeCipherSpec: true, |
| 6834 | }, |
| 6835 | }, |
| 6836 | shouldFail: true, |
| 6837 | expectedError: ":UNEXPECTED_RECORD:", |
| 6838 | }) |
| 6839 | testCases = append(testCases, testCase{ |
| 6840 | testType: serverTest, |
| 6841 | name: "SkipChangeCipherSpec-Server-NPN", |
| 6842 | config: Config{ |
| 6843 | MaxVersion: VersionTLS12, |
| 6844 | NextProtos: []string{"bar"}, |
| 6845 | Bugs: ProtocolBugs{ |
| 6846 | SkipChangeCipherSpec: true, |
| 6847 | }, |
| 6848 | }, |
| 6849 | flags: []string{ |
| 6850 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 6851 | }, |
| 6852 | shouldFail: true, |
| 6853 | expectedError: ":UNEXPECTED_RECORD:", |
| 6854 | }) |
| 6855 | |
| 6856 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 6857 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 6858 | // rejected. Test both with and without handshake packing to handle both |
| 6859 | // when the partial post-CCS message is in its own record and when it is |
| 6860 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6861 | for _, packed := range []bool{false, true} { |
| 6862 | var suffix string |
| 6863 | if packed { |
| 6864 | suffix = "-Packed" |
| 6865 | } |
| 6866 | |
| 6867 | testCases = append(testCases, testCase{ |
| 6868 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 6869 | config: Config{ |
| 6870 | MaxVersion: VersionTLS12, |
| 6871 | Bugs: ProtocolBugs{ |
| 6872 | FragmentAcrossChangeCipherSpec: true, |
| 6873 | PackHandshakeFlight: packed, |
| 6874 | }, |
| 6875 | }, |
| 6876 | shouldFail: true, |
| 6877 | expectedError: ":UNEXPECTED_RECORD:", |
| 6878 | }) |
| 6879 | testCases = append(testCases, testCase{ |
| 6880 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 6881 | config: Config{ |
| 6882 | MaxVersion: VersionTLS12, |
| 6883 | }, |
| 6884 | resumeSession: true, |
| 6885 | resumeConfig: &Config{ |
| 6886 | MaxVersion: VersionTLS12, |
| 6887 | Bugs: ProtocolBugs{ |
| 6888 | FragmentAcrossChangeCipherSpec: true, |
| 6889 | PackHandshakeFlight: packed, |
| 6890 | }, |
| 6891 | }, |
| 6892 | shouldFail: true, |
| 6893 | expectedError: ":UNEXPECTED_RECORD:", |
| 6894 | }) |
| 6895 | testCases = append(testCases, testCase{ |
| 6896 | testType: serverTest, |
| 6897 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 6898 | config: Config{ |
| 6899 | MaxVersion: VersionTLS12, |
| 6900 | Bugs: ProtocolBugs{ |
| 6901 | FragmentAcrossChangeCipherSpec: true, |
| 6902 | PackHandshakeFlight: packed, |
| 6903 | }, |
| 6904 | }, |
| 6905 | shouldFail: true, |
| 6906 | expectedError: ":UNEXPECTED_RECORD:", |
| 6907 | }) |
| 6908 | testCases = append(testCases, testCase{ |
| 6909 | testType: serverTest, |
| 6910 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 6911 | config: Config{ |
| 6912 | MaxVersion: VersionTLS12, |
| 6913 | }, |
| 6914 | resumeSession: true, |
| 6915 | resumeConfig: &Config{ |
| 6916 | MaxVersion: VersionTLS12, |
| 6917 | Bugs: ProtocolBugs{ |
| 6918 | FragmentAcrossChangeCipherSpec: true, |
| 6919 | PackHandshakeFlight: packed, |
| 6920 | }, |
| 6921 | }, |
| 6922 | shouldFail: true, |
| 6923 | expectedError: ":UNEXPECTED_RECORD:", |
| 6924 | }) |
| 6925 | testCases = append(testCases, testCase{ |
| 6926 | testType: serverTest, |
| 6927 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 6928 | config: Config{ |
| 6929 | MaxVersion: VersionTLS12, |
| 6930 | NextProtos: []string{"bar"}, |
| 6931 | Bugs: ProtocolBugs{ |
| 6932 | FragmentAcrossChangeCipherSpec: true, |
| 6933 | PackHandshakeFlight: packed, |
| 6934 | }, |
| 6935 | }, |
| 6936 | flags: []string{ |
| 6937 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 6938 | }, |
| 6939 | shouldFail: true, |
| 6940 | expectedError: ":UNEXPECTED_RECORD:", |
| 6941 | }) |
| 6942 | } |
| 6943 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 6944 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 6945 | // messages in the handshake queue. Do this by testing the server |
| 6946 | // reading the client Finished, reversing the flight so Finished comes |
| 6947 | // first. |
| 6948 | testCases = append(testCases, testCase{ |
| 6949 | protocol: dtls, |
| 6950 | testType: serverTest, |
| 6951 | name: "SendUnencryptedFinished-DTLS", |
| 6952 | config: Config{ |
| 6953 | MaxVersion: VersionTLS12, |
| 6954 | Bugs: ProtocolBugs{ |
| 6955 | SendUnencryptedFinished: true, |
| 6956 | ReverseHandshakeFragments: true, |
| 6957 | }, |
| 6958 | }, |
| 6959 | shouldFail: true, |
| 6960 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6961 | }) |
| 6962 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6963 | // Test synchronization between encryption changes and the handshake in |
| 6964 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 6965 | testCases = append(testCases, testCase{ |
| 6966 | name: "PartialEncryptedExtensionsWithServerHello", |
| 6967 | config: Config{ |
| 6968 | MaxVersion: VersionTLS13, |
| 6969 | Bugs: ProtocolBugs{ |
| 6970 | PartialEncryptedExtensionsWithServerHello: true, |
| 6971 | }, |
| 6972 | }, |
| 6973 | shouldFail: true, |
| 6974 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6975 | }) |
| 6976 | testCases = append(testCases, testCase{ |
| 6977 | testType: serverTest, |
| 6978 | name: "PartialClientFinishedWithClientHello", |
| 6979 | config: Config{ |
| 6980 | MaxVersion: VersionTLS13, |
| 6981 | Bugs: ProtocolBugs{ |
| 6982 | PartialClientFinishedWithClientHello: true, |
| 6983 | }, |
| 6984 | }, |
| 6985 | shouldFail: true, |
| 6986 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 6987 | }) |
| 6988 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 6989 | // Test that early ChangeCipherSpecs are handled correctly. |
| 6990 | testCases = append(testCases, testCase{ |
| 6991 | testType: serverTest, |
| 6992 | name: "EarlyChangeCipherSpec-server-1", |
| 6993 | config: Config{ |
| 6994 | MaxVersion: VersionTLS12, |
| 6995 | Bugs: ProtocolBugs{ |
| 6996 | EarlyChangeCipherSpec: 1, |
| 6997 | }, |
| 6998 | }, |
| 6999 | shouldFail: true, |
| 7000 | expectedError: ":UNEXPECTED_RECORD:", |
| 7001 | }) |
| 7002 | testCases = append(testCases, testCase{ |
| 7003 | testType: serverTest, |
| 7004 | name: "EarlyChangeCipherSpec-server-2", |
| 7005 | config: Config{ |
| 7006 | MaxVersion: VersionTLS12, |
| 7007 | Bugs: ProtocolBugs{ |
| 7008 | EarlyChangeCipherSpec: 2, |
| 7009 | }, |
| 7010 | }, |
| 7011 | shouldFail: true, |
| 7012 | expectedError: ":UNEXPECTED_RECORD:", |
| 7013 | }) |
| 7014 | testCases = append(testCases, testCase{ |
| 7015 | protocol: dtls, |
| 7016 | name: "StrayChangeCipherSpec", |
| 7017 | config: Config{ |
| 7018 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 7019 | // that stray ChangeCipherSpec messages are |
| 7020 | // rejected. |
| 7021 | MaxVersion: VersionTLS12, |
| 7022 | Bugs: ProtocolBugs{ |
| 7023 | StrayChangeCipherSpec: true, |
| 7024 | }, |
| 7025 | }, |
| 7026 | }) |
| 7027 | |
| 7028 | // Test that the contents of ChangeCipherSpec are checked. |
| 7029 | testCases = append(testCases, testCase{ |
| 7030 | name: "BadChangeCipherSpec-1", |
| 7031 | config: Config{ |
| 7032 | MaxVersion: VersionTLS12, |
| 7033 | Bugs: ProtocolBugs{ |
| 7034 | BadChangeCipherSpec: []byte{2}, |
| 7035 | }, |
| 7036 | }, |
| 7037 | shouldFail: true, |
| 7038 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7039 | }) |
| 7040 | testCases = append(testCases, testCase{ |
| 7041 | name: "BadChangeCipherSpec-2", |
| 7042 | config: Config{ |
| 7043 | MaxVersion: VersionTLS12, |
| 7044 | Bugs: ProtocolBugs{ |
| 7045 | BadChangeCipherSpec: []byte{1, 1}, |
| 7046 | }, |
| 7047 | }, |
| 7048 | shouldFail: true, |
| 7049 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7050 | }) |
| 7051 | testCases = append(testCases, testCase{ |
| 7052 | protocol: dtls, |
| 7053 | name: "BadChangeCipherSpec-DTLS-1", |
| 7054 | config: Config{ |
| 7055 | MaxVersion: VersionTLS12, |
| 7056 | Bugs: ProtocolBugs{ |
| 7057 | BadChangeCipherSpec: []byte{2}, |
| 7058 | }, |
| 7059 | }, |
| 7060 | shouldFail: true, |
| 7061 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7062 | }) |
| 7063 | testCases = append(testCases, testCase{ |
| 7064 | protocol: dtls, |
| 7065 | name: "BadChangeCipherSpec-DTLS-2", |
| 7066 | config: Config{ |
| 7067 | MaxVersion: VersionTLS12, |
| 7068 | Bugs: ProtocolBugs{ |
| 7069 | BadChangeCipherSpec: []byte{1, 1}, |
| 7070 | }, |
| 7071 | }, |
| 7072 | shouldFail: true, |
| 7073 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7074 | }) |
| 7075 | } |
| 7076 | |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7077 | func addWrongMessageTypeTests() { |
| 7078 | for _, protocol := range []protocol{tls, dtls} { |
| 7079 | var suffix string |
| 7080 | if protocol == dtls { |
| 7081 | suffix = "-DTLS" |
| 7082 | } |
| 7083 | |
| 7084 | testCases = append(testCases, testCase{ |
| 7085 | protocol: protocol, |
| 7086 | testType: serverTest, |
| 7087 | name: "WrongMessageType-ClientHello" + suffix, |
| 7088 | config: Config{ |
| 7089 | MaxVersion: VersionTLS12, |
| 7090 | Bugs: ProtocolBugs{ |
| 7091 | SendWrongMessageType: typeClientHello, |
| 7092 | }, |
| 7093 | }, |
| 7094 | shouldFail: true, |
| 7095 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7096 | expectedLocalError: "remote error: unexpected message", |
| 7097 | }) |
| 7098 | |
| 7099 | if protocol == dtls { |
| 7100 | testCases = append(testCases, testCase{ |
| 7101 | protocol: protocol, |
| 7102 | name: "WrongMessageType-HelloVerifyRequest" + suffix, |
| 7103 | config: Config{ |
| 7104 | MaxVersion: VersionTLS12, |
| 7105 | Bugs: ProtocolBugs{ |
| 7106 | SendWrongMessageType: typeHelloVerifyRequest, |
| 7107 | }, |
| 7108 | }, |
| 7109 | shouldFail: true, |
| 7110 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7111 | expectedLocalError: "remote error: unexpected message", |
| 7112 | }) |
| 7113 | } |
| 7114 | |
| 7115 | testCases = append(testCases, testCase{ |
| 7116 | protocol: protocol, |
| 7117 | name: "WrongMessageType-ServerHello" + suffix, |
| 7118 | config: Config{ |
| 7119 | MaxVersion: VersionTLS12, |
| 7120 | Bugs: ProtocolBugs{ |
| 7121 | SendWrongMessageType: typeServerHello, |
| 7122 | }, |
| 7123 | }, |
| 7124 | shouldFail: true, |
| 7125 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7126 | expectedLocalError: "remote error: unexpected message", |
| 7127 | }) |
| 7128 | |
| 7129 | testCases = append(testCases, testCase{ |
| 7130 | protocol: protocol, |
| 7131 | name: "WrongMessageType-ServerCertificate" + suffix, |
| 7132 | config: Config{ |
| 7133 | MaxVersion: VersionTLS12, |
| 7134 | Bugs: ProtocolBugs{ |
| 7135 | SendWrongMessageType: typeCertificate, |
| 7136 | }, |
| 7137 | }, |
| 7138 | shouldFail: true, |
| 7139 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7140 | expectedLocalError: "remote error: unexpected message", |
| 7141 | }) |
| 7142 | |
| 7143 | testCases = append(testCases, testCase{ |
| 7144 | protocol: protocol, |
| 7145 | name: "WrongMessageType-CertificateStatus" + suffix, |
| 7146 | config: Config{ |
| 7147 | MaxVersion: VersionTLS12, |
| 7148 | Bugs: ProtocolBugs{ |
| 7149 | SendWrongMessageType: typeCertificateStatus, |
| 7150 | }, |
| 7151 | }, |
| 7152 | flags: []string{"-enable-ocsp-stapling"}, |
| 7153 | shouldFail: true, |
| 7154 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7155 | expectedLocalError: "remote error: unexpected message", |
| 7156 | }) |
| 7157 | |
| 7158 | testCases = append(testCases, testCase{ |
| 7159 | protocol: protocol, |
| 7160 | name: "WrongMessageType-ServerKeyExchange" + suffix, |
| 7161 | config: Config{ |
| 7162 | MaxVersion: VersionTLS12, |
| 7163 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7164 | Bugs: ProtocolBugs{ |
| 7165 | SendWrongMessageType: typeServerKeyExchange, |
| 7166 | }, |
| 7167 | }, |
| 7168 | shouldFail: true, |
| 7169 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7170 | expectedLocalError: "remote error: unexpected message", |
| 7171 | }) |
| 7172 | |
| 7173 | testCases = append(testCases, testCase{ |
| 7174 | protocol: protocol, |
| 7175 | name: "WrongMessageType-CertificateRequest" + suffix, |
| 7176 | config: Config{ |
| 7177 | MaxVersion: VersionTLS12, |
| 7178 | ClientAuth: RequireAnyClientCert, |
| 7179 | Bugs: ProtocolBugs{ |
| 7180 | SendWrongMessageType: typeCertificateRequest, |
| 7181 | }, |
| 7182 | }, |
| 7183 | shouldFail: true, |
| 7184 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7185 | expectedLocalError: "remote error: unexpected message", |
| 7186 | }) |
| 7187 | |
| 7188 | testCases = append(testCases, testCase{ |
| 7189 | protocol: protocol, |
| 7190 | name: "WrongMessageType-ServerHelloDone" + suffix, |
| 7191 | config: Config{ |
| 7192 | MaxVersion: VersionTLS12, |
| 7193 | Bugs: ProtocolBugs{ |
| 7194 | SendWrongMessageType: typeServerHelloDone, |
| 7195 | }, |
| 7196 | }, |
| 7197 | shouldFail: true, |
| 7198 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7199 | expectedLocalError: "remote error: unexpected message", |
| 7200 | }) |
| 7201 | |
| 7202 | testCases = append(testCases, testCase{ |
| 7203 | testType: serverTest, |
| 7204 | protocol: protocol, |
| 7205 | name: "WrongMessageType-ClientCertificate" + suffix, |
| 7206 | config: Config{ |
| 7207 | Certificates: []Certificate{rsaCertificate}, |
| 7208 | MaxVersion: VersionTLS12, |
| 7209 | Bugs: ProtocolBugs{ |
| 7210 | SendWrongMessageType: typeCertificate, |
| 7211 | }, |
| 7212 | }, |
| 7213 | flags: []string{"-require-any-client-certificate"}, |
| 7214 | shouldFail: true, |
| 7215 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7216 | expectedLocalError: "remote error: unexpected message", |
| 7217 | }) |
| 7218 | |
| 7219 | testCases = append(testCases, testCase{ |
| 7220 | testType: serverTest, |
| 7221 | protocol: protocol, |
| 7222 | name: "WrongMessageType-CertificateVerify" + suffix, |
| 7223 | config: Config{ |
| 7224 | Certificates: []Certificate{rsaCertificate}, |
| 7225 | MaxVersion: VersionTLS12, |
| 7226 | Bugs: ProtocolBugs{ |
| 7227 | SendWrongMessageType: typeCertificateVerify, |
| 7228 | }, |
| 7229 | }, |
| 7230 | flags: []string{"-require-any-client-certificate"}, |
| 7231 | shouldFail: true, |
| 7232 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7233 | expectedLocalError: "remote error: unexpected message", |
| 7234 | }) |
| 7235 | |
| 7236 | testCases = append(testCases, testCase{ |
| 7237 | testType: serverTest, |
| 7238 | protocol: protocol, |
| 7239 | name: "WrongMessageType-ClientKeyExchange" + suffix, |
| 7240 | config: Config{ |
| 7241 | MaxVersion: VersionTLS12, |
| 7242 | Bugs: ProtocolBugs{ |
| 7243 | SendWrongMessageType: typeClientKeyExchange, |
| 7244 | }, |
| 7245 | }, |
| 7246 | shouldFail: true, |
| 7247 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7248 | expectedLocalError: "remote error: unexpected message", |
| 7249 | }) |
| 7250 | |
| 7251 | if protocol != dtls { |
| 7252 | testCases = append(testCases, testCase{ |
| 7253 | testType: serverTest, |
| 7254 | protocol: protocol, |
| 7255 | name: "WrongMessageType-NextProtocol" + suffix, |
| 7256 | config: Config{ |
| 7257 | MaxVersion: VersionTLS12, |
| 7258 | NextProtos: []string{"bar"}, |
| 7259 | Bugs: ProtocolBugs{ |
| 7260 | SendWrongMessageType: typeNextProtocol, |
| 7261 | }, |
| 7262 | }, |
| 7263 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 7264 | shouldFail: true, |
| 7265 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7266 | expectedLocalError: "remote error: unexpected message", |
| 7267 | }) |
| 7268 | |
| 7269 | testCases = append(testCases, testCase{ |
| 7270 | testType: serverTest, |
| 7271 | protocol: protocol, |
| 7272 | name: "WrongMessageType-ChannelID" + suffix, |
| 7273 | config: Config{ |
| 7274 | MaxVersion: VersionTLS12, |
| 7275 | ChannelID: channelIDKey, |
| 7276 | Bugs: ProtocolBugs{ |
| 7277 | SendWrongMessageType: typeChannelID, |
| 7278 | }, |
| 7279 | }, |
| 7280 | flags: []string{ |
| 7281 | "-expect-channel-id", |
| 7282 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 7283 | }, |
| 7284 | shouldFail: true, |
| 7285 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7286 | expectedLocalError: "remote error: unexpected message", |
| 7287 | }) |
| 7288 | } |
| 7289 | |
| 7290 | testCases = append(testCases, testCase{ |
| 7291 | testType: serverTest, |
| 7292 | protocol: protocol, |
| 7293 | name: "WrongMessageType-ClientFinished" + suffix, |
| 7294 | config: Config{ |
| 7295 | MaxVersion: VersionTLS12, |
| 7296 | Bugs: ProtocolBugs{ |
| 7297 | SendWrongMessageType: typeFinished, |
| 7298 | }, |
| 7299 | }, |
| 7300 | shouldFail: true, |
| 7301 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7302 | expectedLocalError: "remote error: unexpected message", |
| 7303 | }) |
| 7304 | |
| 7305 | testCases = append(testCases, testCase{ |
| 7306 | protocol: protocol, |
| 7307 | name: "WrongMessageType-NewSessionTicket" + suffix, |
| 7308 | config: Config{ |
| 7309 | MaxVersion: VersionTLS12, |
| 7310 | Bugs: ProtocolBugs{ |
| 7311 | SendWrongMessageType: typeNewSessionTicket, |
| 7312 | }, |
| 7313 | }, |
| 7314 | shouldFail: true, |
| 7315 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7316 | expectedLocalError: "remote error: unexpected message", |
| 7317 | }) |
| 7318 | |
| 7319 | testCases = append(testCases, testCase{ |
| 7320 | protocol: protocol, |
| 7321 | name: "WrongMessageType-ServerFinished" + suffix, |
| 7322 | config: Config{ |
| 7323 | MaxVersion: VersionTLS12, |
| 7324 | Bugs: ProtocolBugs{ |
| 7325 | SendWrongMessageType: typeFinished, |
| 7326 | }, |
| 7327 | }, |
| 7328 | shouldFail: true, |
| 7329 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7330 | expectedLocalError: "remote error: unexpected message", |
| 7331 | }) |
| 7332 | |
| 7333 | } |
| 7334 | } |
| 7335 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7336 | func addTLS13WrongMessageTypeTests() { |
| 7337 | testCases = append(testCases, testCase{ |
| 7338 | testType: serverTest, |
| 7339 | name: "WrongMessageType-TLS13-ClientHello", |
| 7340 | config: Config{ |
| 7341 | MaxVersion: VersionTLS13, |
| 7342 | Bugs: ProtocolBugs{ |
| 7343 | SendWrongMessageType: typeClientHello, |
| 7344 | }, |
| 7345 | }, |
| 7346 | shouldFail: true, |
| 7347 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7348 | expectedLocalError: "remote error: unexpected message", |
| 7349 | }) |
| 7350 | |
| 7351 | testCases = append(testCases, testCase{ |
| 7352 | name: "WrongMessageType-TLS13-ServerHello", |
| 7353 | config: Config{ |
| 7354 | MaxVersion: VersionTLS13, |
| 7355 | Bugs: ProtocolBugs{ |
| 7356 | SendWrongMessageType: typeServerHello, |
| 7357 | }, |
| 7358 | }, |
| 7359 | shouldFail: true, |
| 7360 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7361 | // The alert comes in with the wrong encryption. |
| 7362 | expectedLocalError: "local error: bad record MAC", |
| 7363 | }) |
| 7364 | |
| 7365 | testCases = append(testCases, testCase{ |
| 7366 | name: "WrongMessageType-TLS13-EncryptedExtensions", |
| 7367 | config: Config{ |
| 7368 | MaxVersion: VersionTLS13, |
| 7369 | Bugs: ProtocolBugs{ |
| 7370 | SendWrongMessageType: typeEncryptedExtensions, |
| 7371 | }, |
| 7372 | }, |
| 7373 | shouldFail: true, |
| 7374 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7375 | expectedLocalError: "remote error: unexpected message", |
| 7376 | }) |
| 7377 | |
| 7378 | testCases = append(testCases, testCase{ |
| 7379 | name: "WrongMessageType-TLS13-CertificateRequest", |
| 7380 | config: Config{ |
| 7381 | MaxVersion: VersionTLS13, |
| 7382 | ClientAuth: RequireAnyClientCert, |
| 7383 | Bugs: ProtocolBugs{ |
| 7384 | SendWrongMessageType: typeCertificateRequest, |
| 7385 | }, |
| 7386 | }, |
| 7387 | shouldFail: true, |
| 7388 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7389 | expectedLocalError: "remote error: unexpected message", |
| 7390 | }) |
| 7391 | |
| 7392 | testCases = append(testCases, testCase{ |
| 7393 | name: "WrongMessageType-TLS13-ServerCertificate", |
| 7394 | config: Config{ |
| 7395 | MaxVersion: VersionTLS13, |
| 7396 | Bugs: ProtocolBugs{ |
| 7397 | SendWrongMessageType: typeCertificate, |
| 7398 | }, |
| 7399 | }, |
| 7400 | shouldFail: true, |
| 7401 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7402 | expectedLocalError: "remote error: unexpected message", |
| 7403 | }) |
| 7404 | |
| 7405 | testCases = append(testCases, testCase{ |
| 7406 | name: "WrongMessageType-TLS13-ServerCertificateVerify", |
| 7407 | config: Config{ |
| 7408 | MaxVersion: VersionTLS13, |
| 7409 | Bugs: ProtocolBugs{ |
| 7410 | SendWrongMessageType: typeCertificateVerify, |
| 7411 | }, |
| 7412 | }, |
| 7413 | shouldFail: true, |
| 7414 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7415 | expectedLocalError: "remote error: unexpected message", |
| 7416 | }) |
| 7417 | |
| 7418 | testCases = append(testCases, testCase{ |
| 7419 | name: "WrongMessageType-TLS13-ServerFinished", |
| 7420 | config: Config{ |
| 7421 | MaxVersion: VersionTLS13, |
| 7422 | Bugs: ProtocolBugs{ |
| 7423 | SendWrongMessageType: typeFinished, |
| 7424 | }, |
| 7425 | }, |
| 7426 | shouldFail: true, |
| 7427 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7428 | expectedLocalError: "remote error: unexpected message", |
| 7429 | }) |
| 7430 | |
| 7431 | testCases = append(testCases, testCase{ |
| 7432 | testType: serverTest, |
| 7433 | name: "WrongMessageType-TLS13-ClientCertificate", |
| 7434 | config: Config{ |
| 7435 | Certificates: []Certificate{rsaCertificate}, |
| 7436 | MaxVersion: VersionTLS13, |
| 7437 | Bugs: ProtocolBugs{ |
| 7438 | SendWrongMessageType: typeCertificate, |
| 7439 | }, |
| 7440 | }, |
| 7441 | flags: []string{"-require-any-client-certificate"}, |
| 7442 | shouldFail: true, |
| 7443 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7444 | expectedLocalError: "remote error: unexpected message", |
| 7445 | }) |
| 7446 | |
| 7447 | testCases = append(testCases, testCase{ |
| 7448 | testType: serverTest, |
| 7449 | name: "WrongMessageType-TLS13-ClientCertificateVerify", |
| 7450 | config: Config{ |
| 7451 | Certificates: []Certificate{rsaCertificate}, |
| 7452 | MaxVersion: VersionTLS13, |
| 7453 | Bugs: ProtocolBugs{ |
| 7454 | SendWrongMessageType: typeCertificateVerify, |
| 7455 | }, |
| 7456 | }, |
| 7457 | flags: []string{"-require-any-client-certificate"}, |
| 7458 | shouldFail: true, |
| 7459 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7460 | expectedLocalError: "remote error: unexpected message", |
| 7461 | }) |
| 7462 | |
| 7463 | testCases = append(testCases, testCase{ |
| 7464 | testType: serverTest, |
| 7465 | name: "WrongMessageType-TLS13-ClientFinished", |
| 7466 | config: Config{ |
| 7467 | MaxVersion: VersionTLS13, |
| 7468 | Bugs: ProtocolBugs{ |
| 7469 | SendWrongMessageType: typeFinished, |
| 7470 | }, |
| 7471 | }, |
| 7472 | shouldFail: true, |
| 7473 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7474 | expectedLocalError: "remote error: unexpected message", |
| 7475 | }) |
| 7476 | } |
| 7477 | |
| 7478 | func addTLS13HandshakeTests() { |
| 7479 | testCases = append(testCases, testCase{ |
| 7480 | testType: clientTest, |
| 7481 | name: "MissingKeyShare-Client", |
| 7482 | config: Config{ |
| 7483 | MaxVersion: VersionTLS13, |
| 7484 | Bugs: ProtocolBugs{ |
| 7485 | MissingKeyShare: true, |
| 7486 | }, |
| 7487 | }, |
| 7488 | shouldFail: true, |
| 7489 | expectedError: ":MISSING_KEY_SHARE:", |
| 7490 | }) |
| 7491 | |
| 7492 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7493 | testType: serverTest, |
| 7494 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7495 | config: Config{ |
| 7496 | MaxVersion: VersionTLS13, |
| 7497 | Bugs: ProtocolBugs{ |
| 7498 | MissingKeyShare: true, |
| 7499 | }, |
| 7500 | }, |
| 7501 | shouldFail: true, |
| 7502 | expectedError: ":MISSING_KEY_SHARE:", |
| 7503 | }) |
| 7504 | |
| 7505 | testCases = append(testCases, testCase{ |
| 7506 | testType: clientTest, |
| 7507 | name: "ClientHelloMissingKeyShare", |
| 7508 | config: Config{ |
| 7509 | MaxVersion: VersionTLS13, |
| 7510 | Bugs: ProtocolBugs{ |
| 7511 | MissingKeyShare: true, |
| 7512 | }, |
| 7513 | }, |
| 7514 | shouldFail: true, |
| 7515 | expectedError: ":MISSING_KEY_SHARE:", |
| 7516 | }) |
| 7517 | |
| 7518 | testCases = append(testCases, testCase{ |
| 7519 | testType: clientTest, |
| 7520 | name: "MissingKeyShare", |
| 7521 | config: Config{ |
| 7522 | MaxVersion: VersionTLS13, |
| 7523 | Bugs: ProtocolBugs{ |
| 7524 | MissingKeyShare: true, |
| 7525 | }, |
| 7526 | }, |
| 7527 | shouldFail: true, |
| 7528 | expectedError: ":MISSING_KEY_SHARE:", |
| 7529 | }) |
| 7530 | |
| 7531 | testCases = append(testCases, testCase{ |
| 7532 | testType: serverTest, |
| 7533 | name: "DuplicateKeyShares", |
| 7534 | config: Config{ |
| 7535 | MaxVersion: VersionTLS13, |
| 7536 | Bugs: ProtocolBugs{ |
| 7537 | DuplicateKeyShares: true, |
| 7538 | }, |
| 7539 | }, |
| 7540 | }) |
| 7541 | |
| 7542 | testCases = append(testCases, testCase{ |
| 7543 | testType: clientTest, |
| 7544 | name: "EmptyEncryptedExtensions", |
| 7545 | config: Config{ |
| 7546 | MaxVersion: VersionTLS13, |
| 7547 | Bugs: ProtocolBugs{ |
| 7548 | EmptyEncryptedExtensions: true, |
| 7549 | }, |
| 7550 | }, |
| 7551 | shouldFail: true, |
| 7552 | expectedLocalError: "remote error: error decoding message", |
| 7553 | }) |
| 7554 | |
| 7555 | testCases = append(testCases, testCase{ |
| 7556 | testType: clientTest, |
| 7557 | name: "EncryptedExtensionsWithKeyShare", |
| 7558 | config: Config{ |
| 7559 | MaxVersion: VersionTLS13, |
| 7560 | Bugs: ProtocolBugs{ |
| 7561 | EncryptedExtensionsWithKeyShare: true, |
| 7562 | }, |
| 7563 | }, |
| 7564 | shouldFail: true, |
| 7565 | expectedLocalError: "remote error: unsupported extension", |
| 7566 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7567 | |
| 7568 | testCases = append(testCases, testCase{ |
| 7569 | testType: serverTest, |
| 7570 | name: "SendHelloRetryRequest", |
| 7571 | config: Config{ |
| 7572 | MaxVersion: VersionTLS13, |
| 7573 | // Require a HelloRetryRequest for every curve. |
| 7574 | DefaultCurves: []CurveID{}, |
| 7575 | }, |
| 7576 | expectedCurveID: CurveX25519, |
| 7577 | }) |
| 7578 | |
| 7579 | testCases = append(testCases, testCase{ |
| 7580 | testType: serverTest, |
| 7581 | name: "SendHelloRetryRequest-2", |
| 7582 | config: Config{ |
| 7583 | MaxVersion: VersionTLS13, |
| 7584 | DefaultCurves: []CurveID{CurveP384}, |
| 7585 | }, |
| 7586 | // Although the ClientHello did not predict our preferred curve, |
| 7587 | // we always select it whether it is predicted or not. |
| 7588 | expectedCurveID: CurveX25519, |
| 7589 | }) |
| 7590 | |
| 7591 | testCases = append(testCases, testCase{ |
| 7592 | name: "UnknownCurve-HelloRetryRequest", |
| 7593 | config: Config{ |
| 7594 | MaxVersion: VersionTLS13, |
| 7595 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 7596 | CurvePreferences: []CurveID{CurveP384}, |
| 7597 | Bugs: ProtocolBugs{ |
| 7598 | SendHelloRetryRequestCurve: bogusCurve, |
| 7599 | }, |
| 7600 | }, |
| 7601 | shouldFail: true, |
| 7602 | expectedError: ":WRONG_CURVE:", |
| 7603 | }) |
| 7604 | |
| 7605 | testCases = append(testCases, testCase{ |
| 7606 | name: "DisabledCurve-HelloRetryRequest", |
| 7607 | config: Config{ |
| 7608 | MaxVersion: VersionTLS13, |
| 7609 | CurvePreferences: []CurveID{CurveP256}, |
| 7610 | Bugs: ProtocolBugs{ |
| 7611 | IgnorePeerCurvePreferences: true, |
| 7612 | }, |
| 7613 | }, |
| 7614 | flags: []string{"-p384-only"}, |
| 7615 | shouldFail: true, |
| 7616 | expectedError: ":WRONG_CURVE:", |
| 7617 | }) |
| 7618 | |
| 7619 | testCases = append(testCases, testCase{ |
| 7620 | name: "UnnecessaryHelloRetryRequest", |
| 7621 | config: Config{ |
| 7622 | MaxVersion: VersionTLS13, |
| 7623 | Bugs: ProtocolBugs{ |
| 7624 | UnnecessaryHelloRetryRequest: true, |
| 7625 | }, |
| 7626 | }, |
| 7627 | shouldFail: true, |
| 7628 | expectedError: ":WRONG_CURVE:", |
| 7629 | }) |
| 7630 | |
| 7631 | testCases = append(testCases, testCase{ |
| 7632 | name: "SecondHelloRetryRequest", |
| 7633 | config: Config{ |
| 7634 | MaxVersion: VersionTLS13, |
| 7635 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 7636 | CurvePreferences: []CurveID{CurveP384}, |
| 7637 | Bugs: ProtocolBugs{ |
| 7638 | SecondHelloRetryRequest: true, |
| 7639 | }, |
| 7640 | }, |
| 7641 | shouldFail: true, |
| 7642 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7643 | }) |
| 7644 | |
| 7645 | testCases = append(testCases, testCase{ |
| 7646 | testType: serverTest, |
| 7647 | name: "SecondClientHelloMissingKeyShare", |
| 7648 | config: Config{ |
| 7649 | MaxVersion: VersionTLS13, |
| 7650 | DefaultCurves: []CurveID{}, |
| 7651 | Bugs: ProtocolBugs{ |
| 7652 | SecondClientHelloMissingKeyShare: true, |
| 7653 | }, |
| 7654 | }, |
| 7655 | shouldFail: true, |
| 7656 | expectedError: ":MISSING_KEY_SHARE:", |
| 7657 | }) |
| 7658 | |
| 7659 | testCases = append(testCases, testCase{ |
| 7660 | testType: serverTest, |
| 7661 | name: "SecondClientHelloWrongCurve", |
| 7662 | config: Config{ |
| 7663 | MaxVersion: VersionTLS13, |
| 7664 | DefaultCurves: []CurveID{}, |
| 7665 | Bugs: ProtocolBugs{ |
| 7666 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 7667 | }, |
| 7668 | }, |
| 7669 | shouldFail: true, |
| 7670 | expectedError: ":WRONG_CURVE:", |
| 7671 | }) |
| 7672 | |
| 7673 | testCases = append(testCases, testCase{ |
| 7674 | name: "HelloRetryRequestVersionMismatch", |
| 7675 | config: Config{ |
| 7676 | MaxVersion: VersionTLS13, |
| 7677 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 7678 | CurvePreferences: []CurveID{CurveP384}, |
| 7679 | Bugs: ProtocolBugs{ |
| 7680 | SendServerHelloVersion: 0x0305, |
| 7681 | }, |
| 7682 | }, |
| 7683 | shouldFail: true, |
| 7684 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 7685 | }) |
| 7686 | |
| 7687 | testCases = append(testCases, testCase{ |
| 7688 | name: "HelloRetryRequestCurveMismatch", |
| 7689 | config: Config{ |
| 7690 | MaxVersion: VersionTLS13, |
| 7691 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 7692 | CurvePreferences: []CurveID{CurveP384}, |
| 7693 | Bugs: ProtocolBugs{ |
| 7694 | // Send P-384 (correct) in the HelloRetryRequest. |
| 7695 | SendHelloRetryRequestCurve: CurveP384, |
| 7696 | // But send P-256 in the ServerHello. |
| 7697 | SendCurve: CurveP256, |
| 7698 | }, |
| 7699 | }, |
| 7700 | shouldFail: true, |
| 7701 | expectedError: ":WRONG_CURVE:", |
| 7702 | }) |
| 7703 | |
| 7704 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 7705 | // without sending it. |
| 7706 | testCases = append(testCases, testCase{ |
| 7707 | name: "SkipHelloRetryRequest", |
| 7708 | config: Config{ |
| 7709 | MaxVersion: VersionTLS13, |
| 7710 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 7711 | CurvePreferences: []CurveID{CurveP384}, |
| 7712 | Bugs: ProtocolBugs{ |
| 7713 | SkipHelloRetryRequest: true, |
| 7714 | }, |
| 7715 | }, |
| 7716 | shouldFail: true, |
| 7717 | expectedError: ":WRONG_CURVE:", |
| 7718 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7719 | } |
| 7720 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7721 | func worker(statusChan chan statusMsg, c chan *testCase, shimPath string, wg *sync.WaitGroup) { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7722 | defer wg.Done() |
| 7723 | |
| 7724 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7725 | var err error |
| 7726 | |
| 7727 | if *mallocTest < 0 { |
| 7728 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7729 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7730 | } else { |
| 7731 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 7732 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7733 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 7734 | if err != nil { |
| 7735 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 7736 | } |
| 7737 | break |
| 7738 | } |
| 7739 | } |
| 7740 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7741 | statusChan <- statusMsg{test: test, err: err} |
| 7742 | } |
| 7743 | } |
| 7744 | |
| 7745 | type statusMsg struct { |
| 7746 | test *testCase |
| 7747 | started bool |
| 7748 | err error |
| 7749 | } |
| 7750 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7751 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 7752 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7753 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7754 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7755 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7756 | if !*pipe { |
| 7757 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 7758 | var erase string |
| 7759 | for i := 0; i < lineLen; i++ { |
| 7760 | erase += "\b \b" |
| 7761 | } |
| 7762 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7763 | } |
| 7764 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7765 | if msg.started { |
| 7766 | started++ |
| 7767 | } else { |
| 7768 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7769 | |
| 7770 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 7771 | if msg.err == errUnimplemented { |
| 7772 | if *pipe { |
| 7773 | // Print each test instead of a status line. |
| 7774 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 7775 | } |
| 7776 | unimplemented++ |
| 7777 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 7778 | } else { |
| 7779 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 7780 | failed++ |
| 7781 | testOutput.addResult(msg.test.name, "FAIL") |
| 7782 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7783 | } else { |
| 7784 | if *pipe { |
| 7785 | // Print each test instead of a status line. |
| 7786 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 7787 | } |
| 7788 | testOutput.addResult(msg.test.name, "PASS") |
| 7789 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7790 | } |
| 7791 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7792 | if !*pipe { |
| 7793 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 7794 | line := fmt.Sprintf("%d/%d/%d/%d/%d", failed, unimplemented, done, started, total) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7795 | lineLen = len(line) |
| 7796 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7797 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7798 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7799 | |
| 7800 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7801 | } |
| 7802 | |
| 7803 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7804 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7805 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7806 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7807 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7808 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7809 | addCipherSuiteTests() |
| 7810 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7811 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 7812 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 7813 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 7814 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 7815 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 7816 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 7817 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 7818 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 7819 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7820 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7821 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7822 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7823 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7824 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7825 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7826 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 7827 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7828 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7829 | addCECPQ1Tests() |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7830 | addKeyExchangeInfoTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 7831 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 7832 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7833 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7834 | addWrongMessageTypeTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7835 | addTLS13WrongMessageTypeTests() |
| 7836 | addTLS13HandshakeTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7837 | |
| 7838 | var wg sync.WaitGroup |
| 7839 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7840 | statusChan := make(chan statusMsg, *numWorkers) |
| 7841 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7842 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7843 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7844 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7845 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7846 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7847 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7848 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7849 | } |
| 7850 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7851 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7852 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 7853 | matched := true |
| 7854 | if len(*testToRun) != 0 { |
| 7855 | var err error |
| 7856 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 7857 | if err != nil { |
| 7858 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 7859 | os.Exit(1) |
| 7860 | } |
| 7861 | } |
| 7862 | |
| 7863 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7864 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 7865 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7866 | } |
| 7867 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 7868 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7869 | if !foundTest { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 7870 | fmt.Fprintf(os.Stderr, "No tests matched %q\n", *testToRun) |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 7871 | os.Exit(1) |
| 7872 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7873 | |
| 7874 | close(testChan) |
| 7875 | wg.Wait() |
| 7876 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7877 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7878 | |
| 7879 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 7880 | |
| 7881 | if *jsonOutput != "" { |
| 7882 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 7883 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 7884 | } |
| 7885 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 7886 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 7887 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 7888 | os.Exit(1) |
| 7889 | } |
| 7890 | |
| 7891 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 7892 | os.Exit(1) |
| 7893 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 7894 | } |