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 |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 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" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 23 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 24 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 25 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 26 | "flag" |
| 27 | "fmt" |
| 28 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 29 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 30 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 31 | "net" |
| 32 | "os" |
| 33 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 34 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 35 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 36 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 37 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 38 | "strings" |
| 39 | "sync" |
| 40 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 41 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 42 | ) |
| 43 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 44 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 45 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 46 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 47 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 48 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 49 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 50 | 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.") |
| 51 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 52 | 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] | 53 | 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] | 54 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 55 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 56 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 57 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 58 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 59 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 60 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 61 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 62 | looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 63 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 64 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 65 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 66 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 67 | // ShimConfigurations is used with the “json” package and represents a shim |
| 68 | // config file. |
| 69 | type ShimConfiguration struct { |
| 70 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 71 | // The glob pattern is used to exclude tests from being run and the |
| 72 | // freeform string is unparsed but expected to explain why the test is |
| 73 | // disabled. |
| 74 | DisabledTests map[string]string |
| 75 | |
| 76 | // ErrorMap maps from expected error strings to the correct error |
| 77 | // string for the shim in question. For example, it might map |
| 78 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 79 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 80 | ErrorMap map[string]string |
| 81 | } |
| 82 | |
| 83 | var shimConfig ShimConfiguration |
| 84 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 85 | type testCert int |
| 86 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 87 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 88 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 89 | testCertRSA1024 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 90 | testCertECDSAP256 |
| 91 | testCertECDSAP384 |
| 92 | testCertECDSAP521 |
| 93 | ) |
| 94 | |
| 95 | const ( |
| 96 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 97 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 98 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 99 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 100 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 101 | ) |
| 102 | |
| 103 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 104 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 105 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 106 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 107 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 108 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 109 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 110 | ) |
| 111 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 112 | var ( |
| 113 | rsaCertificate Certificate |
| 114 | rsa1024Certificate Certificate |
| 115 | ecdsaP256Certificate Certificate |
| 116 | ecdsaP384Certificate Certificate |
| 117 | ecdsaP521Certificate Certificate |
| 118 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 119 | |
| 120 | var testCerts = []struct { |
| 121 | id testCert |
| 122 | certFile, keyFile string |
| 123 | cert *Certificate |
| 124 | }{ |
| 125 | { |
| 126 | id: testCertRSA, |
| 127 | certFile: rsaCertificateFile, |
| 128 | keyFile: rsaKeyFile, |
| 129 | cert: &rsaCertificate, |
| 130 | }, |
| 131 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 132 | id: testCertRSA1024, |
| 133 | certFile: rsa1024CertificateFile, |
| 134 | keyFile: rsa1024KeyFile, |
| 135 | cert: &rsa1024Certificate, |
| 136 | }, |
| 137 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 138 | id: testCertECDSAP256, |
| 139 | certFile: ecdsaP256CertificateFile, |
| 140 | keyFile: ecdsaP256KeyFile, |
| 141 | cert: &ecdsaP256Certificate, |
| 142 | }, |
| 143 | { |
| 144 | id: testCertECDSAP384, |
| 145 | certFile: ecdsaP384CertificateFile, |
| 146 | keyFile: ecdsaP384KeyFile, |
| 147 | cert: &ecdsaP384Certificate, |
| 148 | }, |
| 149 | { |
| 150 | id: testCertECDSAP521, |
| 151 | certFile: ecdsaP521CertificateFile, |
| 152 | keyFile: ecdsaP521KeyFile, |
| 153 | cert: &ecdsaP521Certificate, |
| 154 | }, |
| 155 | } |
| 156 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 157 | var channelIDKey *ecdsa.PrivateKey |
| 158 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 159 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 160 | var testOCSPResponse = []byte{1, 2, 3, 4} |
| 161 | var testSCTList = []byte{5, 6, 7, 8} |
| 162 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 163 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 164 | for i := range testCerts { |
| 165 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 166 | if err != nil { |
| 167 | panic(err) |
| 168 | } |
| 169 | cert.OCSPStaple = testOCSPResponse |
| 170 | cert.SignedCertificateTimestampList = testSCTList |
| 171 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 172 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 173 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 174 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 175 | if err != nil { |
| 176 | panic(err) |
| 177 | } |
| 178 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 179 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 180 | panic("bad key type") |
| 181 | } |
| 182 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 183 | if err != nil { |
| 184 | panic(err) |
| 185 | } |
| 186 | if channelIDKey.Curve != elliptic.P256() { |
| 187 | panic("bad curve") |
| 188 | } |
| 189 | |
| 190 | channelIDBytes = make([]byte, 64) |
| 191 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 192 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 193 | } |
| 194 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 195 | func getRunnerCertificate(t testCert) Certificate { |
| 196 | for _, cert := range testCerts { |
| 197 | if cert.id == t { |
| 198 | return *cert.cert |
| 199 | } |
| 200 | } |
| 201 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 202 | } |
| 203 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 204 | func getShimCertificate(t testCert) string { |
| 205 | for _, cert := range testCerts { |
| 206 | if cert.id == t { |
| 207 | return cert.certFile |
| 208 | } |
| 209 | } |
| 210 | panic("Unknown test certificate") |
| 211 | } |
| 212 | |
| 213 | func getShimKey(t testCert) string { |
| 214 | for _, cert := range testCerts { |
| 215 | if cert.id == t { |
| 216 | return cert.keyFile |
| 217 | } |
| 218 | } |
| 219 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 220 | } |
| 221 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 222 | type testType int |
| 223 | |
| 224 | const ( |
| 225 | clientTest testType = iota |
| 226 | serverTest |
| 227 | ) |
| 228 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 229 | type protocol int |
| 230 | |
| 231 | const ( |
| 232 | tls protocol = iota |
| 233 | dtls |
| 234 | ) |
| 235 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 236 | const ( |
| 237 | alpn = 1 |
| 238 | npn = 2 |
| 239 | ) |
| 240 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 241 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 242 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 243 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 244 | name string |
| 245 | config Config |
| 246 | shouldFail bool |
| 247 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 248 | // expectedLocalError, if not empty, contains a substring that must be |
| 249 | // found in the local error. |
| 250 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 251 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 252 | // negotiated. |
| 253 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 254 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 255 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 256 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 257 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 258 | // should be negotiated. |
| 259 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 260 | // expectChannelID controls whether the connection should have |
| 261 | // negotiated a Channel ID with channelIDKey. |
| 262 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 263 | // expectedNextProto controls whether the connection should |
| 264 | // negotiate a next protocol via NPN or ALPN. |
| 265 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 266 | // expectNoNextProto, if true, means that no next protocol should be |
| 267 | // negotiated. |
| 268 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 269 | // expectedNextProtoType, if non-zero, is the expected next |
| 270 | // protocol negotiation mechanism. |
| 271 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 272 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 273 | // should be negotiated. If zero, none should be negotiated. |
| 274 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 275 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 276 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 277 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 278 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 279 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 280 | // algorithm that the peer should have used in the handshake. |
| 281 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 282 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 283 | // have used. |
| 284 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 285 | // messageLen is the length, in bytes, of the test message that will be |
| 286 | // sent. |
| 287 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 288 | // messageCount is the number of test messages that will be sent. |
| 289 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 290 | // certFile is the path to the certificate to use for the server. |
| 291 | certFile string |
| 292 | // keyFile is the path to the private key to use for the server. |
| 293 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 294 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 295 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 296 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 297 | // resumeRenewedSession controls whether a third connection should be |
| 298 | // tested which attempts to resume the second connection's session. |
| 299 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 300 | // expectResumeRejected, if true, specifies that the attempted |
| 301 | // resumption must be rejected by the client. This is only valid for a |
| 302 | // serverTest. |
| 303 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 304 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 305 | // resumption. Unless newSessionsOnResume is set, |
| 306 | // SessionTicketKey, ServerSessionCache, and |
| 307 | // ClientSessionCache are copied from the initial connection's |
| 308 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 309 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 310 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 311 | // use a different session resumption context. |
| 312 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 313 | // noSessionCache, if true, will cause the server to run without a |
| 314 | // session cache. |
| 315 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 316 | // sendPrefix sends a prefix on the socket before actually performing a |
| 317 | // handshake. |
| 318 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 319 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 320 | // message before doing a roundtrip with the runner. |
| 321 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 322 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 323 | // connection immediately after the handshake rather than echoing |
| 324 | // messages from the runner. |
| 325 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 326 | // renegotiate indicates the number of times the connection should be |
| 327 | // renegotiated during the exchange. |
| 328 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 329 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 330 | // HelloRequest when the handshake completes. |
| 331 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 332 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 333 | // switched in just before renegotiation. |
| 334 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 335 | // replayWrites, if true, configures the underlying transport |
| 336 | // to replay every write it makes in DTLS tests. |
| 337 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 338 | // damageFirstWrite, if true, configures the underlying transport to |
| 339 | // damage the final byte of the first application data write. |
| 340 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 341 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 342 | // keying material and verify they match. |
| 343 | exportKeyingMaterial int |
| 344 | exportLabel string |
| 345 | exportContext string |
| 346 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 347 | // flags, if not empty, contains a list of command-line flags that will |
| 348 | // be passed to the shim program. |
| 349 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 350 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 351 | // which will be compared against the expected value. |
| 352 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 353 | // sendEmptyRecords is the number of consecutive empty records to send |
| 354 | // before and after the test message. |
| 355 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 356 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 357 | // before and after the test message. |
| 358 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 359 | // sendKeyUpdates is the number of consecutive key updates to send |
| 360 | // before and after the test message. |
| 361 | sendKeyUpdates int |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 362 | // expectMessageDropped, if true, means the test message is expected to |
| 363 | // be dropped by the client rather than echoed back. |
| 364 | expectMessageDropped bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 367 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 368 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 369 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 370 | if len(data) == 0 { |
| 371 | return |
| 372 | } |
| 373 | |
| 374 | protocol := "tls" |
| 375 | if test.protocol == dtls { |
| 376 | protocol = "dtls" |
| 377 | } |
| 378 | |
| 379 | side := "client" |
| 380 | if test.testType == serverTest { |
| 381 | side = "server" |
| 382 | } |
| 383 | |
| 384 | dir := path.Join(*transcriptDir, protocol, side) |
| 385 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 386 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 387 | return |
| 388 | } |
| 389 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 390 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 391 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 392 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 393 | } |
| 394 | } |
| 395 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 396 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 397 | type timeoutConn struct { |
| 398 | net.Conn |
| 399 | timeout time.Duration |
| 400 | } |
| 401 | |
| 402 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 403 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 404 | return 0, err |
| 405 | } |
| 406 | return t.Conn.Read(b) |
| 407 | } |
| 408 | |
| 409 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 410 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 411 | return 0, err |
| 412 | } |
| 413 | return t.Conn.Write(b) |
| 414 | } |
| 415 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 416 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 417 | if !test.noSessionCache { |
| 418 | if config.ClientSessionCache == nil { |
| 419 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 420 | } |
| 421 | if config.ServerSessionCache == nil { |
| 422 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 423 | } |
| 424 | } |
| 425 | if test.testType == clientTest { |
| 426 | if len(config.Certificates) == 0 { |
| 427 | config.Certificates = []Certificate{rsaCertificate} |
| 428 | } |
| 429 | } else { |
| 430 | // Supply a ServerName to ensure a constant session cache key, |
| 431 | // rather than falling back to net.Conn.RemoteAddr. |
| 432 | if len(config.ServerName) == 0 { |
| 433 | config.ServerName = "test" |
| 434 | } |
| 435 | } |
| 436 | if *fuzzer { |
| 437 | config.Bugs.NullAllCiphers = true |
| 438 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 439 | if *deterministic { |
| 440 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 441 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 442 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 443 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 444 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 445 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 446 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 447 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 448 | } |
| 449 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 450 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 451 | local, peer := "client", "server" |
| 452 | if test.testType == clientTest { |
| 453 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 454 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 455 | connDebug := &recordingConn{ |
| 456 | Conn: conn, |
| 457 | isDatagram: test.protocol == dtls, |
| 458 | local: local, |
| 459 | peer: peer, |
| 460 | } |
| 461 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 462 | if *flagDebug { |
| 463 | defer connDebug.WriteTo(os.Stdout) |
| 464 | } |
| 465 | if len(*transcriptDir) != 0 { |
| 466 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 467 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 468 | }() |
| 469 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 470 | |
| 471 | if config.Bugs.PacketAdaptor != nil { |
| 472 | config.Bugs.PacketAdaptor.debug = connDebug |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | if test.replayWrites { |
| 477 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 478 | } |
| 479 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 480 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 481 | if test.damageFirstWrite { |
| 482 | connDamage = newDamageAdaptor(conn) |
| 483 | conn = connDamage |
| 484 | } |
| 485 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 486 | if test.sendPrefix != "" { |
| 487 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 488 | return err |
| 489 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 490 | } |
| 491 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 492 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 493 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 494 | if test.protocol == dtls { |
| 495 | tlsConn = DTLSServer(conn, config) |
| 496 | } else { |
| 497 | tlsConn = Server(conn, config) |
| 498 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 499 | } else { |
| 500 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 501 | if test.protocol == dtls { |
| 502 | tlsConn = DTLSClient(conn, config) |
| 503 | } else { |
| 504 | tlsConn = Client(conn, config) |
| 505 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 506 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 507 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 508 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 509 | if err := tlsConn.Handshake(); err != nil { |
| 510 | return err |
| 511 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 512 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 513 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 514 | // expectations struct that can be specified separately for the two |
| 515 | // legs. |
| 516 | expectedVersion := test.expectedVersion |
| 517 | if isResume && test.expectedResumeVersion != 0 { |
| 518 | expectedVersion = test.expectedResumeVersion |
| 519 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 520 | connState := tlsConn.ConnectionState() |
| 521 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 522 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 523 | } |
| 524 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 525 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 526 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 527 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 528 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 529 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 530 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 531 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 532 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 533 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 534 | if channelID == nil { |
| 535 | return fmt.Errorf("no channel ID negotiated") |
| 536 | } |
| 537 | if channelID.Curve != channelIDKey.Curve || |
| 538 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 539 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 540 | return fmt.Errorf("incorrect channel ID") |
| 541 | } |
| 542 | } |
| 543 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 544 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 545 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 546 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 547 | } |
| 548 | } |
| 549 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 550 | if test.expectNoNextProto { |
| 551 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 552 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 553 | } |
| 554 | } |
| 555 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 556 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 557 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 558 | return fmt.Errorf("next proto type mismatch") |
| 559 | } |
| 560 | } |
| 561 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 562 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 563 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 564 | } |
| 565 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 566 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 567 | 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] | 568 | } |
| 569 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 570 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 571 | return fmt.Errorf("SCT list mismatch") |
| 572 | } |
| 573 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 574 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 575 | 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] | 576 | } |
| 577 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 578 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 579 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 580 | } |
| 581 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 582 | if test.exportKeyingMaterial > 0 { |
| 583 | actual := make([]byte, test.exportKeyingMaterial) |
| 584 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 585 | return err |
| 586 | } |
| 587 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 588 | if err != nil { |
| 589 | return err |
| 590 | } |
| 591 | if !bytes.Equal(actual, expected) { |
| 592 | return fmt.Errorf("keying material mismatch") |
| 593 | } |
| 594 | } |
| 595 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 596 | if test.testTLSUnique { |
| 597 | var peersValue [12]byte |
| 598 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 599 | return err |
| 600 | } |
| 601 | expected := tlsConn.ConnectionState().TLSUnique |
| 602 | if !bytes.Equal(peersValue[:], expected) { |
| 603 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 604 | } |
| 605 | } |
| 606 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 607 | if test.shimWritesFirst { |
| 608 | var buf [5]byte |
| 609 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 610 | if err != nil { |
| 611 | return err |
| 612 | } |
| 613 | if string(buf[:]) != "hello" { |
| 614 | return fmt.Errorf("bad initial message") |
| 615 | } |
| 616 | } |
| 617 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 618 | for i := 0; i < test.sendKeyUpdates; i++ { |
| 619 | tlsConn.SendKeyUpdate() |
| 620 | } |
| 621 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 622 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 623 | tlsConn.Write(nil) |
| 624 | } |
| 625 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 626 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 627 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 628 | } |
| 629 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 630 | if test.sendHalfHelloRequest { |
| 631 | tlsConn.SendHalfHelloRequest() |
| 632 | } |
| 633 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 634 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 635 | if test.renegotiateCiphers != nil { |
| 636 | config.CipherSuites = test.renegotiateCiphers |
| 637 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 638 | for i := 0; i < test.renegotiate; i++ { |
| 639 | if err := tlsConn.Renegotiate(); err != nil { |
| 640 | return err |
| 641 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 642 | } |
| 643 | } else if test.renegotiateCiphers != nil { |
| 644 | panic("renegotiateCiphers without renegotiate") |
| 645 | } |
| 646 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 647 | if test.damageFirstWrite { |
| 648 | connDamage.setDamage(true) |
| 649 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 650 | connDamage.setDamage(false) |
| 651 | } |
| 652 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 653 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 654 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 655 | if test.protocol == dtls { |
| 656 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 657 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 658 | // Read until EOF. |
| 659 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 660 | return err |
| 661 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 662 | if messageLen == 0 { |
| 663 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 664 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 665 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 666 | messageCount := test.messageCount |
| 667 | if messageCount == 0 { |
| 668 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 669 | } |
| 670 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 671 | for j := 0; j < messageCount; j++ { |
| 672 | testMessage := make([]byte, messageLen) |
| 673 | for i := range testMessage { |
| 674 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 675 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 676 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 677 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 678 | for i := 0; i < test.sendKeyUpdates; i++ { |
| 679 | tlsConn.SendKeyUpdate() |
| 680 | } |
| 681 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 682 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 683 | tlsConn.Write(nil) |
| 684 | } |
| 685 | |
| 686 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 687 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 688 | } |
| 689 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 690 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 691 | // The shim will not respond. |
| 692 | continue |
| 693 | } |
| 694 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 695 | buf := make([]byte, len(testMessage)) |
| 696 | if test.protocol == dtls { |
| 697 | bufTmp := make([]byte, len(buf)+1) |
| 698 | n, err := tlsConn.Read(bufTmp) |
| 699 | if err != nil { |
| 700 | return err |
| 701 | } |
| 702 | if n != len(buf) { |
| 703 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 704 | } |
| 705 | copy(buf, bufTmp) |
| 706 | } else { |
| 707 | _, err := io.ReadFull(tlsConn, buf) |
| 708 | if err != nil { |
| 709 | return err |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | for i, v := range buf { |
| 714 | if v != testMessage[i]^0xff { |
| 715 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 716 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 717 | } |
| 718 | } |
| 719 | |
| 720 | return nil |
| 721 | } |
| 722 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 723 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 724 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 725 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 726 | 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] | 727 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 728 | valgrindArgs = append(valgrindArgs, path) |
| 729 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 730 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 731 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 732 | } |
| 733 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 734 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 735 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 736 | xtermArgs = append(xtermArgs, path) |
| 737 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 738 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 739 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 740 | } |
| 741 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 742 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 743 | xtermArgs := []string{"-e", "lldb", "--"} |
| 744 | xtermArgs = append(xtermArgs, path) |
| 745 | xtermArgs = append(xtermArgs, args...) |
| 746 | |
| 747 | return exec.Command("xterm", xtermArgs...) |
| 748 | } |
| 749 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 750 | var ( |
| 751 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 752 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 753 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 754 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 755 | // accept accepts a connection from listener, unless waitChan signals a process |
| 756 | // exit first. |
| 757 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 758 | type connOrError struct { |
| 759 | conn net.Conn |
| 760 | err error |
| 761 | } |
| 762 | connChan := make(chan connOrError, 1) |
| 763 | go func() { |
| 764 | conn, err := listener.Accept() |
| 765 | connChan <- connOrError{conn, err} |
| 766 | close(connChan) |
| 767 | }() |
| 768 | select { |
| 769 | case result := <-connChan: |
| 770 | return result.conn, result.err |
| 771 | case childErr := <-waitChan: |
| 772 | waitChan <- childErr |
| 773 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 774 | } |
| 775 | } |
| 776 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 777 | func translateExpectedError(errorStr string) string { |
| 778 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 779 | return translated |
| 780 | } |
| 781 | |
| 782 | if *looseErrors { |
| 783 | return "" |
| 784 | } |
| 785 | |
| 786 | return errorStr |
| 787 | } |
| 788 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 789 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 790 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 791 | panic("Error expected without shouldFail in " + test.name) |
| 792 | } |
| 793 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 794 | if test.expectResumeRejected && !test.resumeSession { |
| 795 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 796 | } |
| 797 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 798 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 799 | if err != nil { |
| 800 | panic(err) |
| 801 | } |
| 802 | defer func() { |
| 803 | if listener != nil { |
| 804 | listener.Close() |
| 805 | } |
| 806 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 807 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 808 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 809 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 810 | flags = append(flags, "-server") |
| 811 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 812 | flags = append(flags, "-key-file") |
| 813 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 814 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 815 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 816 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | flags = append(flags, "-cert-file") |
| 820 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 821 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 822 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 823 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 824 | } |
| 825 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 826 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 827 | if test.protocol == dtls { |
| 828 | flags = append(flags, "-dtls") |
| 829 | } |
| 830 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 831 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 832 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 833 | resumeCount++ |
| 834 | if test.resumeRenewedSession { |
| 835 | resumeCount++ |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | if resumeCount > 0 { |
| 840 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 841 | } |
| 842 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 843 | if test.shimWritesFirst { |
| 844 | flags = append(flags, "-shim-writes-first") |
| 845 | } |
| 846 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 847 | if test.shimShutsDown { |
| 848 | flags = append(flags, "-shim-shuts-down") |
| 849 | } |
| 850 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 851 | if test.exportKeyingMaterial > 0 { |
| 852 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 853 | flags = append(flags, "-export-label", test.exportLabel) |
| 854 | flags = append(flags, "-export-context", test.exportContext) |
| 855 | if test.useExportContext { |
| 856 | flags = append(flags, "-use-export-context") |
| 857 | } |
| 858 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 859 | if test.expectResumeRejected { |
| 860 | flags = append(flags, "-expect-session-miss") |
| 861 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 862 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 863 | if test.testTLSUnique { |
| 864 | flags = append(flags, "-tls-unique") |
| 865 | } |
| 866 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 867 | flags = append(flags, test.flags...) |
| 868 | |
| 869 | var shim *exec.Cmd |
| 870 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 871 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 872 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 873 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 874 | } else if *useLLDB { |
| 875 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 876 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 877 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 878 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 879 | shim.Stdin = os.Stdin |
| 880 | var stdoutBuf, stderrBuf bytes.Buffer |
| 881 | shim.Stdout = &stdoutBuf |
| 882 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 883 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 884 | shim.Env = os.Environ() |
| 885 | 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] | 886 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 887 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 888 | } |
| 889 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 890 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 891 | |
| 892 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 893 | panic(err) |
| 894 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 895 | waitChan := make(chan error, 1) |
| 896 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 897 | |
| 898 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 899 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 900 | if *deterministic { |
| 901 | config.Rand = &deterministicRand{} |
| 902 | } |
| 903 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 904 | conn, err := acceptOrWait(listener, waitChan) |
| 905 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 906 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 907 | conn.Close() |
| 908 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 909 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 910 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 911 | var resumeConfig Config |
| 912 | if test.resumeConfig != nil { |
| 913 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 914 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 915 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 916 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 917 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 918 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 919 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 920 | } else { |
| 921 | resumeConfig = config |
| 922 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 923 | var connResume net.Conn |
| 924 | connResume, err = acceptOrWait(listener, waitChan) |
| 925 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame^] | 926 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 927 | connResume.Close() |
| 928 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 929 | } |
| 930 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 931 | // Close the listener now. This is to avoid hangs should the shim try to |
| 932 | // open more connections than expected. |
| 933 | listener.Close() |
| 934 | listener = nil |
| 935 | |
| 936 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 937 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 938 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 939 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 940 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 941 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 942 | case 89: |
| 943 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 944 | case 99: |
| 945 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 946 | } |
| 947 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 948 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 949 | // Account for Windows line endings. |
| 950 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 951 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 952 | |
| 953 | // Separate the errors from the shim and those from tools like |
| 954 | // AddressSanitizer. |
| 955 | var extraStderr string |
| 956 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 957 | stderr = stderrParts[0] |
| 958 | extraStderr = stderrParts[1] |
| 959 | } |
| 960 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 961 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 962 | expectedError := translateExpectedError(test.expectedError) |
| 963 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 964 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 965 | localError := "none" |
| 966 | if err != nil { |
| 967 | localError = err.Error() |
| 968 | } |
| 969 | if len(test.expectedLocalError) != 0 { |
| 970 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 971 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 972 | |
| 973 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 974 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 975 | if childErr != nil { |
| 976 | childError = childErr.Error() |
| 977 | } |
| 978 | |
| 979 | var msg string |
| 980 | switch { |
| 981 | case failed && !test.shouldFail: |
| 982 | msg = "unexpected failure" |
| 983 | case !failed && test.shouldFail: |
| 984 | msg = "unexpected success" |
| 985 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 986 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 987 | default: |
| 988 | panic("internal error") |
| 989 | } |
| 990 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 991 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s\n%s", msg, localError, childError, stdout, stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 992 | } |
| 993 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 994 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 995 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 996 | } |
| 997 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 998 | if *useValgrind && isValgrindError { |
| 999 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1000 | } |
| 1001 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1002 | return nil |
| 1003 | } |
| 1004 | |
| 1005 | var tlsVersions = []struct { |
| 1006 | name string |
| 1007 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1008 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1009 | hasDTLS bool |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1010 | }{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1011 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1012 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1013 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1014 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1015 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | var testCipherSuites = []struct { |
| 1019 | name string |
| 1020 | id uint16 |
| 1021 | }{ |
| 1022 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1023 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1024 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1025 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1026 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1027 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1028 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1029 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1030 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1031 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1032 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 1033 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1034 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1035 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1036 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1037 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1038 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1039 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1040 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1041 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1042 | {"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] | 1043 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1044 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1045 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1046 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1047 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1048 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1049 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | e320392 | 2015-12-09 21:21:31 -0500 | [diff] [blame] | 1050 | {"ECDHE-RSA-CHACHA20-POLY1305-OLD", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD}, |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 1051 | {"CECPQ1-RSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1052 | {"CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256", TLS_CECPQ1_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 1053 | {"CECPQ1-RSA-AES256-GCM-SHA384", TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 1054 | {"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] | 1055 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1056 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1057 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1058 | {"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] | 1059 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 3084e7b | 2016-06-02 12:07:20 -0400 | [diff] [blame] | 1060 | {"ECDHE-PSK-AES128-GCM-SHA256", TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256}, |
| 1061 | {"ECDHE-PSK-AES256-GCM-SHA384", TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1062 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1065 | func hasComponent(suiteName, component string) bool { |
| 1066 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1067 | } |
| 1068 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1069 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1070 | return hasComponent(suiteName, "GCM") || |
| 1071 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1072 | hasComponent(suiteName, "SHA384") || |
| 1073 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1074 | } |
| 1075 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1076 | func isTLS13Suite(suiteName string) bool { |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 1077 | // Only AEADs. |
| 1078 | if !hasComponent(suiteName, "GCM") && !hasComponent(suiteName, "POLY1305") { |
| 1079 | return false |
| 1080 | } |
| 1081 | // No old CHACHA20_POLY1305. |
| 1082 | if hasComponent(suiteName, "CHACHA20-POLY1305-OLD") { |
| 1083 | return false |
| 1084 | } |
| 1085 | // Must have ECDHE. |
| 1086 | // TODO(davidben,svaldez): Add pure PSK support. |
| 1087 | if !hasComponent(suiteName, "ECDHE") { |
| 1088 | return false |
| 1089 | } |
| 1090 | // TODO(davidben,svaldez): Add PSK support. |
| 1091 | if hasComponent(suiteName, "PSK") { |
| 1092 | return false |
| 1093 | } |
| 1094 | return true |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1095 | } |
| 1096 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1097 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1098 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1099 | } |
| 1100 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1101 | func bigFromHex(hex string) *big.Int { |
| 1102 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1103 | if !ok { |
| 1104 | panic("failed to parse hex number 0x" + hex) |
| 1105 | } |
| 1106 | return ret |
| 1107 | } |
| 1108 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1109 | func addBasicTests() { |
| 1110 | basicTests := []testCase{ |
| 1111 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1112 | name: "NoFallbackSCSV", |
| 1113 | config: Config{ |
| 1114 | Bugs: ProtocolBugs{ |
| 1115 | FailIfNotFallbackSCSV: true, |
| 1116 | }, |
| 1117 | }, |
| 1118 | shouldFail: true, |
| 1119 | expectedLocalError: "no fallback SCSV found", |
| 1120 | }, |
| 1121 | { |
| 1122 | name: "SendFallbackSCSV", |
| 1123 | config: Config{ |
| 1124 | Bugs: ProtocolBugs{ |
| 1125 | FailIfNotFallbackSCSV: true, |
| 1126 | }, |
| 1127 | }, |
| 1128 | flags: []string{"-fallback-scsv"}, |
| 1129 | }, |
| 1130 | { |
| 1131 | name: "ClientCertificateTypes", |
| 1132 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1133 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1134 | ClientAuth: RequestClientCert, |
| 1135 | ClientCertificateTypes: []byte{ |
| 1136 | CertTypeDSSSign, |
| 1137 | CertTypeRSASign, |
| 1138 | CertTypeECDSASign, |
| 1139 | }, |
| 1140 | }, |
| 1141 | flags: []string{ |
| 1142 | "-expect-certificate-types", |
| 1143 | base64.StdEncoding.EncodeToString([]byte{ |
| 1144 | CertTypeDSSSign, |
| 1145 | CertTypeRSASign, |
| 1146 | CertTypeECDSASign, |
| 1147 | }), |
| 1148 | }, |
| 1149 | }, |
| 1150 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1151 | name: "UnauthenticatedECDH", |
| 1152 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1153 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1154 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1155 | Bugs: ProtocolBugs{ |
| 1156 | UnauthenticatedECDH: true, |
| 1157 | }, |
| 1158 | }, |
| 1159 | shouldFail: true, |
| 1160 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1161 | }, |
| 1162 | { |
| 1163 | name: "SkipCertificateStatus", |
| 1164 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1165 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1166 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1167 | Bugs: ProtocolBugs{ |
| 1168 | SkipCertificateStatus: true, |
| 1169 | }, |
| 1170 | }, |
| 1171 | flags: []string{ |
| 1172 | "-enable-ocsp-stapling", |
| 1173 | }, |
| 1174 | }, |
| 1175 | { |
| 1176 | name: "SkipServerKeyExchange", |
| 1177 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1178 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1179 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1180 | Bugs: ProtocolBugs{ |
| 1181 | SkipServerKeyExchange: true, |
| 1182 | }, |
| 1183 | }, |
| 1184 | shouldFail: true, |
| 1185 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1186 | }, |
| 1187 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1188 | testType: serverTest, |
| 1189 | name: "Alert", |
| 1190 | config: Config{ |
| 1191 | Bugs: ProtocolBugs{ |
| 1192 | SendSpuriousAlert: alertRecordOverflow, |
| 1193 | }, |
| 1194 | }, |
| 1195 | shouldFail: true, |
| 1196 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1197 | }, |
| 1198 | { |
| 1199 | protocol: dtls, |
| 1200 | testType: serverTest, |
| 1201 | name: "Alert-DTLS", |
| 1202 | config: Config{ |
| 1203 | Bugs: ProtocolBugs{ |
| 1204 | SendSpuriousAlert: alertRecordOverflow, |
| 1205 | }, |
| 1206 | }, |
| 1207 | shouldFail: true, |
| 1208 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1209 | }, |
| 1210 | { |
| 1211 | testType: serverTest, |
| 1212 | name: "FragmentAlert", |
| 1213 | config: Config{ |
| 1214 | Bugs: ProtocolBugs{ |
| 1215 | FragmentAlert: true, |
| 1216 | SendSpuriousAlert: alertRecordOverflow, |
| 1217 | }, |
| 1218 | }, |
| 1219 | shouldFail: true, |
| 1220 | expectedError: ":BAD_ALERT:", |
| 1221 | }, |
| 1222 | { |
| 1223 | protocol: dtls, |
| 1224 | testType: serverTest, |
| 1225 | name: "FragmentAlert-DTLS", |
| 1226 | config: Config{ |
| 1227 | Bugs: ProtocolBugs{ |
| 1228 | FragmentAlert: true, |
| 1229 | SendSpuriousAlert: alertRecordOverflow, |
| 1230 | }, |
| 1231 | }, |
| 1232 | shouldFail: true, |
| 1233 | expectedError: ":BAD_ALERT:", |
| 1234 | }, |
| 1235 | { |
| 1236 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1237 | name: "DoubleAlert", |
| 1238 | config: Config{ |
| 1239 | Bugs: ProtocolBugs{ |
| 1240 | DoubleAlert: true, |
| 1241 | SendSpuriousAlert: alertRecordOverflow, |
| 1242 | }, |
| 1243 | }, |
| 1244 | shouldFail: true, |
| 1245 | expectedError: ":BAD_ALERT:", |
| 1246 | }, |
| 1247 | { |
| 1248 | protocol: dtls, |
| 1249 | testType: serverTest, |
| 1250 | name: "DoubleAlert-DTLS", |
| 1251 | config: Config{ |
| 1252 | Bugs: ProtocolBugs{ |
| 1253 | DoubleAlert: true, |
| 1254 | SendSpuriousAlert: alertRecordOverflow, |
| 1255 | }, |
| 1256 | }, |
| 1257 | shouldFail: true, |
| 1258 | expectedError: ":BAD_ALERT:", |
| 1259 | }, |
| 1260 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1261 | name: "SkipNewSessionTicket", |
| 1262 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1263 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1264 | Bugs: ProtocolBugs{ |
| 1265 | SkipNewSessionTicket: true, |
| 1266 | }, |
| 1267 | }, |
| 1268 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1269 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1270 | }, |
| 1271 | { |
| 1272 | testType: serverTest, |
| 1273 | name: "FallbackSCSV", |
| 1274 | config: Config{ |
| 1275 | MaxVersion: VersionTLS11, |
| 1276 | Bugs: ProtocolBugs{ |
| 1277 | SendFallbackSCSV: true, |
| 1278 | }, |
| 1279 | }, |
| 1280 | shouldFail: true, |
| 1281 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1282 | }, |
| 1283 | { |
| 1284 | testType: serverTest, |
| 1285 | name: "FallbackSCSV-VersionMatch", |
| 1286 | config: Config{ |
| 1287 | Bugs: ProtocolBugs{ |
| 1288 | SendFallbackSCSV: true, |
| 1289 | }, |
| 1290 | }, |
| 1291 | }, |
| 1292 | { |
| 1293 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1294 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1295 | config: Config{ |
| 1296 | MaxVersion: VersionTLS12, |
| 1297 | Bugs: ProtocolBugs{ |
| 1298 | SendFallbackSCSV: true, |
| 1299 | }, |
| 1300 | }, |
| 1301 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1302 | }, |
| 1303 | { |
| 1304 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1305 | name: "FragmentedClientVersion", |
| 1306 | config: Config{ |
| 1307 | Bugs: ProtocolBugs{ |
| 1308 | MaxHandshakeRecordLength: 1, |
| 1309 | FragmentClientVersion: true, |
| 1310 | }, |
| 1311 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1312 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1313 | }, |
| 1314 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1315 | testType: serverTest, |
| 1316 | name: "HttpGET", |
| 1317 | sendPrefix: "GET / HTTP/1.0\n", |
| 1318 | shouldFail: true, |
| 1319 | expectedError: ":HTTP_REQUEST:", |
| 1320 | }, |
| 1321 | { |
| 1322 | testType: serverTest, |
| 1323 | name: "HttpPOST", |
| 1324 | sendPrefix: "POST / HTTP/1.0\n", |
| 1325 | shouldFail: true, |
| 1326 | expectedError: ":HTTP_REQUEST:", |
| 1327 | }, |
| 1328 | { |
| 1329 | testType: serverTest, |
| 1330 | name: "HttpHEAD", |
| 1331 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1332 | shouldFail: true, |
| 1333 | expectedError: ":HTTP_REQUEST:", |
| 1334 | }, |
| 1335 | { |
| 1336 | testType: serverTest, |
| 1337 | name: "HttpPUT", |
| 1338 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1339 | shouldFail: true, |
| 1340 | expectedError: ":HTTP_REQUEST:", |
| 1341 | }, |
| 1342 | { |
| 1343 | testType: serverTest, |
| 1344 | name: "HttpCONNECT", |
| 1345 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1346 | shouldFail: true, |
| 1347 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1348 | }, |
| 1349 | { |
| 1350 | testType: serverTest, |
| 1351 | name: "Garbage", |
| 1352 | sendPrefix: "blah", |
| 1353 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1354 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1355 | }, |
| 1356 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1357 | name: "RSAEphemeralKey", |
| 1358 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1359 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1360 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1361 | Bugs: ProtocolBugs{ |
| 1362 | RSAEphemeralKey: true, |
| 1363 | }, |
| 1364 | }, |
| 1365 | shouldFail: true, |
| 1366 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1367 | }, |
| 1368 | { |
| 1369 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1370 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1371 | shouldFail: true, |
| 1372 | expectedError: ":WRONG_SSL_VERSION:", |
| 1373 | }, |
| 1374 | { |
| 1375 | protocol: dtls, |
| 1376 | name: "DisableEverything-DTLS", |
| 1377 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1378 | shouldFail: true, |
| 1379 | expectedError: ":WRONG_SSL_VERSION:", |
| 1380 | }, |
| 1381 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1382 | protocol: dtls, |
| 1383 | testType: serverTest, |
| 1384 | name: "MTU", |
| 1385 | config: Config{ |
| 1386 | Bugs: ProtocolBugs{ |
| 1387 | MaxPacketLength: 256, |
| 1388 | }, |
| 1389 | }, |
| 1390 | flags: []string{"-mtu", "256"}, |
| 1391 | }, |
| 1392 | { |
| 1393 | protocol: dtls, |
| 1394 | testType: serverTest, |
| 1395 | name: "MTUExceeded", |
| 1396 | config: Config{ |
| 1397 | Bugs: ProtocolBugs{ |
| 1398 | MaxPacketLength: 255, |
| 1399 | }, |
| 1400 | }, |
| 1401 | flags: []string{"-mtu", "256"}, |
| 1402 | shouldFail: true, |
| 1403 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1404 | }, |
| 1405 | { |
| 1406 | name: "CertMismatchRSA", |
| 1407 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1408 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1409 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1410 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1411 | Bugs: ProtocolBugs{ |
| 1412 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1413 | }, |
| 1414 | }, |
| 1415 | shouldFail: true, |
| 1416 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1417 | }, |
| 1418 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1419 | name: "CertMismatchRSA-TLS13", |
| 1420 | config: Config{ |
| 1421 | MaxVersion: VersionTLS13, |
| 1422 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1423 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 1424 | Bugs: ProtocolBugs{ |
| 1425 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1426 | }, |
| 1427 | }, |
| 1428 | shouldFail: true, |
| 1429 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1430 | }, |
| 1431 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1432 | name: "CertMismatchECDSA", |
| 1433 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1434 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1435 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1436 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1437 | Bugs: ProtocolBugs{ |
| 1438 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1439 | }, |
| 1440 | }, |
| 1441 | shouldFail: true, |
| 1442 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1443 | }, |
| 1444 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1445 | name: "CertMismatchECDSA-TLS13", |
| 1446 | config: Config{ |
| 1447 | MaxVersion: VersionTLS13, |
| 1448 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1449 | Certificates: []Certificate{rsaCertificate}, |
| 1450 | Bugs: ProtocolBugs{ |
| 1451 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1452 | }, |
| 1453 | }, |
| 1454 | shouldFail: true, |
| 1455 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1456 | }, |
| 1457 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1458 | name: "EmptyCertificateList", |
| 1459 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1460 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1461 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1462 | Bugs: ProtocolBugs{ |
| 1463 | EmptyCertificateList: true, |
| 1464 | }, |
| 1465 | }, |
| 1466 | shouldFail: true, |
| 1467 | expectedError: ":DECODE_ERROR:", |
| 1468 | }, |
| 1469 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1470 | name: "EmptyCertificateList-TLS13", |
| 1471 | config: Config{ |
| 1472 | MaxVersion: VersionTLS13, |
| 1473 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1474 | Bugs: ProtocolBugs{ |
| 1475 | EmptyCertificateList: true, |
| 1476 | }, |
| 1477 | }, |
| 1478 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1479 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1480 | }, |
| 1481 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1482 | name: "TLSFatalBadPackets", |
| 1483 | damageFirstWrite: true, |
| 1484 | shouldFail: true, |
| 1485 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1486 | }, |
| 1487 | { |
| 1488 | protocol: dtls, |
| 1489 | name: "DTLSIgnoreBadPackets", |
| 1490 | damageFirstWrite: true, |
| 1491 | }, |
| 1492 | { |
| 1493 | protocol: dtls, |
| 1494 | name: "DTLSIgnoreBadPackets-Async", |
| 1495 | damageFirstWrite: true, |
| 1496 | flags: []string{"-async"}, |
| 1497 | }, |
| 1498 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1499 | name: "AppDataBeforeHandshake", |
| 1500 | config: Config{ |
| 1501 | Bugs: ProtocolBugs{ |
| 1502 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1503 | }, |
| 1504 | }, |
| 1505 | shouldFail: true, |
| 1506 | expectedError: ":UNEXPECTED_RECORD:", |
| 1507 | }, |
| 1508 | { |
| 1509 | name: "AppDataBeforeHandshake-Empty", |
| 1510 | config: Config{ |
| 1511 | Bugs: ProtocolBugs{ |
| 1512 | AppDataBeforeHandshake: []byte{}, |
| 1513 | }, |
| 1514 | }, |
| 1515 | shouldFail: true, |
| 1516 | expectedError: ":UNEXPECTED_RECORD:", |
| 1517 | }, |
| 1518 | { |
| 1519 | protocol: dtls, |
| 1520 | name: "AppDataBeforeHandshake-DTLS", |
| 1521 | config: Config{ |
| 1522 | Bugs: ProtocolBugs{ |
| 1523 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1524 | }, |
| 1525 | }, |
| 1526 | shouldFail: true, |
| 1527 | expectedError: ":UNEXPECTED_RECORD:", |
| 1528 | }, |
| 1529 | { |
| 1530 | protocol: dtls, |
| 1531 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1532 | config: Config{ |
| 1533 | Bugs: ProtocolBugs{ |
| 1534 | AppDataBeforeHandshake: []byte{}, |
| 1535 | }, |
| 1536 | }, |
| 1537 | shouldFail: true, |
| 1538 | expectedError: ":UNEXPECTED_RECORD:", |
| 1539 | }, |
| 1540 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1541 | name: "AppDataAfterChangeCipherSpec", |
| 1542 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1543 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1544 | Bugs: ProtocolBugs{ |
| 1545 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1546 | }, |
| 1547 | }, |
| 1548 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1549 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1550 | }, |
| 1551 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1552 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1553 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1554 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1555 | Bugs: ProtocolBugs{ |
| 1556 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1557 | }, |
| 1558 | }, |
| 1559 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1560 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1561 | }, |
| 1562 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1563 | protocol: dtls, |
| 1564 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1565 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1566 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1567 | Bugs: ProtocolBugs{ |
| 1568 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1569 | }, |
| 1570 | }, |
| 1571 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1572 | // application data. |
| 1573 | }, |
| 1574 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1575 | protocol: dtls, |
| 1576 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1577 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1578 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1579 | Bugs: ProtocolBugs{ |
| 1580 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1581 | }, |
| 1582 | }, |
| 1583 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1584 | // application data. |
| 1585 | }, |
| 1586 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1587 | name: "AlertAfterChangeCipherSpec", |
| 1588 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1589 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1590 | Bugs: ProtocolBugs{ |
| 1591 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1592 | }, |
| 1593 | }, |
| 1594 | shouldFail: true, |
| 1595 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1596 | }, |
| 1597 | { |
| 1598 | protocol: dtls, |
| 1599 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1600 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1601 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1602 | Bugs: ProtocolBugs{ |
| 1603 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1604 | }, |
| 1605 | }, |
| 1606 | shouldFail: true, |
| 1607 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1608 | }, |
| 1609 | { |
| 1610 | protocol: dtls, |
| 1611 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1612 | config: Config{ |
| 1613 | Bugs: ProtocolBugs{ |
| 1614 | ReorderHandshakeFragments: true, |
| 1615 | // Small enough that every handshake message is |
| 1616 | // fragmented. |
| 1617 | MaxHandshakeRecordLength: 2, |
| 1618 | }, |
| 1619 | }, |
| 1620 | }, |
| 1621 | { |
| 1622 | protocol: dtls, |
| 1623 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1624 | config: Config{ |
| 1625 | Bugs: ProtocolBugs{ |
| 1626 | ReorderHandshakeFragments: true, |
| 1627 | // Large enough that no handshake message is |
| 1628 | // fragmented. |
| 1629 | MaxHandshakeRecordLength: 2048, |
| 1630 | }, |
| 1631 | }, |
| 1632 | }, |
| 1633 | { |
| 1634 | protocol: dtls, |
| 1635 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1636 | config: Config{ |
| 1637 | Bugs: ProtocolBugs{ |
| 1638 | ReorderHandshakeFragments: true, |
| 1639 | MixCompleteMessageWithFragments: true, |
| 1640 | MaxHandshakeRecordLength: 2, |
| 1641 | }, |
| 1642 | }, |
| 1643 | }, |
| 1644 | { |
| 1645 | name: "SendInvalidRecordType", |
| 1646 | config: Config{ |
| 1647 | Bugs: ProtocolBugs{ |
| 1648 | SendInvalidRecordType: true, |
| 1649 | }, |
| 1650 | }, |
| 1651 | shouldFail: true, |
| 1652 | expectedError: ":UNEXPECTED_RECORD:", |
| 1653 | }, |
| 1654 | { |
| 1655 | protocol: dtls, |
| 1656 | name: "SendInvalidRecordType-DTLS", |
| 1657 | config: Config{ |
| 1658 | Bugs: ProtocolBugs{ |
| 1659 | SendInvalidRecordType: true, |
| 1660 | }, |
| 1661 | }, |
| 1662 | shouldFail: true, |
| 1663 | expectedError: ":UNEXPECTED_RECORD:", |
| 1664 | }, |
| 1665 | { |
| 1666 | name: "FalseStart-SkipServerSecondLeg", |
| 1667 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1668 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1669 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1670 | NextProtos: []string{"foo"}, |
| 1671 | Bugs: ProtocolBugs{ |
| 1672 | SkipNewSessionTicket: true, |
| 1673 | SkipChangeCipherSpec: true, |
| 1674 | SkipFinished: true, |
| 1675 | ExpectFalseStart: true, |
| 1676 | }, |
| 1677 | }, |
| 1678 | flags: []string{ |
| 1679 | "-false-start", |
| 1680 | "-handshake-never-done", |
| 1681 | "-advertise-alpn", "\x03foo", |
| 1682 | }, |
| 1683 | shimWritesFirst: true, |
| 1684 | shouldFail: true, |
| 1685 | expectedError: ":UNEXPECTED_RECORD:", |
| 1686 | }, |
| 1687 | { |
| 1688 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1689 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1690 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1691 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1692 | NextProtos: []string{"foo"}, |
| 1693 | Bugs: ProtocolBugs{ |
| 1694 | SkipNewSessionTicket: true, |
| 1695 | SkipChangeCipherSpec: true, |
| 1696 | SkipFinished: true, |
| 1697 | }, |
| 1698 | }, |
| 1699 | flags: []string{ |
| 1700 | "-implicit-handshake", |
| 1701 | "-false-start", |
| 1702 | "-handshake-never-done", |
| 1703 | "-advertise-alpn", "\x03foo", |
| 1704 | }, |
| 1705 | shouldFail: true, |
| 1706 | expectedError: ":UNEXPECTED_RECORD:", |
| 1707 | }, |
| 1708 | { |
| 1709 | testType: serverTest, |
| 1710 | name: "FailEarlyCallback", |
| 1711 | flags: []string{"-fail-early-callback"}, |
| 1712 | shouldFail: true, |
| 1713 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1714 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1715 | }, |
| 1716 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1717 | protocol: dtls, |
| 1718 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1719 | config: Config{ |
| 1720 | Bugs: ProtocolBugs{ |
| 1721 | MaxHandshakeRecordLength: 2, |
| 1722 | FragmentMessageTypeMismatch: true, |
| 1723 | }, |
| 1724 | }, |
| 1725 | shouldFail: true, |
| 1726 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1727 | }, |
| 1728 | { |
| 1729 | protocol: dtls, |
| 1730 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1731 | config: Config{ |
| 1732 | Bugs: ProtocolBugs{ |
| 1733 | MaxHandshakeRecordLength: 2, |
| 1734 | FragmentMessageLengthMismatch: true, |
| 1735 | }, |
| 1736 | }, |
| 1737 | shouldFail: true, |
| 1738 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1739 | }, |
| 1740 | { |
| 1741 | protocol: dtls, |
| 1742 | name: "SplitFragments-Header-DTLS", |
| 1743 | config: Config{ |
| 1744 | Bugs: ProtocolBugs{ |
| 1745 | SplitFragments: 2, |
| 1746 | }, |
| 1747 | }, |
| 1748 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1749 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1750 | }, |
| 1751 | { |
| 1752 | protocol: dtls, |
| 1753 | name: "SplitFragments-Boundary-DTLS", |
| 1754 | config: Config{ |
| 1755 | Bugs: ProtocolBugs{ |
| 1756 | SplitFragments: dtlsRecordHeaderLen, |
| 1757 | }, |
| 1758 | }, |
| 1759 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1760 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1761 | }, |
| 1762 | { |
| 1763 | protocol: dtls, |
| 1764 | name: "SplitFragments-Body-DTLS", |
| 1765 | config: Config{ |
| 1766 | Bugs: ProtocolBugs{ |
| 1767 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1768 | }, |
| 1769 | }, |
| 1770 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1771 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1772 | }, |
| 1773 | { |
| 1774 | protocol: dtls, |
| 1775 | name: "SendEmptyFragments-DTLS", |
| 1776 | config: Config{ |
| 1777 | Bugs: ProtocolBugs{ |
| 1778 | SendEmptyFragments: true, |
| 1779 | }, |
| 1780 | }, |
| 1781 | }, |
| 1782 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1783 | name: "BadFinished-Client", |
| 1784 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1785 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1786 | Bugs: ProtocolBugs{ |
| 1787 | BadFinished: true, |
| 1788 | }, |
| 1789 | }, |
| 1790 | shouldFail: true, |
| 1791 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1792 | }, |
| 1793 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1794 | name: "BadFinished-Client-TLS13", |
| 1795 | config: Config{ |
| 1796 | MaxVersion: VersionTLS13, |
| 1797 | Bugs: ProtocolBugs{ |
| 1798 | BadFinished: true, |
| 1799 | }, |
| 1800 | }, |
| 1801 | shouldFail: true, |
| 1802 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1803 | }, |
| 1804 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1805 | testType: serverTest, |
| 1806 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1807 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1808 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1809 | Bugs: ProtocolBugs{ |
| 1810 | BadFinished: true, |
| 1811 | }, |
| 1812 | }, |
| 1813 | shouldFail: true, |
| 1814 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1815 | }, |
| 1816 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1817 | testType: serverTest, |
| 1818 | name: "BadFinished-Server-TLS13", |
| 1819 | config: Config{ |
| 1820 | MaxVersion: VersionTLS13, |
| 1821 | Bugs: ProtocolBugs{ |
| 1822 | BadFinished: true, |
| 1823 | }, |
| 1824 | }, |
| 1825 | shouldFail: true, |
| 1826 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1827 | }, |
| 1828 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1829 | name: "FalseStart-BadFinished", |
| 1830 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1831 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1832 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1833 | NextProtos: []string{"foo"}, |
| 1834 | Bugs: ProtocolBugs{ |
| 1835 | BadFinished: true, |
| 1836 | ExpectFalseStart: true, |
| 1837 | }, |
| 1838 | }, |
| 1839 | flags: []string{ |
| 1840 | "-false-start", |
| 1841 | "-handshake-never-done", |
| 1842 | "-advertise-alpn", "\x03foo", |
| 1843 | }, |
| 1844 | shimWritesFirst: true, |
| 1845 | shouldFail: true, |
| 1846 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1847 | }, |
| 1848 | { |
| 1849 | name: "NoFalseStart-NoALPN", |
| 1850 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1851 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1852 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1853 | Bugs: ProtocolBugs{ |
| 1854 | ExpectFalseStart: true, |
| 1855 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1856 | }, |
| 1857 | }, |
| 1858 | flags: []string{ |
| 1859 | "-false-start", |
| 1860 | }, |
| 1861 | shimWritesFirst: true, |
| 1862 | shouldFail: true, |
| 1863 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1864 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1865 | }, |
| 1866 | { |
| 1867 | name: "NoFalseStart-NoAEAD", |
| 1868 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1869 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1870 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1871 | NextProtos: []string{"foo"}, |
| 1872 | Bugs: ProtocolBugs{ |
| 1873 | ExpectFalseStart: true, |
| 1874 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1875 | }, |
| 1876 | }, |
| 1877 | flags: []string{ |
| 1878 | "-false-start", |
| 1879 | "-advertise-alpn", "\x03foo", |
| 1880 | }, |
| 1881 | shimWritesFirst: true, |
| 1882 | shouldFail: true, |
| 1883 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1884 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1885 | }, |
| 1886 | { |
| 1887 | name: "NoFalseStart-RSA", |
| 1888 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1889 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1890 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1891 | NextProtos: []string{"foo"}, |
| 1892 | Bugs: ProtocolBugs{ |
| 1893 | ExpectFalseStart: true, |
| 1894 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1895 | }, |
| 1896 | }, |
| 1897 | flags: []string{ |
| 1898 | "-false-start", |
| 1899 | "-advertise-alpn", "\x03foo", |
| 1900 | }, |
| 1901 | shimWritesFirst: true, |
| 1902 | shouldFail: true, |
| 1903 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1904 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1905 | }, |
| 1906 | { |
| 1907 | name: "NoFalseStart-DHE_RSA", |
| 1908 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1909 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1910 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1911 | NextProtos: []string{"foo"}, |
| 1912 | Bugs: ProtocolBugs{ |
| 1913 | ExpectFalseStart: true, |
| 1914 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1915 | }, |
| 1916 | }, |
| 1917 | flags: []string{ |
| 1918 | "-false-start", |
| 1919 | "-advertise-alpn", "\x03foo", |
| 1920 | }, |
| 1921 | shimWritesFirst: true, |
| 1922 | shouldFail: true, |
| 1923 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1924 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1925 | }, |
| 1926 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1927 | protocol: dtls, |
| 1928 | name: "SendSplitAlert-Sync", |
| 1929 | config: Config{ |
| 1930 | Bugs: ProtocolBugs{ |
| 1931 | SendSplitAlert: true, |
| 1932 | }, |
| 1933 | }, |
| 1934 | }, |
| 1935 | { |
| 1936 | protocol: dtls, |
| 1937 | name: "SendSplitAlert-Async", |
| 1938 | config: Config{ |
| 1939 | Bugs: ProtocolBugs{ |
| 1940 | SendSplitAlert: true, |
| 1941 | }, |
| 1942 | }, |
| 1943 | flags: []string{"-async"}, |
| 1944 | }, |
| 1945 | { |
| 1946 | protocol: dtls, |
| 1947 | name: "PackDTLSHandshake", |
| 1948 | config: Config{ |
| 1949 | Bugs: ProtocolBugs{ |
| 1950 | MaxHandshakeRecordLength: 2, |
| 1951 | PackHandshakeFragments: 20, |
| 1952 | PackHandshakeRecords: 200, |
| 1953 | }, |
| 1954 | }, |
| 1955 | }, |
| 1956 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1957 | name: "SendEmptyRecords-Pass", |
| 1958 | sendEmptyRecords: 32, |
| 1959 | }, |
| 1960 | { |
| 1961 | name: "SendEmptyRecords", |
| 1962 | sendEmptyRecords: 33, |
| 1963 | shouldFail: true, |
| 1964 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1965 | }, |
| 1966 | { |
| 1967 | name: "SendEmptyRecords-Async", |
| 1968 | sendEmptyRecords: 33, |
| 1969 | flags: []string{"-async"}, |
| 1970 | shouldFail: true, |
| 1971 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 1972 | }, |
| 1973 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1974 | name: "SendWarningAlerts-Pass", |
| 1975 | config: Config{ |
| 1976 | MaxVersion: VersionTLS12, |
| 1977 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1978 | sendWarningAlerts: 4, |
| 1979 | }, |
| 1980 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1981 | protocol: dtls, |
| 1982 | name: "SendWarningAlerts-DTLS-Pass", |
| 1983 | config: Config{ |
| 1984 | MaxVersion: VersionTLS12, |
| 1985 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1986 | sendWarningAlerts: 4, |
| 1987 | }, |
| 1988 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 1989 | name: "SendWarningAlerts-TLS13", |
| 1990 | config: Config{ |
| 1991 | MaxVersion: VersionTLS13, |
| 1992 | }, |
| 1993 | sendWarningAlerts: 4, |
| 1994 | shouldFail: true, |
| 1995 | expectedError: ":BAD_ALERT:", |
| 1996 | expectedLocalError: "remote error: error decoding message", |
| 1997 | }, |
| 1998 | { |
| 1999 | name: "SendWarningAlerts", |
| 2000 | config: Config{ |
| 2001 | MaxVersion: VersionTLS12, |
| 2002 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2003 | sendWarningAlerts: 5, |
| 2004 | shouldFail: true, |
| 2005 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2006 | }, |
| 2007 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2008 | name: "SendWarningAlerts-Async", |
| 2009 | config: Config{ |
| 2010 | MaxVersion: VersionTLS12, |
| 2011 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2012 | sendWarningAlerts: 5, |
| 2013 | flags: []string{"-async"}, |
| 2014 | shouldFail: true, |
| 2015 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2016 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2017 | { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2018 | name: "SendKeyUpdates", |
| 2019 | config: Config{ |
| 2020 | MaxVersion: VersionTLS13, |
| 2021 | }, |
| 2022 | sendKeyUpdates: 33, |
| 2023 | shouldFail: true, |
| 2024 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
| 2025 | }, |
| 2026 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2027 | name: "EmptySessionID", |
| 2028 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2029 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2030 | SessionTicketsDisabled: true, |
| 2031 | }, |
| 2032 | noSessionCache: true, |
| 2033 | flags: []string{"-expect-no-session"}, |
| 2034 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2035 | { |
| 2036 | name: "Unclean-Shutdown", |
| 2037 | config: Config{ |
| 2038 | Bugs: ProtocolBugs{ |
| 2039 | NoCloseNotify: true, |
| 2040 | ExpectCloseNotify: true, |
| 2041 | }, |
| 2042 | }, |
| 2043 | shimShutsDown: true, |
| 2044 | flags: []string{"-check-close-notify"}, |
| 2045 | shouldFail: true, |
| 2046 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2047 | }, |
| 2048 | { |
| 2049 | name: "Unclean-Shutdown-Ignored", |
| 2050 | config: Config{ |
| 2051 | Bugs: ProtocolBugs{ |
| 2052 | NoCloseNotify: true, |
| 2053 | }, |
| 2054 | }, |
| 2055 | shimShutsDown: true, |
| 2056 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2057 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2058 | name: "Unclean-Shutdown-Alert", |
| 2059 | config: Config{ |
| 2060 | Bugs: ProtocolBugs{ |
| 2061 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2062 | ExpectCloseNotify: true, |
| 2063 | }, |
| 2064 | }, |
| 2065 | shimShutsDown: true, |
| 2066 | flags: []string{"-check-close-notify"}, |
| 2067 | shouldFail: true, |
| 2068 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2069 | }, |
| 2070 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2071 | name: "LargePlaintext", |
| 2072 | config: Config{ |
| 2073 | Bugs: ProtocolBugs{ |
| 2074 | SendLargeRecords: true, |
| 2075 | }, |
| 2076 | }, |
| 2077 | messageLen: maxPlaintext + 1, |
| 2078 | shouldFail: true, |
| 2079 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2080 | }, |
| 2081 | { |
| 2082 | protocol: dtls, |
| 2083 | name: "LargePlaintext-DTLS", |
| 2084 | config: Config{ |
| 2085 | Bugs: ProtocolBugs{ |
| 2086 | SendLargeRecords: true, |
| 2087 | }, |
| 2088 | }, |
| 2089 | messageLen: maxPlaintext + 1, |
| 2090 | shouldFail: true, |
| 2091 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2092 | }, |
| 2093 | { |
| 2094 | name: "LargeCiphertext", |
| 2095 | config: Config{ |
| 2096 | Bugs: ProtocolBugs{ |
| 2097 | SendLargeRecords: true, |
| 2098 | }, |
| 2099 | }, |
| 2100 | messageLen: maxPlaintext * 2, |
| 2101 | shouldFail: true, |
| 2102 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2103 | }, |
| 2104 | { |
| 2105 | protocol: dtls, |
| 2106 | name: "LargeCiphertext-DTLS", |
| 2107 | config: Config{ |
| 2108 | Bugs: ProtocolBugs{ |
| 2109 | SendLargeRecords: true, |
| 2110 | }, |
| 2111 | }, |
| 2112 | messageLen: maxPlaintext * 2, |
| 2113 | // Unlike the other four cases, DTLS drops records which |
| 2114 | // are invalid before authentication, so the connection |
| 2115 | // does not fail. |
| 2116 | expectMessageDropped: true, |
| 2117 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2118 | { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2119 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 2120 | // mean the server changed its mind on sending a ticket. |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2121 | name: "SendEmptySessionTicket", |
| 2122 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2123 | MaxVersion: VersionTLS12, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2124 | Bugs: ProtocolBugs{ |
| 2125 | SendEmptySessionTicket: true, |
| 2126 | FailIfSessionOffered: true, |
| 2127 | }, |
| 2128 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 2129 | flags: []string{"-expect-no-session"}, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2130 | }, |
David Benjamin | 99fdfb9 | 2015-11-02 12:11:35 -0500 | [diff] [blame] | 2131 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2132 | name: "BadHelloRequest-1", |
| 2133 | renegotiate: 1, |
| 2134 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2135 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2136 | Bugs: ProtocolBugs{ |
| 2137 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2138 | }, |
| 2139 | }, |
| 2140 | flags: []string{ |
| 2141 | "-renegotiate-freely", |
| 2142 | "-expect-total-renegotiations", "1", |
| 2143 | }, |
| 2144 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2145 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2146 | }, |
| 2147 | { |
| 2148 | name: "BadHelloRequest-2", |
| 2149 | renegotiate: 1, |
| 2150 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2151 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2152 | Bugs: ProtocolBugs{ |
| 2153 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2154 | }, |
| 2155 | }, |
| 2156 | flags: []string{ |
| 2157 | "-renegotiate-freely", |
| 2158 | "-expect-total-renegotiations", "1", |
| 2159 | }, |
| 2160 | shouldFail: true, |
| 2161 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2162 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2163 | { |
| 2164 | testType: serverTest, |
| 2165 | name: "SupportTicketsWithSessionID", |
| 2166 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2167 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2168 | SessionTicketsDisabled: true, |
| 2169 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2170 | resumeConfig: &Config{ |
| 2171 | MaxVersion: VersionTLS12, |
| 2172 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2173 | resumeSession: true, |
| 2174 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2175 | { |
| 2176 | protocol: dtls, |
| 2177 | name: "DTLS-SendExtraFinished", |
| 2178 | config: Config{ |
| 2179 | Bugs: ProtocolBugs{ |
| 2180 | SendExtraFinished: true, |
| 2181 | }, |
| 2182 | }, |
| 2183 | shouldFail: true, |
| 2184 | expectedError: ":UNEXPECTED_RECORD:", |
| 2185 | }, |
| 2186 | { |
| 2187 | protocol: dtls, |
| 2188 | name: "DTLS-SendExtraFinished-Reordered", |
| 2189 | config: Config{ |
| 2190 | Bugs: ProtocolBugs{ |
| 2191 | MaxHandshakeRecordLength: 2, |
| 2192 | ReorderHandshakeFragments: true, |
| 2193 | SendExtraFinished: true, |
| 2194 | }, |
| 2195 | }, |
| 2196 | shouldFail: true, |
| 2197 | expectedError: ":UNEXPECTED_RECORD:", |
| 2198 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2199 | { |
| 2200 | testType: serverTest, |
| 2201 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2202 | config: Config{ |
| 2203 | // Choose a cipher suite that does not involve |
| 2204 | // elliptic curves, so no extensions are |
| 2205 | // involved. |
| 2206 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2207 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2208 | Bugs: ProtocolBugs{ |
| 2209 | SendV2ClientHello: true, |
| 2210 | }, |
| 2211 | }, |
| 2212 | sendPrefix: string([]byte{ |
| 2213 | byte(recordTypeHandshake), |
| 2214 | 3, 1, // version |
| 2215 | 0, 0, // length |
| 2216 | }), |
| 2217 | // A no-op empty record may not be sent before V2ClientHello. |
| 2218 | shouldFail: true, |
| 2219 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2220 | }, |
| 2221 | { |
| 2222 | testType: serverTest, |
| 2223 | name: "V2ClientHello-WarningAlertPrefix", |
| 2224 | config: Config{ |
| 2225 | // Choose a cipher suite that does not involve |
| 2226 | // elliptic curves, so no extensions are |
| 2227 | // involved. |
| 2228 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2229 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2230 | Bugs: ProtocolBugs{ |
| 2231 | SendV2ClientHello: true, |
| 2232 | }, |
| 2233 | }, |
| 2234 | sendPrefix: string([]byte{ |
| 2235 | byte(recordTypeAlert), |
| 2236 | 3, 1, // version |
| 2237 | 0, 2, // length |
| 2238 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2239 | }), |
| 2240 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2241 | shouldFail: true, |
| 2242 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2243 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2244 | { |
| 2245 | testType: clientTest, |
| 2246 | name: "KeyUpdate", |
| 2247 | config: Config{ |
| 2248 | MaxVersion: VersionTLS13, |
| 2249 | Bugs: ProtocolBugs{ |
| 2250 | SendKeyUpdateBeforeEveryAppDataRecord: true, |
| 2251 | }, |
| 2252 | }, |
| 2253 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2254 | { |
| 2255 | name: "SendSNIWarningAlert", |
| 2256 | config: Config{ |
| 2257 | MaxVersion: VersionTLS12, |
| 2258 | Bugs: ProtocolBugs{ |
| 2259 | SendSNIWarningAlert: true, |
| 2260 | }, |
| 2261 | }, |
| 2262 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2263 | { |
| 2264 | testType: serverTest, |
| 2265 | name: "ExtraCompressionMethods-TLS12", |
| 2266 | config: Config{ |
| 2267 | MaxVersion: VersionTLS12, |
| 2268 | Bugs: ProtocolBugs{ |
| 2269 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2270 | }, |
| 2271 | }, |
| 2272 | }, |
| 2273 | { |
| 2274 | testType: serverTest, |
| 2275 | name: "ExtraCompressionMethods-TLS13", |
| 2276 | config: Config{ |
| 2277 | MaxVersion: VersionTLS13, |
| 2278 | Bugs: ProtocolBugs{ |
| 2279 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2280 | }, |
| 2281 | }, |
| 2282 | shouldFail: true, |
| 2283 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2284 | expectedLocalError: "remote error: illegal parameter", |
| 2285 | }, |
| 2286 | { |
| 2287 | testType: serverTest, |
| 2288 | name: "NoNullCompression-TLS12", |
| 2289 | config: Config{ |
| 2290 | MaxVersion: VersionTLS12, |
| 2291 | Bugs: ProtocolBugs{ |
| 2292 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2293 | }, |
| 2294 | }, |
| 2295 | shouldFail: true, |
| 2296 | expectedError: ":NO_COMPRESSION_SPECIFIED:", |
| 2297 | expectedLocalError: "remote error: illegal parameter", |
| 2298 | }, |
| 2299 | { |
| 2300 | testType: serverTest, |
| 2301 | name: "NoNullCompression-TLS13", |
| 2302 | config: Config{ |
| 2303 | MaxVersion: VersionTLS13, |
| 2304 | Bugs: ProtocolBugs{ |
| 2305 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2306 | }, |
| 2307 | }, |
| 2308 | shouldFail: true, |
| 2309 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2310 | expectedLocalError: "remote error: illegal parameter", |
| 2311 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2312 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2313 | testCases = append(testCases, basicTests...) |
| 2314 | } |
| 2315 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2316 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2317 | const bogusCipher = 0xfe00 |
| 2318 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2319 | for _, suite := range testCipherSuites { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2320 | const psk = "12345" |
| 2321 | const pskIdentity = "luggage combo" |
| 2322 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2323 | var cert Certificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2324 | var certFile string |
| 2325 | var keyFile string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2326 | if hasComponent(suite.name, "ECDSA") { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2327 | cert = ecdsaP256Certificate |
| 2328 | certFile = ecdsaP256CertificateFile |
| 2329 | keyFile = ecdsaP256KeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2330 | } else { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2331 | cert = rsaCertificate |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2332 | certFile = rsaCertificateFile |
| 2333 | keyFile = rsaKeyFile |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2336 | var flags []string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 2337 | if hasComponent(suite.name, "PSK") { |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2338 | flags = append(flags, |
| 2339 | "-psk", psk, |
| 2340 | "-psk-identity", pskIdentity) |
| 2341 | } |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 2342 | if hasComponent(suite.name, "NULL") { |
| 2343 | // NULL ciphers must be explicitly enabled. |
| 2344 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2345 | } |
Matt Braithwaite | 053931e | 2016-05-25 12:06:05 -0700 | [diff] [blame] | 2346 | if hasComponent(suite.name, "CECPQ1") { |
| 2347 | // CECPQ1 ciphers must be explicitly enabled. |
| 2348 | flags = append(flags, "-cipher", "DEFAULT:kCECPQ1") |
| 2349 | } |
David Benjamin | 881f196 | 2016-08-10 18:29:12 -0400 | [diff] [blame] | 2350 | if hasComponent(suite.name, "ECDHE-PSK") && hasComponent(suite.name, "GCM") { |
| 2351 | // ECDHE_PSK AES_GCM ciphers must be explicitly enabled |
| 2352 | // for now. |
| 2353 | flags = append(flags, "-cipher", suite.name) |
| 2354 | } |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2355 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2356 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2357 | for _, protocol := range []protocol{tls, dtls} { |
| 2358 | var prefix string |
| 2359 | if protocol == dtls { |
| 2360 | if !ver.hasDTLS { |
| 2361 | continue |
| 2362 | } |
| 2363 | prefix = "D" |
| 2364 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2365 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2366 | var shouldServerFail, shouldClientFail bool |
| 2367 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2368 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2369 | // a BoringSSL server will never select it |
| 2370 | // because the extension is missing. |
| 2371 | shouldServerFail = true |
| 2372 | } |
| 2373 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2374 | shouldClientFail = true |
| 2375 | shouldServerFail = true |
| 2376 | } |
David Benjamin | 54c217c | 2016-07-13 12:35:25 -0400 | [diff] [blame] | 2377 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2378 | shouldClientFail = true |
| 2379 | shouldServerFail = true |
| 2380 | } |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2381 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2382 | shouldClientFail = true |
| 2383 | shouldServerFail = true |
| 2384 | } |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 2385 | |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2386 | var expectedServerError, expectedClientError string |
| 2387 | if shouldServerFail { |
| 2388 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2389 | } |
| 2390 | if shouldClientFail { |
| 2391 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2392 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2393 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2394 | testCases = append(testCases, testCase{ |
| 2395 | testType: serverTest, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2396 | protocol: protocol, |
| 2397 | |
| 2398 | name: prefix + ver.name + "-" + suite.name + "-server", |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2399 | config: Config{ |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2400 | MinVersion: ver.version, |
| 2401 | MaxVersion: ver.version, |
| 2402 | CipherSuites: []uint16{suite.id}, |
| 2403 | Certificates: []Certificate{cert}, |
| 2404 | PreSharedKey: []byte(psk), |
| 2405 | PreSharedKeyIdentity: pskIdentity, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2406 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2407 | EnableAllCiphers: shouldServerFail, |
| 2408 | IgnorePeerCipherPreferences: shouldServerFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2409 | }, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2410 | }, |
| 2411 | certFile: certFile, |
| 2412 | keyFile: keyFile, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 2413 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2414 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2415 | shouldFail: shouldServerFail, |
| 2416 | expectedError: expectedServerError, |
| 2417 | }) |
| 2418 | |
| 2419 | testCases = append(testCases, testCase{ |
| 2420 | testType: clientTest, |
| 2421 | protocol: protocol, |
| 2422 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2423 | config: Config{ |
| 2424 | MinVersion: ver.version, |
| 2425 | MaxVersion: ver.version, |
| 2426 | CipherSuites: []uint16{suite.id}, |
| 2427 | Certificates: []Certificate{cert}, |
| 2428 | PreSharedKey: []byte(psk), |
| 2429 | PreSharedKeyIdentity: pskIdentity, |
| 2430 | Bugs: ProtocolBugs{ |
David Benjamin | 9acf0ca | 2016-06-25 00:01:28 -0400 | [diff] [blame] | 2431 | EnableAllCiphers: shouldClientFail, |
| 2432 | IgnorePeerCipherPreferences: shouldClientFail, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2433 | }, |
| 2434 | }, |
| 2435 | flags: flags, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 2436 | resumeSession: true, |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2437 | shouldFail: shouldClientFail, |
| 2438 | expectedError: expectedClientError, |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 2439 | }) |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2440 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2441 | if !shouldClientFail { |
| 2442 | // Ensure the maximum record size is accepted. |
| 2443 | testCases = append(testCases, testCase{ |
| 2444 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2445 | config: Config{ |
| 2446 | MinVersion: ver.version, |
| 2447 | MaxVersion: ver.version, |
| 2448 | CipherSuites: []uint16{suite.id}, |
| 2449 | Certificates: []Certificate{cert}, |
| 2450 | PreSharedKey: []byte(psk), |
| 2451 | PreSharedKeyIdentity: pskIdentity, |
| 2452 | }, |
| 2453 | flags: flags, |
| 2454 | messageLen: maxPlaintext, |
| 2455 | }) |
| 2456 | } |
| 2457 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2458 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2459 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2460 | |
| 2461 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2462 | name: "NoSharedCipher", |
| 2463 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2464 | MaxVersion: VersionTLS12, |
| 2465 | CipherSuites: []uint16{}, |
| 2466 | }, |
| 2467 | shouldFail: true, |
| 2468 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2469 | }) |
| 2470 | |
| 2471 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2472 | name: "NoSharedCipher-TLS13", |
| 2473 | config: Config{ |
| 2474 | MaxVersion: VersionTLS13, |
| 2475 | CipherSuites: []uint16{}, |
| 2476 | }, |
| 2477 | shouldFail: true, |
| 2478 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2479 | }) |
| 2480 | |
| 2481 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2482 | name: "UnsupportedCipherSuite", |
| 2483 | config: Config{ |
| 2484 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2485 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2486 | Bugs: ProtocolBugs{ |
| 2487 | IgnorePeerCipherPreferences: true, |
| 2488 | }, |
| 2489 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2490 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2491 | shouldFail: true, |
| 2492 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2493 | }) |
| 2494 | |
| 2495 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2496 | name: "ServerHelloBogusCipher", |
| 2497 | config: Config{ |
| 2498 | MaxVersion: VersionTLS12, |
| 2499 | Bugs: ProtocolBugs{ |
| 2500 | SendCipherSuite: bogusCipher, |
| 2501 | }, |
| 2502 | }, |
| 2503 | shouldFail: true, |
| 2504 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2505 | }) |
| 2506 | testCases = append(testCases, testCase{ |
| 2507 | name: "ServerHelloBogusCipher-TLS13", |
| 2508 | config: Config{ |
| 2509 | MaxVersion: VersionTLS13, |
| 2510 | Bugs: ProtocolBugs{ |
| 2511 | SendCipherSuite: bogusCipher, |
| 2512 | }, |
| 2513 | }, |
| 2514 | shouldFail: true, |
| 2515 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2516 | }) |
| 2517 | |
| 2518 | testCases = append(testCases, testCase{ |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2519 | name: "WeakDH", |
| 2520 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2521 | MaxVersion: VersionTLS12, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2522 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2523 | Bugs: ProtocolBugs{ |
| 2524 | // This is a 1023-bit prime number, generated |
| 2525 | // with: |
| 2526 | // openssl gendh 1023 | openssl asn1parse -i |
| 2527 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2528 | }, |
| 2529 | }, |
| 2530 | shouldFail: true, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2531 | expectedError: ":BAD_DH_P_LENGTH:", |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2532 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2533 | |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2534 | testCases = append(testCases, testCase{ |
| 2535 | name: "SillyDH", |
| 2536 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2537 | MaxVersion: VersionTLS12, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2538 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2539 | Bugs: ProtocolBugs{ |
| 2540 | // This is a 4097-bit prime number, generated |
| 2541 | // with: |
| 2542 | // openssl gendh 4097 | openssl asn1parse -i |
| 2543 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2544 | }, |
| 2545 | }, |
| 2546 | shouldFail: true, |
| 2547 | expectedError: ":DH_P_TOO_LONG:", |
| 2548 | }) |
| 2549 | |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2550 | // This test ensures that Diffie-Hellman public values are padded with |
| 2551 | // zeros so that they're the same length as the prime. This is to avoid |
| 2552 | // hitting a bug in yaSSL. |
| 2553 | testCases = append(testCases, testCase{ |
| 2554 | testType: serverTest, |
| 2555 | name: "DHPublicValuePadded", |
| 2556 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2557 | MaxVersion: VersionTLS12, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2558 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2559 | Bugs: ProtocolBugs{ |
| 2560 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2561 | }, |
| 2562 | }, |
| 2563 | flags: []string{"-use-sparse-dh-prime"}, |
| 2564 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2565 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2566 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2567 | testCases = append(testCases, testCase{ |
| 2568 | testType: serverTest, |
| 2569 | name: "UnknownCipher", |
| 2570 | config: Config{ |
| 2571 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2572 | }, |
| 2573 | }) |
| 2574 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2575 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2576 | testCases = append(testCases, testCase{ |
| 2577 | name: "EmptyECDHEPSKHint", |
| 2578 | config: Config{ |
| 2579 | MaxVersion: VersionTLS12, |
| 2580 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2581 | PreSharedKey: []byte("secret"), |
| 2582 | }, |
| 2583 | flags: []string{"-psk", "secret"}, |
| 2584 | }) |
| 2585 | |
| 2586 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2587 | // ServerKeyExchange is sent. |
| 2588 | testCases = append(testCases, testCase{ |
| 2589 | name: "ExplicitEmptyPSKHint", |
| 2590 | config: Config{ |
| 2591 | MaxVersion: VersionTLS12, |
| 2592 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2593 | PreSharedKey: []byte("secret"), |
| 2594 | Bugs: ProtocolBugs{ |
| 2595 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2596 | }, |
| 2597 | }, |
| 2598 | flags: []string{"-psk", "secret"}, |
| 2599 | }) |
| 2600 | |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2601 | // versionSpecificCiphersTest specifies a test for the TLS 1.0 and TLS |
| 2602 | // 1.1 specific cipher suite settings. A server is setup with the given |
| 2603 | // cipher lists and then a connection is made for each member of |
| 2604 | // expectations. The cipher suite that the server selects must match |
| 2605 | // the specified one. |
| 2606 | var versionSpecificCiphersTest = []struct { |
| 2607 | ciphersDefault, ciphersTLS10, ciphersTLS11 string |
| 2608 | // expectations is a map from TLS version to cipher suite id. |
| 2609 | expectations map[uint16]uint16 |
| 2610 | }{ |
| 2611 | { |
| 2612 | // Test that the null case (where no version-specific ciphers are set) |
| 2613 | // works as expected. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2614 | "DES-CBC3-SHA:AES128-SHA", // default ciphers |
| 2615 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2616 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2617 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2618 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2619 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2620 | VersionTLS11: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2621 | VersionTLS12: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2622 | }, |
| 2623 | }, |
| 2624 | { |
| 2625 | // With ciphers_tls10 set, TLS 1.0, 1.1 and 1.2 should get a different |
| 2626 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2627 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2628 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2629 | "", // no ciphers specifically for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2630 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2631 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2632 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2633 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2634 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2635 | }, |
| 2636 | }, |
| 2637 | { |
| 2638 | // With ciphers_tls11 set, TLS 1.1 and 1.2 should get a different |
| 2639 | // cipher. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2640 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2641 | "", // no ciphers specifically for TLS ≥ 1.0 |
| 2642 | "AES128-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2643 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2644 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
| 2645 | VersionTLS10: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2646 | VersionTLS11: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2647 | VersionTLS12: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2648 | }, |
| 2649 | }, |
| 2650 | { |
| 2651 | // With both ciphers_tls10 and ciphers_tls11 set, ciphers_tls11 should |
| 2652 | // mask ciphers_tls10 for TLS 1.1 and 1.2. |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2653 | "DES-CBC3-SHA:AES128-SHA", // default |
| 2654 | "AES128-SHA", // these ciphers for TLS ≥ 1.0 |
| 2655 | "AES256-SHA", // these ciphers for TLS ≥ 1.1 |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2656 | map[uint16]uint16{ |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2657 | VersionSSL30: TLS_RSA_WITH_3DES_EDE_CBC_SHA, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2658 | VersionTLS10: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 2659 | VersionTLS11: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2660 | VersionTLS12: TLS_RSA_WITH_AES_256_CBC_SHA, |
| 2661 | }, |
| 2662 | }, |
| 2663 | } |
| 2664 | |
| 2665 | for i, test := range versionSpecificCiphersTest { |
| 2666 | for version, expectedCipherSuite := range test.expectations { |
| 2667 | flags := []string{"-cipher", test.ciphersDefault} |
| 2668 | if len(test.ciphersTLS10) > 0 { |
| 2669 | flags = append(flags, "-cipher-tls10", test.ciphersTLS10) |
| 2670 | } |
| 2671 | if len(test.ciphersTLS11) > 0 { |
| 2672 | flags = append(flags, "-cipher-tls11", test.ciphersTLS11) |
| 2673 | } |
| 2674 | |
| 2675 | testCases = append(testCases, testCase{ |
| 2676 | testType: serverTest, |
| 2677 | name: fmt.Sprintf("VersionSpecificCiphersTest-%d-%x", i, version), |
| 2678 | config: Config{ |
| 2679 | MaxVersion: version, |
| 2680 | MinVersion: version, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2681 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA}, |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2682 | }, |
| 2683 | flags: flags, |
| 2684 | expectedCipher: expectedCipherSuite, |
| 2685 | }) |
| 2686 | } |
| 2687 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2688 | } |
| 2689 | |
| 2690 | func addBadECDSASignatureTests() { |
| 2691 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2692 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2693 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2694 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2695 | config: Config{ |
| 2696 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2697 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2698 | Bugs: ProtocolBugs{ |
| 2699 | BadECDSAR: badR, |
| 2700 | BadECDSAS: badS, |
| 2701 | }, |
| 2702 | }, |
| 2703 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2704 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2705 | }) |
| 2706 | } |
| 2707 | } |
| 2708 | } |
| 2709 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2710 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2711 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2712 | name: "MaxCBCPadding", |
| 2713 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2714 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2715 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2716 | Bugs: ProtocolBugs{ |
| 2717 | MaxPadding: true, |
| 2718 | }, |
| 2719 | }, |
| 2720 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2721 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2722 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2723 | name: "BadCBCPadding", |
| 2724 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2725 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2726 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2727 | Bugs: ProtocolBugs{ |
| 2728 | PaddingFirstByteBad: true, |
| 2729 | }, |
| 2730 | }, |
| 2731 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2732 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2733 | }) |
| 2734 | // OpenSSL previously had an issue where the first byte of padding in |
| 2735 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2736 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2737 | name: "BadCBCPadding255", |
| 2738 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2739 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2740 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2741 | Bugs: ProtocolBugs{ |
| 2742 | MaxPadding: true, |
| 2743 | PaddingFirstByteBadIf255: true, |
| 2744 | }, |
| 2745 | }, |
| 2746 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2747 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2748 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2749 | }) |
| 2750 | } |
| 2751 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2752 | func addCBCSplittingTests() { |
| 2753 | testCases = append(testCases, testCase{ |
| 2754 | name: "CBCRecordSplitting", |
| 2755 | config: Config{ |
| 2756 | MaxVersion: VersionTLS10, |
| 2757 | MinVersion: VersionTLS10, |
| 2758 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2759 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2760 | messageLen: -1, // read until EOF |
| 2761 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2762 | flags: []string{ |
| 2763 | "-async", |
| 2764 | "-write-different-record-sizes", |
| 2765 | "-cbc-record-splitting", |
| 2766 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2767 | }) |
| 2768 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2769 | name: "CBCRecordSplittingPartialWrite", |
| 2770 | config: Config{ |
| 2771 | MaxVersion: VersionTLS10, |
| 2772 | MinVersion: VersionTLS10, |
| 2773 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2774 | }, |
| 2775 | messageLen: -1, // read until EOF |
| 2776 | flags: []string{ |
| 2777 | "-async", |
| 2778 | "-write-different-record-sizes", |
| 2779 | "-cbc-record-splitting", |
| 2780 | "-partial-write", |
| 2781 | }, |
| 2782 | }) |
| 2783 | } |
| 2784 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2785 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2786 | // Add a dummy cert pool to stress certificate authority parsing. |
| 2787 | // TODO(davidben): Add tests that those values parse out correctly. |
| 2788 | certPool := x509.NewCertPool() |
| 2789 | cert, err := x509.ParseCertificate(rsaCertificate.Certificate[0]) |
| 2790 | if err != nil { |
| 2791 | panic(err) |
| 2792 | } |
| 2793 | certPool.AddCert(cert) |
| 2794 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2795 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2796 | testCases = append(testCases, testCase{ |
| 2797 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2798 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2799 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2800 | MinVersion: ver.version, |
| 2801 | MaxVersion: ver.version, |
| 2802 | ClientAuth: RequireAnyClientCert, |
| 2803 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2804 | }, |
| 2805 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2806 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2807 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2808 | }, |
| 2809 | }) |
| 2810 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2811 | testType: serverTest, |
| 2812 | name: ver.name + "-Server-ClientAuth-RSA", |
| 2813 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2814 | MinVersion: ver.version, |
| 2815 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2816 | Certificates: []Certificate{rsaCertificate}, |
| 2817 | }, |
| 2818 | flags: []string{"-require-any-client-certificate"}, |
| 2819 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2820 | if ver.version != VersionSSL30 { |
| 2821 | testCases = append(testCases, testCase{ |
| 2822 | testType: serverTest, |
| 2823 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 2824 | config: Config{ |
| 2825 | MinVersion: ver.version, |
| 2826 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2827 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2828 | }, |
| 2829 | flags: []string{"-require-any-client-certificate"}, |
| 2830 | }) |
| 2831 | testCases = append(testCases, testCase{ |
| 2832 | testType: clientTest, |
| 2833 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 2834 | config: Config{ |
| 2835 | MinVersion: ver.version, |
| 2836 | MaxVersion: ver.version, |
| 2837 | ClientAuth: RequireAnyClientCert, |
| 2838 | ClientCAs: certPool, |
| 2839 | }, |
| 2840 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2841 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2842 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2843 | }, |
| 2844 | }) |
| 2845 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 2846 | |
| 2847 | testCases = append(testCases, testCase{ |
| 2848 | name: "NoClientCertificate-" + ver.name, |
| 2849 | config: Config{ |
| 2850 | MinVersion: ver.version, |
| 2851 | MaxVersion: ver.version, |
| 2852 | ClientAuth: RequireAnyClientCert, |
| 2853 | }, |
| 2854 | shouldFail: true, |
| 2855 | expectedLocalError: "client didn't provide a certificate", |
| 2856 | }) |
| 2857 | |
| 2858 | testCases = append(testCases, testCase{ |
| 2859 | // Even if not configured to expect a certificate, OpenSSL will |
| 2860 | // return X509_V_OK as the verify_result. |
| 2861 | testType: serverTest, |
| 2862 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 2863 | config: Config{ |
| 2864 | MinVersion: ver.version, |
| 2865 | MaxVersion: ver.version, |
| 2866 | }, |
| 2867 | flags: []string{ |
| 2868 | "-expect-verify-result", |
| 2869 | }, |
| 2870 | // TODO(davidben): Switch this to true when TLS 1.3 |
| 2871 | // supports session resumption. |
| 2872 | resumeSession: ver.version < VersionTLS13, |
| 2873 | }) |
| 2874 | |
| 2875 | testCases = append(testCases, testCase{ |
| 2876 | // If a client certificate is not provided, OpenSSL will still |
| 2877 | // return X509_V_OK as the verify_result. |
| 2878 | testType: serverTest, |
| 2879 | name: "NoClientCertificate-Server-" + ver.name, |
| 2880 | config: Config{ |
| 2881 | MinVersion: ver.version, |
| 2882 | MaxVersion: ver.version, |
| 2883 | }, |
| 2884 | flags: []string{ |
| 2885 | "-expect-verify-result", |
| 2886 | "-verify-peer", |
| 2887 | }, |
| 2888 | // TODO(davidben): Switch this to true when TLS 1.3 |
| 2889 | // supports session resumption. |
| 2890 | resumeSession: ver.version < VersionTLS13, |
| 2891 | }) |
| 2892 | |
| 2893 | testCases = append(testCases, testCase{ |
| 2894 | testType: serverTest, |
| 2895 | name: "RequireAnyClientCertificate-" + ver.name, |
| 2896 | config: Config{ |
| 2897 | MinVersion: ver.version, |
| 2898 | MaxVersion: ver.version, |
| 2899 | }, |
| 2900 | flags: []string{"-require-any-client-certificate"}, |
| 2901 | shouldFail: true, |
| 2902 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 2903 | }) |
| 2904 | |
| 2905 | if ver.version != VersionSSL30 { |
| 2906 | testCases = append(testCases, testCase{ |
| 2907 | testType: serverTest, |
| 2908 | name: "SkipClientCertificate-" + ver.name, |
| 2909 | config: Config{ |
| 2910 | MinVersion: ver.version, |
| 2911 | MaxVersion: ver.version, |
| 2912 | Bugs: ProtocolBugs{ |
| 2913 | SkipClientCertificate: true, |
| 2914 | }, |
| 2915 | }, |
| 2916 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 2917 | flags: []string{"-verify-peer"}, |
| 2918 | shouldFail: true, |
| 2919 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2920 | }) |
| 2921 | } |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2922 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 2923 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2924 | // Client auth is only legal in certificate-based ciphers. |
| 2925 | testCases = append(testCases, testCase{ |
| 2926 | testType: clientTest, |
| 2927 | name: "ClientAuth-PSK", |
| 2928 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2929 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2930 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2931 | PreSharedKey: []byte("secret"), |
| 2932 | ClientAuth: RequireAnyClientCert, |
| 2933 | }, |
| 2934 | flags: []string{ |
| 2935 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2936 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2937 | "-psk", "secret", |
| 2938 | }, |
| 2939 | shouldFail: true, |
| 2940 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2941 | }) |
| 2942 | testCases = append(testCases, testCase{ |
| 2943 | testType: clientTest, |
| 2944 | name: "ClientAuth-ECDHE_PSK", |
| 2945 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2946 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 2947 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2948 | PreSharedKey: []byte("secret"), |
| 2949 | ClientAuth: RequireAnyClientCert, |
| 2950 | }, |
| 2951 | flags: []string{ |
| 2952 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2953 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2954 | "-psk", "secret", |
| 2955 | }, |
| 2956 | shouldFail: true, |
| 2957 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 2958 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 2959 | |
| 2960 | // Regression test for a bug where the client CA list, if explicitly |
| 2961 | // set to NULL, was mis-encoded. |
| 2962 | testCases = append(testCases, testCase{ |
| 2963 | testType: serverTest, |
| 2964 | name: "Null-Client-CA-List", |
| 2965 | config: Config{ |
| 2966 | MaxVersion: VersionTLS12, |
| 2967 | Certificates: []Certificate{rsaCertificate}, |
| 2968 | }, |
| 2969 | flags: []string{ |
| 2970 | "-require-any-client-certificate", |
| 2971 | "-use-null-client-ca-list", |
| 2972 | }, |
| 2973 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2974 | } |
| 2975 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2976 | func addExtendedMasterSecretTests() { |
| 2977 | const expectEMSFlag = "-expect-extended-master-secret" |
| 2978 | |
| 2979 | for _, with := range []bool{false, true} { |
| 2980 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2981 | if with { |
| 2982 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 2983 | } |
| 2984 | |
| 2985 | for _, isClient := range []bool{false, true} { |
| 2986 | suffix := "-Server" |
| 2987 | testType := serverTest |
| 2988 | if isClient { |
| 2989 | suffix = "-Client" |
| 2990 | testType = clientTest |
| 2991 | } |
| 2992 | |
| 2993 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2994 | // In TLS 1.3, the extension is irrelevant and |
| 2995 | // always reports as enabled. |
| 2996 | var flags []string |
| 2997 | if with || ver.version >= VersionTLS13 { |
| 2998 | flags = []string{expectEMSFlag} |
| 2999 | } |
| 3000 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3001 | test := testCase{ |
| 3002 | testType: testType, |
| 3003 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3004 | config: Config{ |
| 3005 | MinVersion: ver.version, |
| 3006 | MaxVersion: ver.version, |
| 3007 | Bugs: ProtocolBugs{ |
| 3008 | NoExtendedMasterSecret: !with, |
| 3009 | RequireExtendedMasterSecret: with, |
| 3010 | }, |
| 3011 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3012 | flags: flags, |
| 3013 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3014 | } |
| 3015 | if test.shouldFail { |
| 3016 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3017 | } |
| 3018 | testCases = append(testCases, test) |
| 3019 | } |
| 3020 | } |
| 3021 | } |
| 3022 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3023 | for _, isClient := range []bool{false, true} { |
| 3024 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3025 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3026 | boolToWord := func(b bool) string { |
| 3027 | if b { |
| 3028 | return "Yes" |
| 3029 | } |
| 3030 | return "No" |
| 3031 | } |
| 3032 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3033 | if isClient { |
| 3034 | suffix += "Client" |
| 3035 | } else { |
| 3036 | suffix += "Server" |
| 3037 | } |
| 3038 | |
| 3039 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3040 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3041 | Bugs: ProtocolBugs{ |
| 3042 | RequireExtendedMasterSecret: true, |
| 3043 | }, |
| 3044 | } |
| 3045 | |
| 3046 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3047 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3048 | Bugs: ProtocolBugs{ |
| 3049 | NoExtendedMasterSecret: true, |
| 3050 | }, |
| 3051 | } |
| 3052 | |
| 3053 | test := testCase{ |
| 3054 | name: "ExtendedMasterSecret-" + suffix, |
| 3055 | resumeSession: true, |
| 3056 | } |
| 3057 | |
| 3058 | if !isClient { |
| 3059 | test.testType = serverTest |
| 3060 | } |
| 3061 | |
| 3062 | if supportedInFirstConnection { |
| 3063 | test.config = supportedConfig |
| 3064 | } else { |
| 3065 | test.config = noSupportConfig |
| 3066 | } |
| 3067 | |
| 3068 | if supportedInResumeConnection { |
| 3069 | test.resumeConfig = &supportedConfig |
| 3070 | } else { |
| 3071 | test.resumeConfig = &noSupportConfig |
| 3072 | } |
| 3073 | |
| 3074 | switch suffix { |
| 3075 | case "YesToYes-Client", "YesToYes-Server": |
| 3076 | // When a session is resumed, it should |
| 3077 | // still be aware that its master |
| 3078 | // secret was generated via EMS and |
| 3079 | // thus it's safe to use tls-unique. |
| 3080 | test.flags = []string{expectEMSFlag} |
| 3081 | case "NoToYes-Server": |
| 3082 | // If an original connection did not |
| 3083 | // contain EMS, but a resumption |
| 3084 | // handshake does, then a server should |
| 3085 | // not resume the session. |
| 3086 | test.expectResumeRejected = true |
| 3087 | case "YesToNo-Server": |
| 3088 | // Resuming an EMS session without the |
| 3089 | // EMS extension should cause the |
| 3090 | // server to abort the connection. |
| 3091 | test.shouldFail = true |
| 3092 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3093 | case "NoToYes-Client": |
| 3094 | // A client should abort a connection |
| 3095 | // where the server resumed a non-EMS |
| 3096 | // session but echoed the EMS |
| 3097 | // extension. |
| 3098 | test.shouldFail = true |
| 3099 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3100 | case "YesToNo-Client": |
| 3101 | // A client should abort a connection |
| 3102 | // where the server didn't echo EMS |
| 3103 | // when the session used it. |
| 3104 | test.shouldFail = true |
| 3105 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3106 | } |
| 3107 | |
| 3108 | testCases = append(testCases, test) |
| 3109 | } |
| 3110 | } |
| 3111 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3112 | |
| 3113 | // Switching EMS on renegotiation is forbidden. |
| 3114 | testCases = append(testCases, testCase{ |
| 3115 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3116 | config: Config{ |
| 3117 | MaxVersion: VersionTLS12, |
| 3118 | Bugs: ProtocolBugs{ |
| 3119 | NoExtendedMasterSecret: true, |
| 3120 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3121 | }, |
| 3122 | }, |
| 3123 | renegotiate: 1, |
| 3124 | flags: []string{ |
| 3125 | "-renegotiate-freely", |
| 3126 | "-expect-total-renegotiations", "1", |
| 3127 | }, |
| 3128 | }) |
| 3129 | |
| 3130 | testCases = append(testCases, testCase{ |
| 3131 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3132 | config: Config{ |
| 3133 | MaxVersion: VersionTLS12, |
| 3134 | Bugs: ProtocolBugs{ |
| 3135 | NoExtendedMasterSecret: true, |
| 3136 | }, |
| 3137 | }, |
| 3138 | renegotiate: 1, |
| 3139 | flags: []string{ |
| 3140 | "-renegotiate-freely", |
| 3141 | "-expect-total-renegotiations", "1", |
| 3142 | }, |
| 3143 | shouldFail: true, |
| 3144 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3145 | }) |
| 3146 | |
| 3147 | testCases = append(testCases, testCase{ |
| 3148 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3149 | config: Config{ |
| 3150 | MaxVersion: VersionTLS12, |
| 3151 | Bugs: ProtocolBugs{ |
| 3152 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3153 | }, |
| 3154 | }, |
| 3155 | renegotiate: 1, |
| 3156 | flags: []string{ |
| 3157 | "-renegotiate-freely", |
| 3158 | "-expect-total-renegotiations", "1", |
| 3159 | }, |
| 3160 | shouldFail: true, |
| 3161 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3162 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3163 | } |
| 3164 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3165 | type stateMachineTestConfig struct { |
| 3166 | protocol protocol |
| 3167 | async bool |
| 3168 | splitHandshake, packHandshakeFlight bool |
| 3169 | } |
| 3170 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3171 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3172 | // various conditions. Some of these are redundant with other tests, but they |
| 3173 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3174 | func addAllStateMachineCoverageTests() { |
| 3175 | for _, async := range []bool{false, true} { |
| 3176 | for _, protocol := range []protocol{tls, dtls} { |
| 3177 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3178 | protocol: protocol, |
| 3179 | async: async, |
| 3180 | }) |
| 3181 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3182 | protocol: protocol, |
| 3183 | async: async, |
| 3184 | splitHandshake: true, |
| 3185 | }) |
| 3186 | if protocol == tls { |
| 3187 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3188 | protocol: protocol, |
| 3189 | async: async, |
| 3190 | packHandshakeFlight: true, |
| 3191 | }) |
| 3192 | } |
| 3193 | } |
| 3194 | } |
| 3195 | } |
| 3196 | |
| 3197 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3198 | var tests []testCase |
| 3199 | |
| 3200 | // Basic handshake, with resumption. Client and server, |
| 3201 | // session ID and session ticket. |
| 3202 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3203 | name: "Basic-Client", |
| 3204 | config: Config{ |
| 3205 | MaxVersion: VersionTLS12, |
| 3206 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3207 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3208 | // Ensure session tickets are used, not session IDs. |
| 3209 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3210 | }) |
| 3211 | tests = append(tests, testCase{ |
| 3212 | name: "Basic-Client-RenewTicket", |
| 3213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3214 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3215 | Bugs: ProtocolBugs{ |
| 3216 | RenewTicketOnResume: true, |
| 3217 | }, |
| 3218 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3219 | flags: []string{"-expect-ticket-renewal"}, |
| 3220 | resumeSession: true, |
| 3221 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3222 | }) |
| 3223 | tests = append(tests, testCase{ |
| 3224 | name: "Basic-Client-NoTicket", |
| 3225 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3226 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3227 | SessionTicketsDisabled: true, |
| 3228 | }, |
| 3229 | resumeSession: true, |
| 3230 | }) |
| 3231 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3232 | name: "Basic-Client-Implicit", |
| 3233 | config: Config{ |
| 3234 | MaxVersion: VersionTLS12, |
| 3235 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3236 | flags: []string{"-implicit-handshake"}, |
| 3237 | resumeSession: true, |
| 3238 | }) |
| 3239 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3240 | testType: serverTest, |
| 3241 | name: "Basic-Server", |
| 3242 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3243 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3244 | Bugs: ProtocolBugs{ |
| 3245 | RequireSessionTickets: true, |
| 3246 | }, |
| 3247 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3248 | resumeSession: true, |
| 3249 | }) |
| 3250 | tests = append(tests, testCase{ |
| 3251 | testType: serverTest, |
| 3252 | name: "Basic-Server-NoTickets", |
| 3253 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3254 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3255 | SessionTicketsDisabled: true, |
| 3256 | }, |
| 3257 | resumeSession: true, |
| 3258 | }) |
| 3259 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3260 | testType: serverTest, |
| 3261 | name: "Basic-Server-Implicit", |
| 3262 | config: Config{ |
| 3263 | MaxVersion: VersionTLS12, |
| 3264 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3265 | flags: []string{"-implicit-handshake"}, |
| 3266 | resumeSession: true, |
| 3267 | }) |
| 3268 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3269 | testType: serverTest, |
| 3270 | name: "Basic-Server-EarlyCallback", |
| 3271 | config: Config{ |
| 3272 | MaxVersion: VersionTLS12, |
| 3273 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3274 | flags: []string{"-use-early-callback"}, |
| 3275 | resumeSession: true, |
| 3276 | }) |
| 3277 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3278 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3279 | if config.protocol == tls { |
| 3280 | tests = append(tests, testCase{ |
| 3281 | name: "TLS13-1RTT-Client", |
| 3282 | config: Config{ |
| 3283 | MaxVersion: VersionTLS13, |
| 3284 | MinVersion: VersionTLS13, |
| 3285 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3286 | resumeSession: true, |
| 3287 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3288 | }) |
| 3289 | |
| 3290 | tests = append(tests, testCase{ |
| 3291 | testType: serverTest, |
| 3292 | name: "TLS13-1RTT-Server", |
| 3293 | config: Config{ |
| 3294 | MaxVersion: VersionTLS13, |
| 3295 | MinVersion: VersionTLS13, |
| 3296 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3297 | resumeSession: true, |
| 3298 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3299 | }) |
| 3300 | |
| 3301 | tests = append(tests, testCase{ |
| 3302 | name: "TLS13-HelloRetryRequest-Client", |
| 3303 | config: Config{ |
| 3304 | MaxVersion: VersionTLS13, |
| 3305 | MinVersion: VersionTLS13, |
| 3306 | // P-384 requires a HelloRetryRequest against |
| 3307 | // BoringSSL's default configuration. Assert |
| 3308 | // that we do indeed test this with |
| 3309 | // ExpectMissingKeyShare. |
| 3310 | CurvePreferences: []CurveID{CurveP384}, |
| 3311 | Bugs: ProtocolBugs{ |
| 3312 | ExpectMissingKeyShare: true, |
| 3313 | }, |
| 3314 | }, |
| 3315 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3316 | resumeSession: true, |
| 3317 | }) |
| 3318 | |
| 3319 | tests = append(tests, testCase{ |
| 3320 | testType: serverTest, |
| 3321 | name: "TLS13-HelloRetryRequest-Server", |
| 3322 | config: Config{ |
| 3323 | MaxVersion: VersionTLS13, |
| 3324 | MinVersion: VersionTLS13, |
| 3325 | // Require a HelloRetryRequest for every curve. |
| 3326 | DefaultCurves: []CurveID{}, |
| 3327 | }, |
| 3328 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3329 | resumeSession: true, |
| 3330 | }) |
| 3331 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3332 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3333 | // TLS client auth. |
| 3334 | tests = append(tests, testCase{ |
| 3335 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3336 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3337 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3338 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3339 | ClientAuth: RequestClientCert, |
| 3340 | }, |
| 3341 | }) |
| 3342 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3343 | testType: serverTest, |
| 3344 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3345 | config: Config{ |
| 3346 | MaxVersion: VersionTLS12, |
| 3347 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3348 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3349 | flags: []string{"-verify-peer"}, |
| 3350 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3351 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3352 | tests = append(tests, testCase{ |
| 3353 | testType: clientTest, |
| 3354 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3355 | config: Config{ |
| 3356 | MaxVersion: VersionSSL30, |
| 3357 | ClientAuth: RequestClientCert, |
| 3358 | }, |
| 3359 | }) |
| 3360 | tests = append(tests, testCase{ |
| 3361 | testType: serverTest, |
| 3362 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3363 | config: Config{ |
| 3364 | MaxVersion: VersionSSL30, |
| 3365 | }, |
| 3366 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3367 | flags: []string{"-verify-peer"}, |
| 3368 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3369 | tests = append(tests, testCase{ |
| 3370 | testType: clientTest, |
| 3371 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3372 | config: Config{ |
| 3373 | MaxVersion: VersionTLS13, |
| 3374 | ClientAuth: RequestClientCert, |
| 3375 | }, |
| 3376 | }) |
| 3377 | tests = append(tests, testCase{ |
| 3378 | testType: serverTest, |
| 3379 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3380 | config: Config{ |
| 3381 | MaxVersion: VersionTLS13, |
| 3382 | }, |
| 3383 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3384 | flags: []string{"-verify-peer"}, |
| 3385 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3386 | } |
| 3387 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3388 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3389 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3390 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3391 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3392 | ClientAuth: RequireAnyClientCert, |
| 3393 | }, |
| 3394 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3395 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3396 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3397 | }, |
| 3398 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3399 | tests = append(tests, testCase{ |
| 3400 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3401 | name: "ClientAuth-RSA-Client-TLS13", |
| 3402 | config: Config{ |
| 3403 | MaxVersion: VersionTLS13, |
| 3404 | ClientAuth: RequireAnyClientCert, |
| 3405 | }, |
| 3406 | flags: []string{ |
| 3407 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3408 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3409 | }, |
| 3410 | }) |
| 3411 | tests = append(tests, testCase{ |
| 3412 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3413 | name: "ClientAuth-ECDSA-Client", |
| 3414 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3415 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3416 | ClientAuth: RequireAnyClientCert, |
| 3417 | }, |
| 3418 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3419 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3420 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3421 | }, |
| 3422 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3423 | tests = append(tests, testCase{ |
| 3424 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3425 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3426 | config: Config{ |
| 3427 | MaxVersion: VersionTLS13, |
| 3428 | ClientAuth: RequireAnyClientCert, |
| 3429 | }, |
| 3430 | flags: []string{ |
| 3431 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3432 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3433 | }, |
| 3434 | }) |
| 3435 | tests = append(tests, testCase{ |
| 3436 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3437 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3438 | config: Config{ |
| 3439 | MaxVersion: VersionTLS12, |
| 3440 | ClientAuth: RequestClientCert, |
| 3441 | }, |
| 3442 | flags: []string{"-use-old-client-cert-callback"}, |
| 3443 | }) |
| 3444 | tests = append(tests, testCase{ |
| 3445 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3446 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3447 | config: Config{ |
| 3448 | MaxVersion: VersionTLS13, |
| 3449 | ClientAuth: RequestClientCert, |
| 3450 | }, |
| 3451 | flags: []string{"-use-old-client-cert-callback"}, |
| 3452 | }) |
| 3453 | tests = append(tests, testCase{ |
| 3454 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3455 | name: "ClientAuth-OldCallback", |
| 3456 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3457 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3458 | ClientAuth: RequireAnyClientCert, |
| 3459 | }, |
| 3460 | flags: []string{ |
| 3461 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3462 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3463 | "-use-old-client-cert-callback", |
| 3464 | }, |
| 3465 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3466 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3467 | testType: clientTest, |
| 3468 | name: "ClientAuth-OldCallback-TLS13", |
| 3469 | config: Config{ |
| 3470 | MaxVersion: VersionTLS13, |
| 3471 | ClientAuth: RequireAnyClientCert, |
| 3472 | }, |
| 3473 | flags: []string{ |
| 3474 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3475 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3476 | "-use-old-client-cert-callback", |
| 3477 | }, |
| 3478 | }) |
| 3479 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3480 | testType: serverTest, |
| 3481 | name: "ClientAuth-Server", |
| 3482 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3483 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3484 | Certificates: []Certificate{rsaCertificate}, |
| 3485 | }, |
| 3486 | flags: []string{"-require-any-client-certificate"}, |
| 3487 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3488 | tests = append(tests, testCase{ |
| 3489 | testType: serverTest, |
| 3490 | name: "ClientAuth-Server-TLS13", |
| 3491 | config: Config{ |
| 3492 | MaxVersion: VersionTLS13, |
| 3493 | Certificates: []Certificate{rsaCertificate}, |
| 3494 | }, |
| 3495 | flags: []string{"-require-any-client-certificate"}, |
| 3496 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3497 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3498 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3499 | tests = append(tests, testCase{ |
| 3500 | testType: serverTest, |
| 3501 | name: "Basic-Server-RSA", |
| 3502 | config: Config{ |
| 3503 | MaxVersion: VersionTLS12, |
| 3504 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3505 | }, |
| 3506 | flags: []string{ |
| 3507 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3508 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3509 | }, |
| 3510 | }) |
| 3511 | tests = append(tests, testCase{ |
| 3512 | testType: serverTest, |
| 3513 | name: "Basic-Server-ECDHE-RSA", |
| 3514 | config: Config{ |
| 3515 | MaxVersion: VersionTLS12, |
| 3516 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3517 | }, |
| 3518 | flags: []string{ |
| 3519 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3520 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3521 | }, |
| 3522 | }) |
| 3523 | tests = append(tests, testCase{ |
| 3524 | testType: serverTest, |
| 3525 | name: "Basic-Server-ECDHE-ECDSA", |
| 3526 | config: Config{ |
| 3527 | MaxVersion: VersionTLS12, |
| 3528 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3529 | }, |
| 3530 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3531 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3532 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3533 | }, |
| 3534 | }) |
| 3535 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3536 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3537 | tests = append(tests, testCase{ |
| 3538 | name: "SessionTicketsDisabled-Client", |
| 3539 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3540 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3541 | SessionTicketsDisabled: true, |
| 3542 | }, |
| 3543 | }) |
| 3544 | tests = append(tests, testCase{ |
| 3545 | testType: serverTest, |
| 3546 | name: "SessionTicketsDisabled-Server", |
| 3547 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3548 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3549 | SessionTicketsDisabled: true, |
| 3550 | }, |
| 3551 | }) |
| 3552 | |
| 3553 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3554 | // identity hint. |
| 3555 | tests = append(tests, testCase{ |
| 3556 | name: "EmptyPSKHint-Client", |
| 3557 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3558 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3559 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3560 | PreSharedKey: []byte("secret"), |
| 3561 | }, |
| 3562 | flags: []string{"-psk", "secret"}, |
| 3563 | }) |
| 3564 | tests = append(tests, testCase{ |
| 3565 | testType: serverTest, |
| 3566 | name: "EmptyPSKHint-Server", |
| 3567 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3568 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3569 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3570 | PreSharedKey: []byte("secret"), |
| 3571 | }, |
| 3572 | flags: []string{"-psk", "secret"}, |
| 3573 | }) |
| 3574 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3575 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3576 | tests = append(tests, testCase{ |
| 3577 | testType: clientTest, |
| 3578 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3579 | config: Config{ |
| 3580 | MaxVersion: VersionTLS12, |
| 3581 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3582 | flags: []string{ |
| 3583 | "-enable-ocsp-stapling", |
| 3584 | "-expect-ocsp-response", |
| 3585 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3586 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3587 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3588 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3589 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3590 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3591 | testType: serverTest, |
| 3592 | name: "OCSPStapling-Server", |
| 3593 | config: Config{ |
| 3594 | MaxVersion: VersionTLS12, |
| 3595 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3596 | expectedOCSPResponse: testOCSPResponse, |
| 3597 | flags: []string{ |
| 3598 | "-ocsp-response", |
| 3599 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3600 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3601 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3602 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3603 | tests = append(tests, testCase{ |
| 3604 | testType: clientTest, |
| 3605 | name: "OCSPStapling-Client-TLS13", |
| 3606 | config: Config{ |
| 3607 | MaxVersion: VersionTLS13, |
| 3608 | }, |
| 3609 | flags: []string{ |
| 3610 | "-enable-ocsp-stapling", |
| 3611 | "-expect-ocsp-response", |
| 3612 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3613 | "-verify-peer", |
| 3614 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3615 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3616 | }) |
| 3617 | tests = append(tests, testCase{ |
| 3618 | testType: serverTest, |
| 3619 | name: "OCSPStapling-Server-TLS13", |
| 3620 | config: Config{ |
| 3621 | MaxVersion: VersionTLS13, |
| 3622 | }, |
| 3623 | expectedOCSPResponse: testOCSPResponse, |
| 3624 | flags: []string{ |
| 3625 | "-ocsp-response", |
| 3626 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3627 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3628 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3629 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3630 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3631 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3632 | for _, vers := range tlsVersions { |
| 3633 | if config.protocol == dtls && !vers.hasDTLS { |
| 3634 | continue |
| 3635 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3636 | for _, testType := range []testType{clientTest, serverTest} { |
| 3637 | suffix := "-Client" |
| 3638 | if testType == serverTest { |
| 3639 | suffix = "-Server" |
| 3640 | } |
| 3641 | suffix += "-" + vers.name |
| 3642 | |
| 3643 | flag := "-verify-peer" |
| 3644 | if testType == serverTest { |
| 3645 | flag = "-require-any-client-certificate" |
| 3646 | } |
| 3647 | |
| 3648 | tests = append(tests, testCase{ |
| 3649 | testType: testType, |
| 3650 | name: "CertificateVerificationSucceed" + suffix, |
| 3651 | config: Config{ |
| 3652 | MaxVersion: vers.version, |
| 3653 | Certificates: []Certificate{rsaCertificate}, |
| 3654 | }, |
| 3655 | flags: []string{ |
| 3656 | flag, |
| 3657 | "-expect-verify-result", |
| 3658 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3659 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3660 | }) |
| 3661 | tests = append(tests, testCase{ |
| 3662 | testType: testType, |
| 3663 | name: "CertificateVerificationFail" + suffix, |
| 3664 | config: Config{ |
| 3665 | MaxVersion: vers.version, |
| 3666 | Certificates: []Certificate{rsaCertificate}, |
| 3667 | }, |
| 3668 | flags: []string{ |
| 3669 | flag, |
| 3670 | "-verify-fail", |
| 3671 | }, |
| 3672 | shouldFail: true, |
| 3673 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3674 | }) |
| 3675 | } |
| 3676 | |
| 3677 | // By default, the client is in a soft fail mode where the peer |
| 3678 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3679 | tests = append(tests, testCase{ |
| 3680 | testType: clientTest, |
| 3681 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3682 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3683 | MaxVersion: vers.version, |
| 3684 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3685 | }, |
| 3686 | flags: []string{ |
| 3687 | "-verify-fail", |
| 3688 | "-expect-verify-result", |
| 3689 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3690 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3691 | }) |
| 3692 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3693 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3694 | tests = append(tests, testCase{ |
| 3695 | name: "ShimSendAlert", |
| 3696 | flags: []string{"-send-alert"}, |
| 3697 | shimWritesFirst: true, |
| 3698 | shouldFail: true, |
| 3699 | expectedLocalError: "remote error: decompression failure", |
| 3700 | }) |
| 3701 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3702 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3703 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3704 | name: "Renegotiate-Client", |
| 3705 | config: Config{ |
| 3706 | MaxVersion: VersionTLS12, |
| 3707 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3708 | renegotiate: 1, |
| 3709 | flags: []string{ |
| 3710 | "-renegotiate-freely", |
| 3711 | "-expect-total-renegotiations", "1", |
| 3712 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3713 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3714 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3715 | tests = append(tests, testCase{ |
| 3716 | name: "SendHalfHelloRequest", |
| 3717 | config: Config{ |
| 3718 | MaxVersion: VersionTLS12, |
| 3719 | Bugs: ProtocolBugs{ |
| 3720 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3721 | }, |
| 3722 | }, |
| 3723 | sendHalfHelloRequest: true, |
| 3724 | flags: []string{"-renegotiate-ignore"}, |
| 3725 | shouldFail: true, |
| 3726 | expectedError: ":UNEXPECTED_RECORD:", |
| 3727 | }) |
| 3728 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3729 | // NPN on client and server; results in post-handshake message. |
| 3730 | tests = append(tests, testCase{ |
| 3731 | name: "NPN-Client", |
| 3732 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3733 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3734 | NextProtos: []string{"foo"}, |
| 3735 | }, |
| 3736 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3737 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3738 | expectedNextProto: "foo", |
| 3739 | expectedNextProtoType: npn, |
| 3740 | }) |
| 3741 | tests = append(tests, testCase{ |
| 3742 | testType: serverTest, |
| 3743 | name: "NPN-Server", |
| 3744 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3745 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3746 | NextProtos: []string{"bar"}, |
| 3747 | }, |
| 3748 | flags: []string{ |
| 3749 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3750 | "-expect-next-proto", "bar", |
| 3751 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3752 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3753 | expectedNextProto: "bar", |
| 3754 | expectedNextProtoType: npn, |
| 3755 | }) |
| 3756 | |
| 3757 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 3758 | |
| 3759 | // Client does False Start and negotiates NPN. |
| 3760 | tests = append(tests, testCase{ |
| 3761 | name: "FalseStart", |
| 3762 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3763 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3764 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3765 | NextProtos: []string{"foo"}, |
| 3766 | Bugs: ProtocolBugs{ |
| 3767 | ExpectFalseStart: true, |
| 3768 | }, |
| 3769 | }, |
| 3770 | flags: []string{ |
| 3771 | "-false-start", |
| 3772 | "-select-next-proto", "foo", |
| 3773 | }, |
| 3774 | shimWritesFirst: true, |
| 3775 | resumeSession: true, |
| 3776 | }) |
| 3777 | |
| 3778 | // Client does False Start and negotiates ALPN. |
| 3779 | tests = append(tests, testCase{ |
| 3780 | name: "FalseStart-ALPN", |
| 3781 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3782 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3783 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3784 | NextProtos: []string{"foo"}, |
| 3785 | Bugs: ProtocolBugs{ |
| 3786 | ExpectFalseStart: true, |
| 3787 | }, |
| 3788 | }, |
| 3789 | flags: []string{ |
| 3790 | "-false-start", |
| 3791 | "-advertise-alpn", "\x03foo", |
| 3792 | }, |
| 3793 | shimWritesFirst: true, |
| 3794 | resumeSession: true, |
| 3795 | }) |
| 3796 | |
| 3797 | // Client does False Start but doesn't explicitly call |
| 3798 | // SSL_connect. |
| 3799 | tests = append(tests, testCase{ |
| 3800 | name: "FalseStart-Implicit", |
| 3801 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3802 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3803 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3804 | NextProtos: []string{"foo"}, |
| 3805 | }, |
| 3806 | flags: []string{ |
| 3807 | "-implicit-handshake", |
| 3808 | "-false-start", |
| 3809 | "-advertise-alpn", "\x03foo", |
| 3810 | }, |
| 3811 | }) |
| 3812 | |
| 3813 | // False Start without session tickets. |
| 3814 | tests = append(tests, testCase{ |
| 3815 | name: "FalseStart-SessionTicketsDisabled", |
| 3816 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3817 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3818 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3819 | NextProtos: []string{"foo"}, |
| 3820 | SessionTicketsDisabled: true, |
| 3821 | Bugs: ProtocolBugs{ |
| 3822 | ExpectFalseStart: true, |
| 3823 | }, |
| 3824 | }, |
| 3825 | flags: []string{ |
| 3826 | "-false-start", |
| 3827 | "-select-next-proto", "foo", |
| 3828 | }, |
| 3829 | shimWritesFirst: true, |
| 3830 | }) |
| 3831 | |
Adam Langley | df759b5 | 2016-07-11 15:24:37 -0700 | [diff] [blame] | 3832 | tests = append(tests, testCase{ |
| 3833 | name: "FalseStart-CECPQ1", |
| 3834 | config: Config{ |
| 3835 | MaxVersion: VersionTLS12, |
| 3836 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 3837 | NextProtos: []string{"foo"}, |
| 3838 | Bugs: ProtocolBugs{ |
| 3839 | ExpectFalseStart: true, |
| 3840 | }, |
| 3841 | }, |
| 3842 | flags: []string{ |
| 3843 | "-false-start", |
| 3844 | "-cipher", "DEFAULT:kCECPQ1", |
| 3845 | "-select-next-proto", "foo", |
| 3846 | }, |
| 3847 | shimWritesFirst: true, |
| 3848 | resumeSession: true, |
| 3849 | }) |
| 3850 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3851 | // Server parses a V2ClientHello. |
| 3852 | tests = append(tests, testCase{ |
| 3853 | testType: serverTest, |
| 3854 | name: "SendV2ClientHello", |
| 3855 | config: Config{ |
| 3856 | // Choose a cipher suite that does not involve |
| 3857 | // elliptic curves, so no extensions are |
| 3858 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3859 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 3860 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3861 | Bugs: ProtocolBugs{ |
| 3862 | SendV2ClientHello: true, |
| 3863 | }, |
| 3864 | }, |
| 3865 | }) |
| 3866 | |
| 3867 | // Client sends a Channel ID. |
| 3868 | tests = append(tests, testCase{ |
| 3869 | name: "ChannelID-Client", |
| 3870 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3871 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3872 | RequestChannelID: true, |
| 3873 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3874 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3875 | resumeSession: true, |
| 3876 | expectChannelID: true, |
| 3877 | }) |
| 3878 | |
| 3879 | // Server accepts a Channel ID. |
| 3880 | tests = append(tests, testCase{ |
| 3881 | testType: serverTest, |
| 3882 | name: "ChannelID-Server", |
| 3883 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3884 | MaxVersion: VersionTLS12, |
| 3885 | ChannelID: channelIDKey, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3886 | }, |
| 3887 | flags: []string{ |
| 3888 | "-expect-channel-id", |
| 3889 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3890 | }, |
| 3891 | resumeSession: true, |
| 3892 | expectChannelID: true, |
| 3893 | }) |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3894 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3895 | // Channel ID and NPN at the same time, to ensure their relative |
| 3896 | // ordering is correct. |
| 3897 | tests = append(tests, testCase{ |
| 3898 | name: "ChannelID-NPN-Client", |
| 3899 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3900 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3901 | RequestChannelID: true, |
| 3902 | NextProtos: []string{"foo"}, |
| 3903 | }, |
| 3904 | flags: []string{ |
| 3905 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 3906 | "-select-next-proto", "foo", |
| 3907 | }, |
| 3908 | resumeSession: true, |
| 3909 | expectChannelID: true, |
| 3910 | expectedNextProto: "foo", |
| 3911 | expectedNextProtoType: npn, |
| 3912 | }) |
| 3913 | tests = append(tests, testCase{ |
| 3914 | testType: serverTest, |
| 3915 | name: "ChannelID-NPN-Server", |
| 3916 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3917 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 3918 | ChannelID: channelIDKey, |
| 3919 | NextProtos: []string{"bar"}, |
| 3920 | }, |
| 3921 | flags: []string{ |
| 3922 | "-expect-channel-id", |
| 3923 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 3924 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 3925 | "-expect-next-proto", "bar", |
| 3926 | }, |
| 3927 | resumeSession: true, |
| 3928 | expectChannelID: true, |
| 3929 | expectedNextProto: "bar", |
| 3930 | expectedNextProtoType: npn, |
| 3931 | }) |
| 3932 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3933 | // Bidirectional shutdown with the runner initiating. |
| 3934 | tests = append(tests, testCase{ |
| 3935 | name: "Shutdown-Runner", |
| 3936 | config: Config{ |
| 3937 | Bugs: ProtocolBugs{ |
| 3938 | ExpectCloseNotify: true, |
| 3939 | }, |
| 3940 | }, |
| 3941 | flags: []string{"-check-close-notify"}, |
| 3942 | }) |
| 3943 | |
| 3944 | // Bidirectional shutdown with the shim initiating. The runner, |
| 3945 | // in the meantime, sends garbage before the close_notify which |
| 3946 | // the shim must ignore. |
| 3947 | tests = append(tests, testCase{ |
| 3948 | name: "Shutdown-Shim", |
| 3949 | config: Config{ |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 3950 | MaxVersion: VersionTLS12, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 3951 | Bugs: ProtocolBugs{ |
| 3952 | ExpectCloseNotify: true, |
| 3953 | }, |
| 3954 | }, |
| 3955 | shimShutsDown: true, |
| 3956 | sendEmptyRecords: 1, |
| 3957 | sendWarningAlerts: 1, |
| 3958 | flags: []string{"-check-close-notify"}, |
| 3959 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3960 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3961 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 3962 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3963 | tests = append(tests, testCase{ |
| 3964 | name: "SkipHelloVerifyRequest", |
| 3965 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3966 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3967 | Bugs: ProtocolBugs{ |
| 3968 | SkipHelloVerifyRequest: true, |
| 3969 | }, |
| 3970 | }, |
| 3971 | }) |
| 3972 | } |
| 3973 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3974 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3975 | test.protocol = config.protocol |
| 3976 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3977 | test.name += "-DTLS" |
| 3978 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3979 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3980 | test.name += "-Async" |
| 3981 | test.flags = append(test.flags, "-async") |
| 3982 | } else { |
| 3983 | test.name += "-Sync" |
| 3984 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3985 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3986 | test.name += "-SplitHandshakeRecords" |
| 3987 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3988 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 3989 | test.config.Bugs.MaxPacketLength = 256 |
| 3990 | test.flags = append(test.flags, "-mtu", "256") |
| 3991 | } |
| 3992 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3993 | if config.packHandshakeFlight { |
| 3994 | test.name += "-PackHandshakeFlight" |
| 3995 | test.config.Bugs.PackHandshakeFlight = true |
| 3996 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3997 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 3998 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3999 | } |
| 4000 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4001 | func addDDoSCallbackTests() { |
| 4002 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4003 | for _, resume := range []bool{false, true} { |
| 4004 | suffix := "Resume" |
| 4005 | if resume { |
| 4006 | suffix = "No" + suffix |
| 4007 | } |
| 4008 | |
| 4009 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4010 | testType: serverTest, |
| 4011 | name: "Server-DDoS-OK-" + suffix, |
| 4012 | config: Config{ |
| 4013 | MaxVersion: VersionTLS12, |
| 4014 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4015 | flags: []string{"-install-ddos-callback"}, |
| 4016 | resumeSession: resume, |
| 4017 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4018 | testCases = append(testCases, testCase{ |
| 4019 | testType: serverTest, |
| 4020 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4021 | config: Config{ |
| 4022 | MaxVersion: VersionTLS13, |
| 4023 | }, |
| 4024 | flags: []string{"-install-ddos-callback"}, |
| 4025 | resumeSession: resume, |
| 4026 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4027 | |
| 4028 | failFlag := "-fail-ddos-callback" |
| 4029 | if resume { |
| 4030 | failFlag = "-fail-second-ddos-callback" |
| 4031 | } |
| 4032 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4033 | testType: serverTest, |
| 4034 | name: "Server-DDoS-Reject-" + suffix, |
| 4035 | config: Config{ |
| 4036 | MaxVersion: VersionTLS12, |
| 4037 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4038 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4039 | resumeSession: resume, |
| 4040 | shouldFail: true, |
| 4041 | expectedError: ":CONNECTION_REJECTED:", |
| 4042 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4043 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4044 | testCases = append(testCases, testCase{ |
| 4045 | testType: serverTest, |
| 4046 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4047 | config: Config{ |
| 4048 | MaxVersion: VersionTLS13, |
| 4049 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4050 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4051 | resumeSession: resume, |
| 4052 | shouldFail: true, |
| 4053 | expectedError: ":CONNECTION_REJECTED:", |
| 4054 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4055 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4056 | } |
| 4057 | } |
| 4058 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4059 | func addVersionNegotiationTests() { |
| 4060 | for i, shimVers := range tlsVersions { |
| 4061 | // Assemble flags to disable all newer versions on the shim. |
| 4062 | var flags []string |
| 4063 | for _, vers := range tlsVersions[i+1:] { |
| 4064 | flags = append(flags, vers.flag) |
| 4065 | } |
| 4066 | |
| 4067 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4068 | protocols := []protocol{tls} |
| 4069 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4070 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4071 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4072 | for _, protocol := range protocols { |
| 4073 | expectedVersion := shimVers.version |
| 4074 | if runnerVers.version < shimVers.version { |
| 4075 | expectedVersion = runnerVers.version |
| 4076 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4077 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4078 | suffix := shimVers.name + "-" + runnerVers.name |
| 4079 | if protocol == dtls { |
| 4080 | suffix += "-DTLS" |
| 4081 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4082 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4083 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4084 | |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4085 | clientVers := shimVers.version |
| 4086 | if clientVers > VersionTLS10 { |
| 4087 | clientVers = VersionTLS10 |
| 4088 | } |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4089 | serverVers := expectedVersion |
| 4090 | if expectedVersion >= VersionTLS13 { |
| 4091 | serverVers = VersionTLS10 |
| 4092 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4093 | testCases = append(testCases, testCase{ |
| 4094 | protocol: protocol, |
| 4095 | testType: clientTest, |
| 4096 | name: "VersionNegotiation-Client-" + suffix, |
| 4097 | config: Config{ |
| 4098 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4099 | Bugs: ProtocolBugs{ |
| 4100 | ExpectInitialRecordVersion: clientVers, |
| 4101 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4102 | }, |
| 4103 | flags: flags, |
| 4104 | expectedVersion: expectedVersion, |
| 4105 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4106 | testCases = append(testCases, testCase{ |
| 4107 | protocol: protocol, |
| 4108 | testType: clientTest, |
| 4109 | name: "VersionNegotiation-Client2-" + suffix, |
| 4110 | config: Config{ |
| 4111 | MaxVersion: runnerVers.version, |
| 4112 | Bugs: ProtocolBugs{ |
| 4113 | ExpectInitialRecordVersion: clientVers, |
| 4114 | }, |
| 4115 | }, |
| 4116 | flags: []string{"-max-version", shimVersFlag}, |
| 4117 | expectedVersion: expectedVersion, |
| 4118 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4119 | |
| 4120 | testCases = append(testCases, testCase{ |
| 4121 | protocol: protocol, |
| 4122 | testType: serverTest, |
| 4123 | name: "VersionNegotiation-Server-" + suffix, |
| 4124 | config: Config{ |
| 4125 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4126 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4127 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4128 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4129 | }, |
| 4130 | flags: flags, |
| 4131 | expectedVersion: expectedVersion, |
| 4132 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4133 | testCases = append(testCases, testCase{ |
| 4134 | protocol: protocol, |
| 4135 | testType: serverTest, |
| 4136 | name: "VersionNegotiation-Server2-" + suffix, |
| 4137 | config: Config{ |
| 4138 | MaxVersion: runnerVers.version, |
| 4139 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4140 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4141 | }, |
| 4142 | }, |
| 4143 | flags: []string{"-max-version", shimVersFlag}, |
| 4144 | expectedVersion: expectedVersion, |
| 4145 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4146 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4147 | } |
| 4148 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4149 | |
| 4150 | // Test for version tolerance. |
| 4151 | testCases = append(testCases, testCase{ |
| 4152 | testType: serverTest, |
| 4153 | name: "MinorVersionTolerance", |
| 4154 | config: Config{ |
| 4155 | Bugs: ProtocolBugs{ |
| 4156 | SendClientVersion: 0x03ff, |
| 4157 | }, |
| 4158 | }, |
| 4159 | expectedVersion: VersionTLS13, |
| 4160 | }) |
| 4161 | testCases = append(testCases, testCase{ |
| 4162 | testType: serverTest, |
| 4163 | name: "MajorVersionTolerance", |
| 4164 | config: Config{ |
| 4165 | Bugs: ProtocolBugs{ |
| 4166 | SendClientVersion: 0x0400, |
| 4167 | }, |
| 4168 | }, |
| 4169 | expectedVersion: VersionTLS13, |
| 4170 | }) |
| 4171 | testCases = append(testCases, testCase{ |
| 4172 | protocol: dtls, |
| 4173 | testType: serverTest, |
| 4174 | name: "MinorVersionTolerance-DTLS", |
| 4175 | config: Config{ |
| 4176 | Bugs: ProtocolBugs{ |
| 4177 | SendClientVersion: 0x03ff, |
| 4178 | }, |
| 4179 | }, |
| 4180 | expectedVersion: VersionTLS12, |
| 4181 | }) |
| 4182 | testCases = append(testCases, testCase{ |
| 4183 | protocol: dtls, |
| 4184 | testType: serverTest, |
| 4185 | name: "MajorVersionTolerance-DTLS", |
| 4186 | config: Config{ |
| 4187 | Bugs: ProtocolBugs{ |
| 4188 | SendClientVersion: 0x0400, |
| 4189 | }, |
| 4190 | }, |
| 4191 | expectedVersion: VersionTLS12, |
| 4192 | }) |
| 4193 | |
| 4194 | // Test that versions below 3.0 are rejected. |
| 4195 | testCases = append(testCases, testCase{ |
| 4196 | testType: serverTest, |
| 4197 | name: "VersionTooLow", |
| 4198 | config: Config{ |
| 4199 | Bugs: ProtocolBugs{ |
| 4200 | SendClientVersion: 0x0200, |
| 4201 | }, |
| 4202 | }, |
| 4203 | shouldFail: true, |
| 4204 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4205 | }) |
| 4206 | testCases = append(testCases, testCase{ |
| 4207 | protocol: dtls, |
| 4208 | testType: serverTest, |
| 4209 | name: "VersionTooLow-DTLS", |
| 4210 | config: Config{ |
| 4211 | Bugs: ProtocolBugs{ |
| 4212 | // 0x0201 is the lowest version expressable in |
| 4213 | // DTLS. |
| 4214 | SendClientVersion: 0x0201, |
| 4215 | }, |
| 4216 | }, |
| 4217 | shouldFail: true, |
| 4218 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4219 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4220 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4221 | testCases = append(testCases, testCase{ |
| 4222 | name: "ServerBogusVersion", |
| 4223 | config: Config{ |
| 4224 | Bugs: ProtocolBugs{ |
| 4225 | SendServerHelloVersion: 0x1234, |
| 4226 | }, |
| 4227 | }, |
| 4228 | shouldFail: true, |
| 4229 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4230 | }) |
| 4231 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4232 | // Test TLS 1.3's downgrade signal. |
| 4233 | testCases = append(testCases, testCase{ |
| 4234 | name: "Downgrade-TLS12-Client", |
| 4235 | config: Config{ |
| 4236 | Bugs: ProtocolBugs{ |
| 4237 | NegotiateVersion: VersionTLS12, |
| 4238 | }, |
| 4239 | }, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4240 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4241 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4242 | }) |
| 4243 | testCases = append(testCases, testCase{ |
| 4244 | testType: serverTest, |
| 4245 | name: "Downgrade-TLS12-Server", |
| 4246 | config: Config{ |
| 4247 | Bugs: ProtocolBugs{ |
| 4248 | SendClientVersion: VersionTLS12, |
| 4249 | }, |
| 4250 | }, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4251 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4252 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4253 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4254 | } |
| 4255 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4256 | func addMinimumVersionTests() { |
| 4257 | for i, shimVers := range tlsVersions { |
| 4258 | // Assemble flags to disable all older versions on the shim. |
| 4259 | var flags []string |
| 4260 | for _, vers := range tlsVersions[:i] { |
| 4261 | flags = append(flags, vers.flag) |
| 4262 | } |
| 4263 | |
| 4264 | for _, runnerVers := range tlsVersions { |
| 4265 | protocols := []protocol{tls} |
| 4266 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4267 | protocols = append(protocols, dtls) |
| 4268 | } |
| 4269 | for _, protocol := range protocols { |
| 4270 | suffix := shimVers.name + "-" + runnerVers.name |
| 4271 | if protocol == dtls { |
| 4272 | suffix += "-DTLS" |
| 4273 | } |
| 4274 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4275 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4276 | var expectedVersion uint16 |
| 4277 | var shouldFail bool |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4278 | var expectedClientError, expectedServerError string |
| 4279 | var expectedClientLocalError, expectedServerLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4280 | if runnerVers.version >= shimVers.version { |
| 4281 | expectedVersion = runnerVers.version |
| 4282 | } else { |
| 4283 | shouldFail = true |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4284 | expectedServerError = ":UNSUPPORTED_PROTOCOL:" |
| 4285 | expectedServerLocalError = "remote error: protocol version not supported" |
| 4286 | if shimVers.version >= VersionTLS13 && runnerVers.version <= VersionTLS11 { |
| 4287 | // If the client's minimum version is TLS 1.3 and the runner's |
| 4288 | // maximum is below TLS 1.2, the runner will fail to select a |
| 4289 | // cipher before the shim rejects the selected version. |
| 4290 | expectedClientError = ":SSLV3_ALERT_HANDSHAKE_FAILURE:" |
| 4291 | expectedClientLocalError = "tls: no cipher suite supported by both client and server" |
| 4292 | } else { |
| 4293 | expectedClientError = expectedServerError |
| 4294 | expectedClientLocalError = expectedServerLocalError |
| 4295 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | testCases = append(testCases, testCase{ |
| 4299 | protocol: protocol, |
| 4300 | testType: clientTest, |
| 4301 | name: "MinimumVersion-Client-" + suffix, |
| 4302 | config: Config{ |
| 4303 | MaxVersion: runnerVers.version, |
| 4304 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4305 | flags: flags, |
| 4306 | expectedVersion: expectedVersion, |
| 4307 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4308 | expectedError: expectedClientError, |
| 4309 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4310 | }) |
| 4311 | testCases = append(testCases, testCase{ |
| 4312 | protocol: protocol, |
| 4313 | testType: clientTest, |
| 4314 | name: "MinimumVersion-Client2-" + suffix, |
| 4315 | config: Config{ |
| 4316 | MaxVersion: runnerVers.version, |
| 4317 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4318 | flags: []string{"-min-version", shimVersFlag}, |
| 4319 | expectedVersion: expectedVersion, |
| 4320 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4321 | expectedError: expectedClientError, |
| 4322 | expectedLocalError: expectedClientLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4323 | }) |
| 4324 | |
| 4325 | testCases = append(testCases, testCase{ |
| 4326 | protocol: protocol, |
| 4327 | testType: serverTest, |
| 4328 | name: "MinimumVersion-Server-" + suffix, |
| 4329 | config: Config{ |
| 4330 | MaxVersion: runnerVers.version, |
| 4331 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4332 | flags: flags, |
| 4333 | expectedVersion: expectedVersion, |
| 4334 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4335 | expectedError: expectedServerError, |
| 4336 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4337 | }) |
| 4338 | testCases = append(testCases, testCase{ |
| 4339 | protocol: protocol, |
| 4340 | testType: serverTest, |
| 4341 | name: "MinimumVersion-Server2-" + suffix, |
| 4342 | config: Config{ |
| 4343 | MaxVersion: runnerVers.version, |
| 4344 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4345 | flags: []string{"-min-version", shimVersFlag}, |
| 4346 | expectedVersion: expectedVersion, |
| 4347 | shouldFail: shouldFail, |
David Benjamin | 929d4ee | 2016-06-24 23:55:58 -0400 | [diff] [blame] | 4348 | expectedError: expectedServerError, |
| 4349 | expectedLocalError: expectedServerLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4350 | }) |
| 4351 | } |
| 4352 | } |
| 4353 | } |
| 4354 | } |
| 4355 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4356 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4357 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4358 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4359 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4360 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4361 | // Repeat extensions tests all versions except SSL 3.0. |
| 4362 | for _, ver := range tlsVersions { |
| 4363 | if ver.version == VersionSSL30 { |
| 4364 | continue |
| 4365 | } |
| 4366 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4367 | // Test that duplicate extensions are rejected. |
| 4368 | testCases = append(testCases, testCase{ |
| 4369 | testType: clientTest, |
| 4370 | name: "DuplicateExtensionClient-" + ver.name, |
| 4371 | config: Config{ |
| 4372 | MaxVersion: ver.version, |
| 4373 | Bugs: ProtocolBugs{ |
| 4374 | DuplicateExtension: true, |
| 4375 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4376 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4377 | shouldFail: true, |
| 4378 | expectedLocalError: "remote error: error decoding message", |
| 4379 | }) |
| 4380 | testCases = append(testCases, testCase{ |
| 4381 | testType: serverTest, |
| 4382 | name: "DuplicateExtensionServer-" + ver.name, |
| 4383 | config: Config{ |
| 4384 | MaxVersion: ver.version, |
| 4385 | Bugs: ProtocolBugs{ |
| 4386 | DuplicateExtension: true, |
| 4387 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4388 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4389 | shouldFail: true, |
| 4390 | expectedLocalError: "remote error: error decoding message", |
| 4391 | }) |
| 4392 | |
| 4393 | // Test SNI. |
| 4394 | testCases = append(testCases, testCase{ |
| 4395 | testType: clientTest, |
| 4396 | name: "ServerNameExtensionClient-" + ver.name, |
| 4397 | config: Config{ |
| 4398 | MaxVersion: ver.version, |
| 4399 | Bugs: ProtocolBugs{ |
| 4400 | ExpectServerName: "example.com", |
| 4401 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4402 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4403 | flags: []string{"-host-name", "example.com"}, |
| 4404 | }) |
| 4405 | testCases = append(testCases, testCase{ |
| 4406 | testType: clientTest, |
| 4407 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4408 | config: Config{ |
| 4409 | MaxVersion: ver.version, |
| 4410 | Bugs: ProtocolBugs{ |
| 4411 | ExpectServerName: "mismatch.com", |
| 4412 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4413 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4414 | flags: []string{"-host-name", "example.com"}, |
| 4415 | shouldFail: true, |
| 4416 | expectedLocalError: "tls: unexpected server name", |
| 4417 | }) |
| 4418 | testCases = append(testCases, testCase{ |
| 4419 | testType: clientTest, |
| 4420 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4421 | config: Config{ |
| 4422 | MaxVersion: ver.version, |
| 4423 | Bugs: ProtocolBugs{ |
| 4424 | ExpectServerName: "missing.com", |
| 4425 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4426 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4427 | shouldFail: true, |
| 4428 | expectedLocalError: "tls: unexpected server name", |
| 4429 | }) |
| 4430 | testCases = append(testCases, testCase{ |
| 4431 | testType: serverTest, |
| 4432 | name: "ServerNameExtensionServer-" + ver.name, |
| 4433 | config: Config{ |
| 4434 | MaxVersion: ver.version, |
| 4435 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4436 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4437 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4438 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4439 | }) |
| 4440 | |
| 4441 | // Test ALPN. |
| 4442 | testCases = append(testCases, testCase{ |
| 4443 | testType: clientTest, |
| 4444 | name: "ALPNClient-" + ver.name, |
| 4445 | config: Config{ |
| 4446 | MaxVersion: ver.version, |
| 4447 | NextProtos: []string{"foo"}, |
| 4448 | }, |
| 4449 | flags: []string{ |
| 4450 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4451 | "-expect-alpn", "foo", |
| 4452 | }, |
| 4453 | expectedNextProto: "foo", |
| 4454 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4455 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4456 | }) |
| 4457 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4458 | testType: clientTest, |
| 4459 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4460 | config: Config{ |
| 4461 | MaxVersion: ver.version, |
| 4462 | Bugs: ProtocolBugs{ |
| 4463 | SendALPN: "baz", |
| 4464 | }, |
| 4465 | }, |
| 4466 | flags: []string{ |
| 4467 | "-advertise-alpn", "\x03foo\x03bar", |
| 4468 | }, |
| 4469 | shouldFail: true, |
| 4470 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4471 | expectedLocalError: "remote error: illegal parameter", |
| 4472 | }) |
| 4473 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4474 | testType: serverTest, |
| 4475 | name: "ALPNServer-" + ver.name, |
| 4476 | config: Config{ |
| 4477 | MaxVersion: ver.version, |
| 4478 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4479 | }, |
| 4480 | flags: []string{ |
| 4481 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4482 | "-select-alpn", "foo", |
| 4483 | }, |
| 4484 | expectedNextProto: "foo", |
| 4485 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4486 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4487 | }) |
| 4488 | testCases = append(testCases, testCase{ |
| 4489 | testType: serverTest, |
| 4490 | name: "ALPNServer-Decline-" + ver.name, |
| 4491 | config: Config{ |
| 4492 | MaxVersion: ver.version, |
| 4493 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4494 | }, |
| 4495 | flags: []string{"-decline-alpn"}, |
| 4496 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4497 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4498 | }) |
| 4499 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4500 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4501 | // called once. |
| 4502 | testCases = append(testCases, testCase{ |
| 4503 | testType: serverTest, |
| 4504 | name: "ALPNServer-Async-" + ver.name, |
| 4505 | config: Config{ |
| 4506 | MaxVersion: ver.version, |
| 4507 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4508 | }, |
| 4509 | flags: []string{ |
| 4510 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4511 | "-select-alpn", "foo", |
| 4512 | "-async", |
| 4513 | }, |
| 4514 | expectedNextProto: "foo", |
| 4515 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4516 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4517 | }) |
| 4518 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4519 | var emptyString string |
| 4520 | testCases = append(testCases, testCase{ |
| 4521 | testType: clientTest, |
| 4522 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4523 | config: Config{ |
| 4524 | MaxVersion: ver.version, |
| 4525 | NextProtos: []string{""}, |
| 4526 | Bugs: ProtocolBugs{ |
| 4527 | // A server returning an empty ALPN protocol |
| 4528 | // should be rejected. |
| 4529 | ALPNProtocol: &emptyString, |
| 4530 | }, |
| 4531 | }, |
| 4532 | flags: []string{ |
| 4533 | "-advertise-alpn", "\x03foo", |
| 4534 | }, |
| 4535 | shouldFail: true, |
| 4536 | expectedError: ":PARSE_TLSEXT:", |
| 4537 | }) |
| 4538 | testCases = append(testCases, testCase{ |
| 4539 | testType: serverTest, |
| 4540 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4541 | config: Config{ |
| 4542 | MaxVersion: ver.version, |
| 4543 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4544 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4545 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4546 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4547 | flags: []string{ |
| 4548 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4549 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4550 | shouldFail: true, |
| 4551 | expectedError: ":PARSE_TLSEXT:", |
| 4552 | }) |
| 4553 | |
| 4554 | // Test NPN and the interaction with ALPN. |
| 4555 | if ver.version < VersionTLS13 { |
| 4556 | // Test that the server prefers ALPN over NPN. |
| 4557 | testCases = append(testCases, testCase{ |
| 4558 | testType: serverTest, |
| 4559 | name: "ALPNServer-Preferred-" + ver.name, |
| 4560 | config: Config{ |
| 4561 | MaxVersion: ver.version, |
| 4562 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4563 | }, |
| 4564 | flags: []string{ |
| 4565 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4566 | "-select-alpn", "foo", |
| 4567 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4568 | }, |
| 4569 | expectedNextProto: "foo", |
| 4570 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4571 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4572 | }) |
| 4573 | testCases = append(testCases, testCase{ |
| 4574 | testType: serverTest, |
| 4575 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 4576 | config: Config{ |
| 4577 | MaxVersion: ver.version, |
| 4578 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4579 | Bugs: ProtocolBugs{ |
| 4580 | SwapNPNAndALPN: true, |
| 4581 | }, |
| 4582 | }, |
| 4583 | flags: []string{ |
| 4584 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4585 | "-select-alpn", "foo", |
| 4586 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4587 | }, |
| 4588 | expectedNextProto: "foo", |
| 4589 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4590 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4591 | }) |
| 4592 | |
| 4593 | // Test that negotiating both NPN and ALPN is forbidden. |
| 4594 | testCases = append(testCases, testCase{ |
| 4595 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 4596 | config: Config{ |
| 4597 | MaxVersion: ver.version, |
| 4598 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4599 | Bugs: ProtocolBugs{ |
| 4600 | NegotiateALPNAndNPN: true, |
| 4601 | }, |
| 4602 | }, |
| 4603 | flags: []string{ |
| 4604 | "-advertise-alpn", "\x03foo", |
| 4605 | "-select-next-proto", "foo", |
| 4606 | }, |
| 4607 | shouldFail: true, |
| 4608 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4609 | }) |
| 4610 | testCases = append(testCases, testCase{ |
| 4611 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 4612 | config: Config{ |
| 4613 | MaxVersion: ver.version, |
| 4614 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4615 | Bugs: ProtocolBugs{ |
| 4616 | NegotiateALPNAndNPN: true, |
| 4617 | SwapNPNAndALPN: true, |
| 4618 | }, |
| 4619 | }, |
| 4620 | flags: []string{ |
| 4621 | "-advertise-alpn", "\x03foo", |
| 4622 | "-select-next-proto", "foo", |
| 4623 | }, |
| 4624 | shouldFail: true, |
| 4625 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 4626 | }) |
| 4627 | |
| 4628 | // Test that NPN can be disabled with SSL_OP_DISABLE_NPN. |
| 4629 | testCases = append(testCases, testCase{ |
| 4630 | name: "DisableNPN-" + ver.name, |
| 4631 | config: Config{ |
| 4632 | MaxVersion: ver.version, |
| 4633 | NextProtos: []string{"foo"}, |
| 4634 | }, |
| 4635 | flags: []string{ |
| 4636 | "-select-next-proto", "foo", |
| 4637 | "-disable-npn", |
| 4638 | }, |
| 4639 | expectNoNextProto: true, |
| 4640 | }) |
| 4641 | } |
| 4642 | |
| 4643 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4644 | |
| 4645 | // Resume with a corrupt ticket. |
| 4646 | testCases = append(testCases, testCase{ |
| 4647 | testType: serverTest, |
| 4648 | name: "CorruptTicket-" + ver.name, |
| 4649 | config: Config{ |
| 4650 | MaxVersion: ver.version, |
| 4651 | Bugs: ProtocolBugs{ |
| 4652 | CorruptTicket: true, |
| 4653 | }, |
| 4654 | }, |
| 4655 | resumeSession: true, |
| 4656 | expectResumeRejected: true, |
| 4657 | }) |
| 4658 | // Test the ticket callback, with and without renewal. |
| 4659 | testCases = append(testCases, testCase{ |
| 4660 | testType: serverTest, |
| 4661 | name: "TicketCallback-" + ver.name, |
| 4662 | config: Config{ |
| 4663 | MaxVersion: ver.version, |
| 4664 | }, |
| 4665 | resumeSession: true, |
| 4666 | flags: []string{"-use-ticket-callback"}, |
| 4667 | }) |
| 4668 | testCases = append(testCases, testCase{ |
| 4669 | testType: serverTest, |
| 4670 | name: "TicketCallback-Renew-" + ver.name, |
| 4671 | config: Config{ |
| 4672 | MaxVersion: ver.version, |
| 4673 | Bugs: ProtocolBugs{ |
| 4674 | ExpectNewTicket: true, |
| 4675 | }, |
| 4676 | }, |
| 4677 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 4678 | resumeSession: true, |
| 4679 | }) |
| 4680 | |
| 4681 | // Test that the ticket callback is only called once when everything before |
| 4682 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 4683 | // certificate selection callbacks run. |
| 4684 | testCases = append(testCases, testCase{ |
| 4685 | testType: serverTest, |
| 4686 | name: "TicketCallback-SingleCall-" + ver.name, |
| 4687 | config: Config{ |
| 4688 | MaxVersion: ver.version, |
| 4689 | Bugs: ProtocolBugs{ |
| 4690 | CorruptTicket: true, |
| 4691 | }, |
| 4692 | }, |
| 4693 | resumeSession: true, |
| 4694 | expectResumeRejected: true, |
| 4695 | flags: []string{ |
| 4696 | "-use-ticket-callback", |
| 4697 | "-async", |
| 4698 | }, |
| 4699 | }) |
| 4700 | |
| 4701 | // Resume with an oversized session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4702 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4703 | testCases = append(testCases, testCase{ |
| 4704 | testType: serverTest, |
| 4705 | name: "OversizedSessionId-" + ver.name, |
| 4706 | config: Config{ |
| 4707 | MaxVersion: ver.version, |
| 4708 | Bugs: ProtocolBugs{ |
| 4709 | OversizedSessionId: true, |
| 4710 | }, |
| 4711 | }, |
| 4712 | resumeSession: true, |
| 4713 | shouldFail: true, |
| 4714 | expectedError: ":DECODE_ERROR:", |
| 4715 | }) |
| 4716 | } |
| 4717 | |
| 4718 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 4719 | // are ignored. |
| 4720 | if ver.hasDTLS { |
| 4721 | testCases = append(testCases, testCase{ |
| 4722 | protocol: dtls, |
| 4723 | name: "SRTP-Client-" + ver.name, |
| 4724 | config: Config{ |
| 4725 | MaxVersion: ver.version, |
| 4726 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4727 | }, |
| 4728 | flags: []string{ |
| 4729 | "-srtp-profiles", |
| 4730 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4731 | }, |
| 4732 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4733 | }) |
| 4734 | testCases = append(testCases, testCase{ |
| 4735 | protocol: dtls, |
| 4736 | testType: serverTest, |
| 4737 | name: "SRTP-Server-" + ver.name, |
| 4738 | config: Config{ |
| 4739 | MaxVersion: ver.version, |
| 4740 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 4741 | }, |
| 4742 | flags: []string{ |
| 4743 | "-srtp-profiles", |
| 4744 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4745 | }, |
| 4746 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4747 | }) |
| 4748 | // Test that the MKI is ignored. |
| 4749 | testCases = append(testCases, testCase{ |
| 4750 | protocol: dtls, |
| 4751 | testType: serverTest, |
| 4752 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 4753 | config: Config{ |
| 4754 | MaxVersion: ver.version, |
| 4755 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 4756 | Bugs: ProtocolBugs{ |
| 4757 | SRTPMasterKeyIdentifer: "bogus", |
| 4758 | }, |
| 4759 | }, |
| 4760 | flags: []string{ |
| 4761 | "-srtp-profiles", |
| 4762 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4763 | }, |
| 4764 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 4765 | }) |
| 4766 | // Test that SRTP isn't negotiated on the server if there were |
| 4767 | // no matching profiles. |
| 4768 | testCases = append(testCases, testCase{ |
| 4769 | protocol: dtls, |
| 4770 | testType: serverTest, |
| 4771 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 4772 | config: Config{ |
| 4773 | MaxVersion: ver.version, |
| 4774 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 4775 | }, |
| 4776 | flags: []string{ |
| 4777 | "-srtp-profiles", |
| 4778 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 4779 | }, |
| 4780 | expectedSRTPProtectionProfile: 0, |
| 4781 | }) |
| 4782 | // Test that the server returning an invalid SRTP profile is |
| 4783 | // flagged as an error by the client. |
| 4784 | testCases = append(testCases, testCase{ |
| 4785 | protocol: dtls, |
| 4786 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 4787 | config: Config{ |
| 4788 | MaxVersion: ver.version, |
| 4789 | Bugs: ProtocolBugs{ |
| 4790 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 4791 | }, |
| 4792 | }, |
| 4793 | flags: []string{ |
| 4794 | "-srtp-profiles", |
| 4795 | "SRTP_AES128_CM_SHA1_80", |
| 4796 | }, |
| 4797 | shouldFail: true, |
| 4798 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 4799 | }) |
| 4800 | } |
| 4801 | |
| 4802 | // Test SCT list. |
| 4803 | testCases = append(testCases, testCase{ |
| 4804 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 4805 | testType: clientTest, |
| 4806 | config: Config{ |
| 4807 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4808 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4809 | flags: []string{ |
| 4810 | "-enable-signed-cert-timestamps", |
| 4811 | "-expect-signed-cert-timestamps", |
| 4812 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4813 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4814 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4815 | }) |
| 4816 | testCases = append(testCases, testCase{ |
| 4817 | name: "SendSCTListOnResume-" + ver.name, |
| 4818 | config: Config{ |
| 4819 | MaxVersion: ver.version, |
| 4820 | Bugs: ProtocolBugs{ |
| 4821 | SendSCTListOnResume: []byte("bogus"), |
| 4822 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 4823 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4824 | flags: []string{ |
| 4825 | "-enable-signed-cert-timestamps", |
| 4826 | "-expect-signed-cert-timestamps", |
| 4827 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 4828 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4829 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4830 | }) |
| 4831 | testCases = append(testCases, testCase{ |
| 4832 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 4833 | testType: serverTest, |
| 4834 | config: Config{ |
| 4835 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4836 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4837 | flags: []string{ |
| 4838 | "-signed-cert-timestamps", |
| 4839 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 4840 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4841 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4842 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4843 | }) |
| 4844 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4845 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 4846 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 4847 | testType: clientTest, |
| 4848 | name: "ClientHelloPadding", |
| 4849 | config: Config{ |
| 4850 | Bugs: ProtocolBugs{ |
| 4851 | RequireClientHelloSize: 512, |
| 4852 | }, |
| 4853 | }, |
| 4854 | // This hostname just needs to be long enough to push the |
| 4855 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 4856 | // long. |
| 4857 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 4858 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 4859 | |
| 4860 | // Extensions should not function in SSL 3.0. |
| 4861 | testCases = append(testCases, testCase{ |
| 4862 | testType: serverTest, |
| 4863 | name: "SSLv3Extensions-NoALPN", |
| 4864 | config: Config{ |
| 4865 | MaxVersion: VersionSSL30, |
| 4866 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4867 | }, |
| 4868 | flags: []string{ |
| 4869 | "-select-alpn", "foo", |
| 4870 | }, |
| 4871 | expectNoNextProto: true, |
| 4872 | }) |
| 4873 | |
| 4874 | // Test session tickets separately as they follow a different codepath. |
| 4875 | testCases = append(testCases, testCase{ |
| 4876 | testType: serverTest, |
| 4877 | name: "SSLv3Extensions-NoTickets", |
| 4878 | config: Config{ |
| 4879 | MaxVersion: VersionSSL30, |
| 4880 | Bugs: ProtocolBugs{ |
| 4881 | // Historically, session tickets in SSL 3.0 |
| 4882 | // failed in different ways depending on whether |
| 4883 | // the client supported renegotiation_info. |
| 4884 | NoRenegotiationInfo: true, |
| 4885 | }, |
| 4886 | }, |
| 4887 | resumeSession: true, |
| 4888 | }) |
| 4889 | testCases = append(testCases, testCase{ |
| 4890 | testType: serverTest, |
| 4891 | name: "SSLv3Extensions-NoTickets2", |
| 4892 | config: Config{ |
| 4893 | MaxVersion: VersionSSL30, |
| 4894 | }, |
| 4895 | resumeSession: true, |
| 4896 | }) |
| 4897 | |
| 4898 | // But SSL 3.0 does send and process renegotiation_info. |
| 4899 | testCases = append(testCases, testCase{ |
| 4900 | testType: serverTest, |
| 4901 | name: "SSLv3Extensions-RenegotiationInfo", |
| 4902 | config: Config{ |
| 4903 | MaxVersion: VersionSSL30, |
| 4904 | Bugs: ProtocolBugs{ |
| 4905 | RequireRenegotiationInfo: true, |
| 4906 | }, |
| 4907 | }, |
| 4908 | }) |
| 4909 | testCases = append(testCases, testCase{ |
| 4910 | testType: serverTest, |
| 4911 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 4912 | config: Config{ |
| 4913 | MaxVersion: VersionSSL30, |
| 4914 | Bugs: ProtocolBugs{ |
| 4915 | NoRenegotiationInfo: true, |
| 4916 | SendRenegotiationSCSV: true, |
| 4917 | RequireRenegotiationInfo: true, |
| 4918 | }, |
| 4919 | }, |
| 4920 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4921 | |
| 4922 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 4923 | // in ServerHello. |
| 4924 | testCases = append(testCases, testCase{ |
| 4925 | name: "NPN-Forbidden-TLS13", |
| 4926 | config: Config{ |
| 4927 | MaxVersion: VersionTLS13, |
| 4928 | NextProtos: []string{"foo"}, |
| 4929 | Bugs: ProtocolBugs{ |
| 4930 | NegotiateNPNAtAllVersions: true, |
| 4931 | }, |
| 4932 | }, |
| 4933 | flags: []string{"-select-next-proto", "foo"}, |
| 4934 | shouldFail: true, |
| 4935 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4936 | }) |
| 4937 | testCases = append(testCases, testCase{ |
| 4938 | name: "EMS-Forbidden-TLS13", |
| 4939 | config: Config{ |
| 4940 | MaxVersion: VersionTLS13, |
| 4941 | Bugs: ProtocolBugs{ |
| 4942 | NegotiateEMSAtAllVersions: true, |
| 4943 | }, |
| 4944 | }, |
| 4945 | shouldFail: true, |
| 4946 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4947 | }) |
| 4948 | testCases = append(testCases, testCase{ |
| 4949 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 4950 | config: Config{ |
| 4951 | MaxVersion: VersionTLS13, |
| 4952 | Bugs: ProtocolBugs{ |
| 4953 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 4954 | }, |
| 4955 | }, |
| 4956 | shouldFail: true, |
| 4957 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4958 | }) |
| 4959 | testCases = append(testCases, testCase{ |
| 4960 | name: "ChannelID-Forbidden-TLS13", |
| 4961 | config: Config{ |
| 4962 | MaxVersion: VersionTLS13, |
| 4963 | RequestChannelID: true, |
| 4964 | Bugs: ProtocolBugs{ |
| 4965 | NegotiateChannelIDAtAllVersions: true, |
| 4966 | }, |
| 4967 | }, |
| 4968 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4969 | shouldFail: true, |
| 4970 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4971 | }) |
| 4972 | testCases = append(testCases, testCase{ |
| 4973 | name: "Ticket-Forbidden-TLS13", |
| 4974 | config: Config{ |
| 4975 | MaxVersion: VersionTLS12, |
| 4976 | }, |
| 4977 | resumeConfig: &Config{ |
| 4978 | MaxVersion: VersionTLS13, |
| 4979 | Bugs: ProtocolBugs{ |
| 4980 | AdvertiseTicketExtension: true, |
| 4981 | }, |
| 4982 | }, |
| 4983 | resumeSession: true, |
| 4984 | shouldFail: true, |
| 4985 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 4986 | }) |
| 4987 | |
| 4988 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 4989 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 4990 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 4991 | // implicit in every test.) |
| 4992 | testCases = append(testCases, testCase{ |
| 4993 | testType: serverTest, |
| 4994 | name: "ChannelID-Declined-TLS13", |
| 4995 | config: Config{ |
| 4996 | MaxVersion: VersionTLS13, |
| 4997 | ChannelID: channelIDKey, |
| 4998 | }, |
| 4999 | flags: []string{"-enable-channel-id"}, |
| 5000 | }) |
| 5001 | testCases = append(testCases, testCase{ |
| 5002 | testType: serverTest, |
| 5003 | name: "NPN-Server", |
| 5004 | config: Config{ |
| 5005 | MaxVersion: VersionTLS13, |
| 5006 | NextProtos: []string{"bar"}, |
| 5007 | }, |
| 5008 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5009 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5010 | |
| 5011 | testCases = append(testCases, testCase{ |
| 5012 | testType: serverTest, |
| 5013 | name: "InvalidChannelIDSignature", |
| 5014 | config: Config{ |
| 5015 | MaxVersion: VersionTLS12, |
| 5016 | ChannelID: channelIDKey, |
| 5017 | Bugs: ProtocolBugs{ |
| 5018 | InvalidChannelIDSignature: true, |
| 5019 | }, |
| 5020 | }, |
| 5021 | flags: []string{"-enable-channel-id"}, |
| 5022 | shouldFail: true, |
| 5023 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 5024 | expectedLocalError: "remote error: error decrypting message", |
| 5025 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5026 | } |
| 5027 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5028 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5029 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5030 | for _, resumeVers := range tlsVersions { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5031 | cipher := TLS_RSA_WITH_AES_128_CBC_SHA |
| 5032 | if sessionVers.version >= VersionTLS13 || resumeVers.version >= VersionTLS13 { |
| 5033 | // TLS 1.3 only shares ciphers with TLS 1.2, so |
| 5034 | // we skip certain combinations and use a |
| 5035 | // different cipher to test with. |
| 5036 | cipher = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
| 5037 | if sessionVers.version < VersionTLS12 || resumeVers.version < VersionTLS12 { |
| 5038 | continue |
| 5039 | } |
| 5040 | } |
| 5041 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5042 | protocols := []protocol{tls} |
| 5043 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5044 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5045 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5046 | for _, protocol := range protocols { |
| 5047 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5048 | if protocol == dtls { |
| 5049 | suffix += "-DTLS" |
| 5050 | } |
| 5051 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5052 | if sessionVers.version == resumeVers.version { |
| 5053 | testCases = append(testCases, testCase{ |
| 5054 | protocol: protocol, |
| 5055 | name: "Resume-Client" + suffix, |
| 5056 | resumeSession: true, |
| 5057 | config: Config{ |
| 5058 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5059 | CipherSuites: []uint16{cipher}, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5060 | Bugs: ProtocolBugs{ |
| 5061 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5062 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5063 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5064 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5065 | expectedVersion: sessionVers.version, |
| 5066 | expectedResumeVersion: resumeVers.version, |
| 5067 | }) |
| 5068 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5069 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5070 | |
| 5071 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5072 | // there is no way to convince a non-lookahead client the |
| 5073 | // session was resumed. It will appear to the client that a |
| 5074 | // stray ChangeCipherSpec was sent. |
| 5075 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5076 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5077 | } |
| 5078 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5079 | testCases = append(testCases, testCase{ |
| 5080 | protocol: protocol, |
| 5081 | name: "Resume-Client-Mismatch" + suffix, |
| 5082 | resumeSession: true, |
| 5083 | config: Config{ |
| 5084 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5085 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5086 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5087 | expectedVersion: sessionVers.version, |
| 5088 | resumeConfig: &Config{ |
| 5089 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5090 | CipherSuites: []uint16{cipher}, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5091 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5092 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5093 | }, |
| 5094 | }, |
| 5095 | expectedResumeVersion: resumeVers.version, |
| 5096 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5097 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5098 | }) |
| 5099 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5100 | |
| 5101 | testCases = append(testCases, testCase{ |
| 5102 | protocol: protocol, |
| 5103 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5104 | resumeSession: true, |
| 5105 | config: Config{ |
| 5106 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5107 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5108 | }, |
| 5109 | expectedVersion: sessionVers.version, |
| 5110 | resumeConfig: &Config{ |
| 5111 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5112 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5113 | }, |
| 5114 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5115 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5116 | expectedResumeVersion: resumeVers.version, |
| 5117 | }) |
| 5118 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5119 | testCases = append(testCases, testCase{ |
| 5120 | protocol: protocol, |
| 5121 | testType: serverTest, |
| 5122 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5123 | resumeSession: true, |
| 5124 | config: Config{ |
| 5125 | MaxVersion: sessionVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5126 | CipherSuites: []uint16{cipher}, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5127 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5128 | expectedVersion: sessionVers.version, |
| 5129 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5130 | resumeConfig: &Config{ |
| 5131 | MaxVersion: resumeVers.version, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5132 | CipherSuites: []uint16{cipher}, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5133 | Bugs: ProtocolBugs{ |
| 5134 | SendBothTickets: true, |
| 5135 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5136 | }, |
| 5137 | expectedResumeVersion: resumeVers.version, |
| 5138 | }) |
| 5139 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5140 | } |
| 5141 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5142 | |
| 5143 | testCases = append(testCases, testCase{ |
| 5144 | name: "Resume-Client-CipherMismatch", |
| 5145 | resumeSession: true, |
| 5146 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5147 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5148 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5149 | }, |
| 5150 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5151 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5152 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 5153 | Bugs: ProtocolBugs{ |
| 5154 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 5155 | }, |
| 5156 | }, |
| 5157 | shouldFail: true, |
| 5158 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5159 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5160 | |
| 5161 | testCases = append(testCases, testCase{ |
| 5162 | name: "Resume-Client-CipherMismatch-TLS13", |
| 5163 | resumeSession: true, |
| 5164 | config: Config{ |
| 5165 | MaxVersion: VersionTLS13, |
| 5166 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5167 | }, |
| 5168 | resumeConfig: &Config{ |
| 5169 | MaxVersion: VersionTLS13, |
| 5170 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5171 | Bugs: ProtocolBugs{ |
| 5172 | SendCipherSuite: TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, |
| 5173 | }, |
| 5174 | }, |
| 5175 | shouldFail: true, |
| 5176 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 5177 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5178 | } |
| 5179 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5180 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 5181 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5182 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5183 | testType: serverTest, |
| 5184 | name: "Renegotiate-Server-Forbidden", |
| 5185 | config: Config{ |
| 5186 | MaxVersion: VersionTLS12, |
| 5187 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5188 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5189 | shouldFail: true, |
| 5190 | expectedError: ":NO_RENEGOTIATION:", |
| 5191 | expectedLocalError: "remote error: no renegotiation", |
| 5192 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5193 | // The server shouldn't echo the renegotiation extension unless |
| 5194 | // requested by the client. |
| 5195 | testCases = append(testCases, testCase{ |
| 5196 | testType: serverTest, |
| 5197 | name: "Renegotiate-Server-NoExt", |
| 5198 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5199 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5200 | Bugs: ProtocolBugs{ |
| 5201 | NoRenegotiationInfo: true, |
| 5202 | RequireRenegotiationInfo: true, |
| 5203 | }, |
| 5204 | }, |
| 5205 | shouldFail: true, |
| 5206 | expectedLocalError: "renegotiation extension missing", |
| 5207 | }) |
| 5208 | // The renegotiation SCSV should be sufficient for the server to echo |
| 5209 | // the extension. |
| 5210 | testCases = append(testCases, testCase{ |
| 5211 | testType: serverTest, |
| 5212 | name: "Renegotiate-Server-NoExt-SCSV", |
| 5213 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5214 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 5215 | Bugs: ProtocolBugs{ |
| 5216 | NoRenegotiationInfo: true, |
| 5217 | SendRenegotiationSCSV: true, |
| 5218 | RequireRenegotiationInfo: true, |
| 5219 | }, |
| 5220 | }, |
| 5221 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5222 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5223 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5224 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5225 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5226 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 5227 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5228 | }, |
| 5229 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5230 | renegotiate: 1, |
| 5231 | flags: []string{ |
| 5232 | "-renegotiate-freely", |
| 5233 | "-expect-total-renegotiations", "1", |
| 5234 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 5235 | }) |
| 5236 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5237 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5238 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5239 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5240 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5241 | Bugs: ProtocolBugs{ |
| 5242 | EmptyRenegotiationInfo: true, |
| 5243 | }, |
| 5244 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5245 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5246 | shouldFail: true, |
| 5247 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5248 | }) |
| 5249 | testCases = append(testCases, testCase{ |
| 5250 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5251 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5252 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5253 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5254 | Bugs: ProtocolBugs{ |
| 5255 | BadRenegotiationInfo: true, |
| 5256 | }, |
| 5257 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5258 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5259 | shouldFail: true, |
| 5260 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5261 | }) |
| 5262 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5263 | name: "Renegotiate-Client-Downgrade", |
| 5264 | renegotiate: 1, |
| 5265 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5266 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5267 | Bugs: ProtocolBugs{ |
| 5268 | NoRenegotiationInfoAfterInitial: true, |
| 5269 | }, |
| 5270 | }, |
| 5271 | flags: []string{"-renegotiate-freely"}, |
| 5272 | shouldFail: true, |
| 5273 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5274 | }) |
| 5275 | testCases = append(testCases, testCase{ |
| 5276 | name: "Renegotiate-Client-Upgrade", |
| 5277 | renegotiate: 1, |
| 5278 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5279 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 5280 | Bugs: ProtocolBugs{ |
| 5281 | NoRenegotiationInfoInInitial: true, |
| 5282 | }, |
| 5283 | }, |
| 5284 | flags: []string{"-renegotiate-freely"}, |
| 5285 | shouldFail: true, |
| 5286 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 5287 | }) |
| 5288 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5289 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5290 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5291 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5292 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5293 | Bugs: ProtocolBugs{ |
| 5294 | NoRenegotiationInfo: true, |
| 5295 | }, |
| 5296 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5297 | flags: []string{ |
| 5298 | "-renegotiate-freely", |
| 5299 | "-expect-total-renegotiations", "1", |
| 5300 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5301 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5302 | |
| 5303 | // Test that the server may switch ciphers on renegotiation without |
| 5304 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 5305 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5306 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5307 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5308 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5309 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5310 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5311 | }, |
| 5312 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5313 | flags: []string{ |
| 5314 | "-renegotiate-freely", |
| 5315 | "-expect-total-renegotiations", "1", |
| 5316 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5317 | }) |
| 5318 | testCases = append(testCases, testCase{ |
| 5319 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5320 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5321 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5322 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 5323 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5324 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 5325 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5326 | flags: []string{ |
| 5327 | "-renegotiate-freely", |
| 5328 | "-expect-total-renegotiations", "1", |
| 5329 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5330 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 5331 | |
| 5332 | // Test that the server may not switch versions on renegotiation. |
| 5333 | testCases = append(testCases, testCase{ |
| 5334 | name: "Renegotiate-Client-SwitchVersion", |
| 5335 | config: Config{ |
| 5336 | MaxVersion: VersionTLS12, |
| 5337 | // Pick a cipher which exists at both versions. |
| 5338 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 5339 | Bugs: ProtocolBugs{ |
| 5340 | NegotiateVersionOnRenego: VersionTLS11, |
| 5341 | }, |
| 5342 | }, |
| 5343 | renegotiate: 1, |
| 5344 | flags: []string{ |
| 5345 | "-renegotiate-freely", |
| 5346 | "-expect-total-renegotiations", "1", |
| 5347 | }, |
| 5348 | shouldFail: true, |
| 5349 | expectedError: ":WRONG_SSL_VERSION:", |
| 5350 | }) |
| 5351 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 5352 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5353 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5354 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5355 | config: Config{ |
| 5356 | MaxVersion: VersionTLS10, |
| 5357 | Bugs: ProtocolBugs{ |
| 5358 | RequireSameRenegoClientVersion: true, |
| 5359 | }, |
| 5360 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5361 | flags: []string{ |
| 5362 | "-renegotiate-freely", |
| 5363 | "-expect-total-renegotiations", "1", |
| 5364 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 5365 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5366 | testCases = append(testCases, testCase{ |
| 5367 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5368 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5369 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5370 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5371 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5372 | NextProtos: []string{"foo"}, |
| 5373 | }, |
| 5374 | flags: []string{ |
| 5375 | "-false-start", |
| 5376 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5377 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 5378 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 5379 | }, |
| 5380 | shimWritesFirst: true, |
| 5381 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5382 | |
| 5383 | // Client-side renegotiation controls. |
| 5384 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5385 | name: "Renegotiate-Client-Forbidden-1", |
| 5386 | config: Config{ |
| 5387 | MaxVersion: VersionTLS12, |
| 5388 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5389 | renegotiate: 1, |
| 5390 | shouldFail: true, |
| 5391 | expectedError: ":NO_RENEGOTIATION:", |
| 5392 | expectedLocalError: "remote error: no renegotiation", |
| 5393 | }) |
| 5394 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5395 | name: "Renegotiate-Client-Once-1", |
| 5396 | config: Config{ |
| 5397 | MaxVersion: VersionTLS12, |
| 5398 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5399 | renegotiate: 1, |
| 5400 | flags: []string{ |
| 5401 | "-renegotiate-once", |
| 5402 | "-expect-total-renegotiations", "1", |
| 5403 | }, |
| 5404 | }) |
| 5405 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5406 | name: "Renegotiate-Client-Freely-1", |
| 5407 | config: Config{ |
| 5408 | MaxVersion: VersionTLS12, |
| 5409 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5410 | renegotiate: 1, |
| 5411 | flags: []string{ |
| 5412 | "-renegotiate-freely", |
| 5413 | "-expect-total-renegotiations", "1", |
| 5414 | }, |
| 5415 | }) |
| 5416 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5417 | name: "Renegotiate-Client-Once-2", |
| 5418 | config: Config{ |
| 5419 | MaxVersion: VersionTLS12, |
| 5420 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5421 | renegotiate: 2, |
| 5422 | flags: []string{"-renegotiate-once"}, |
| 5423 | shouldFail: true, |
| 5424 | expectedError: ":NO_RENEGOTIATION:", |
| 5425 | expectedLocalError: "remote error: no renegotiation", |
| 5426 | }) |
| 5427 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5428 | name: "Renegotiate-Client-Freely-2", |
| 5429 | config: Config{ |
| 5430 | MaxVersion: VersionTLS12, |
| 5431 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 5432 | renegotiate: 2, |
| 5433 | flags: []string{ |
| 5434 | "-renegotiate-freely", |
| 5435 | "-expect-total-renegotiations", "2", |
| 5436 | }, |
| 5437 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5438 | testCases = append(testCases, testCase{ |
| 5439 | name: "Renegotiate-Client-NoIgnore", |
| 5440 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5441 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5442 | Bugs: ProtocolBugs{ |
| 5443 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5444 | }, |
| 5445 | }, |
| 5446 | shouldFail: true, |
| 5447 | expectedError: ":NO_RENEGOTIATION:", |
| 5448 | }) |
| 5449 | testCases = append(testCases, testCase{ |
| 5450 | name: "Renegotiate-Client-Ignore", |
| 5451 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5452 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 5453 | Bugs: ProtocolBugs{ |
| 5454 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5455 | }, |
| 5456 | }, |
| 5457 | flags: []string{ |
| 5458 | "-renegotiate-ignore", |
| 5459 | "-expect-total-renegotiations", "0", |
| 5460 | }, |
| 5461 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5462 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5463 | // Stray HelloRequests during the handshake are ignored in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 5464 | testCases = append(testCases, testCase{ |
| 5465 | name: "StrayHelloRequest", |
| 5466 | config: Config{ |
| 5467 | MaxVersion: VersionTLS12, |
| 5468 | Bugs: ProtocolBugs{ |
| 5469 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5470 | }, |
| 5471 | }, |
| 5472 | }) |
| 5473 | testCases = append(testCases, testCase{ |
| 5474 | name: "StrayHelloRequest-Packed", |
| 5475 | config: Config{ |
| 5476 | MaxVersion: VersionTLS12, |
| 5477 | Bugs: ProtocolBugs{ |
| 5478 | PackHandshakeFlight: true, |
| 5479 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5480 | }, |
| 5481 | }, |
| 5482 | }) |
| 5483 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 5484 | // Test renegotiation works if HelloRequest and server Finished come in |
| 5485 | // the same record. |
| 5486 | testCases = append(testCases, testCase{ |
| 5487 | name: "Renegotiate-Client-Packed", |
| 5488 | config: Config{ |
| 5489 | MaxVersion: VersionTLS12, |
| 5490 | Bugs: ProtocolBugs{ |
| 5491 | PackHandshakeFlight: true, |
| 5492 | PackHelloRequestWithFinished: true, |
| 5493 | }, |
| 5494 | }, |
| 5495 | renegotiate: 1, |
| 5496 | flags: []string{ |
| 5497 | "-renegotiate-freely", |
| 5498 | "-expect-total-renegotiations", "1", |
| 5499 | }, |
| 5500 | }) |
| 5501 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5502 | // Renegotiation is forbidden in TLS 1.3. |
| 5503 | testCases = append(testCases, testCase{ |
| 5504 | name: "Renegotiate-Client-TLS13", |
| 5505 | config: Config{ |
| 5506 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5507 | Bugs: ProtocolBugs{ |
| 5508 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 5509 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5510 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5511 | flags: []string{ |
| 5512 | "-renegotiate-freely", |
| 5513 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 5514 | shouldFail: true, |
| 5515 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 5516 | }) |
| 5517 | |
| 5518 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 5519 | testCases = append(testCases, testCase{ |
| 5520 | name: "StrayHelloRequest-TLS13", |
| 5521 | config: Config{ |
| 5522 | MaxVersion: VersionTLS13, |
| 5523 | Bugs: ProtocolBugs{ |
| 5524 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 5525 | }, |
| 5526 | }, |
| 5527 | shouldFail: true, |
| 5528 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 5529 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 5530 | } |
| 5531 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5532 | func addDTLSReplayTests() { |
| 5533 | // Test that sequence number replays are detected. |
| 5534 | testCases = append(testCases, testCase{ |
| 5535 | protocol: dtls, |
| 5536 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5537 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5538 | replayWrites: true, |
| 5539 | }) |
| 5540 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5541 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5542 | // than the retransmit window. |
| 5543 | testCases = append(testCases, testCase{ |
| 5544 | protocol: dtls, |
| 5545 | name: "DTLS-Replay-LargeGaps", |
| 5546 | config: Config{ |
| 5547 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5548 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5549 | return in * 127 |
| 5550 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5551 | }, |
| 5552 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 5553 | messageCount: 200, |
| 5554 | replayWrites: true, |
| 5555 | }) |
| 5556 | |
| 5557 | // Test the incoming sequence number changing non-monotonically. |
| 5558 | testCases = append(testCases, testCase{ |
| 5559 | protocol: dtls, |
| 5560 | name: "DTLS-Replay-NonMonotonic", |
| 5561 | config: Config{ |
| 5562 | Bugs: ProtocolBugs{ |
| 5563 | SequenceNumberMapping: func(in uint64) uint64 { |
| 5564 | return in ^ 31 |
| 5565 | }, |
| 5566 | }, |
| 5567 | }, |
| 5568 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 5569 | replayWrites: true, |
| 5570 | }) |
| 5571 | } |
| 5572 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5573 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5574 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5575 | id signatureAlgorithm |
| 5576 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5577 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5578 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 5579 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 5580 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 5581 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5582 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 5583 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 5584 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 5585 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5586 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 5587 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 5588 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5589 | // Tests for key types prior to TLS 1.2. |
| 5590 | {"RSA", 0, testCertRSA}, |
| 5591 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5592 | } |
| 5593 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5594 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 5595 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 5596 | |
| 5597 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5598 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 5599 | // versions a signing cipher. |
| 5600 | signingCiphers := []uint16{ |
| 5601 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 5602 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 5603 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 5604 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 5605 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA, |
| 5606 | } |
| 5607 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5608 | var allAlgorithms []signatureAlgorithm |
| 5609 | for _, alg := range testSignatureAlgorithms { |
| 5610 | if alg.id != 0 { |
| 5611 | allAlgorithms = append(allAlgorithms, alg.id) |
| 5612 | } |
| 5613 | } |
| 5614 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5615 | // Make sure each signature algorithm works. Include some fake values in |
| 5616 | // the list and ensure they're ignored. |
| 5617 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5618 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5619 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 5620 | continue |
| 5621 | } |
| 5622 | |
| 5623 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 5624 | // or remove it in C. |
| 5625 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5626 | continue |
| 5627 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5628 | |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5629 | var shouldFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5630 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5631 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
| 5632 | shouldFail = true |
| 5633 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 5634 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 5635 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 5636 | shouldFail = true |
| 5637 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5638 | |
| 5639 | var signError, verifyError string |
| 5640 | if shouldFail { |
| 5641 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
| 5642 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5643 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5644 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5645 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 5646 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5647 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5648 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5649 | config: Config{ |
| 5650 | MaxVersion: ver.version, |
| 5651 | ClientAuth: RequireAnyClientCert, |
| 5652 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5653 | fakeSigAlg1, |
| 5654 | alg.id, |
| 5655 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5656 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5657 | }, |
| 5658 | flags: []string{ |
| 5659 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5660 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5661 | "-enable-all-curves", |
| 5662 | }, |
| 5663 | shouldFail: shouldFail, |
| 5664 | expectedError: signError, |
| 5665 | expectedPeerSignatureAlgorithm: alg.id, |
| 5666 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5667 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5668 | testCases = append(testCases, testCase{ |
| 5669 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5670 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5671 | config: Config{ |
| 5672 | MaxVersion: ver.version, |
| 5673 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5674 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5675 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5676 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5677 | Bugs: ProtocolBugs{ |
| 5678 | SkipECDSACurveCheck: shouldFail, |
| 5679 | IgnoreSignatureVersionChecks: shouldFail, |
| 5680 | // The client won't advertise 1.3-only algorithms after |
| 5681 | // version negotiation. |
| 5682 | IgnorePeerSignatureAlgorithmPreferences: shouldFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5683 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5684 | }, |
| 5685 | flags: []string{ |
| 5686 | "-require-any-client-certificate", |
| 5687 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5688 | "-enable-all-curves", |
| 5689 | }, |
| 5690 | shouldFail: shouldFail, |
| 5691 | expectedError: verifyError, |
| 5692 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5693 | |
| 5694 | testCases = append(testCases, testCase{ |
| 5695 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5696 | name: "ServerAuth-Sign" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5697 | config: Config{ |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5698 | MaxVersion: ver.version, |
| 5699 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5700 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5701 | fakeSigAlg1, |
| 5702 | alg.id, |
| 5703 | fakeSigAlg2, |
| 5704 | }, |
| 5705 | }, |
| 5706 | flags: []string{ |
| 5707 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5708 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5709 | "-enable-all-curves", |
| 5710 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5711 | shouldFail: shouldFail, |
| 5712 | expectedError: signError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5713 | expectedPeerSignatureAlgorithm: alg.id, |
| 5714 | }) |
| 5715 | |
| 5716 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5717 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5718 | config: Config{ |
| 5719 | MaxVersion: ver.version, |
| 5720 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5721 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5722 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5723 | alg.id, |
| 5724 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5725 | Bugs: ProtocolBugs{ |
| 5726 | SkipECDSACurveCheck: shouldFail, |
| 5727 | IgnoreSignatureVersionChecks: shouldFail, |
| 5728 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5729 | }, |
| 5730 | flags: []string{ |
| 5731 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 5732 | "-enable-all-curves", |
| 5733 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 5734 | shouldFail: shouldFail, |
| 5735 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5736 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 5737 | |
| 5738 | if !shouldFail { |
| 5739 | testCases = append(testCases, testCase{ |
| 5740 | testType: serverTest, |
| 5741 | name: "ClientAuth-InvalidSignature" + suffix, |
| 5742 | config: Config{ |
| 5743 | MaxVersion: ver.version, |
| 5744 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5745 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5746 | alg.id, |
| 5747 | }, |
| 5748 | Bugs: ProtocolBugs{ |
| 5749 | InvalidSignature: true, |
| 5750 | }, |
| 5751 | }, |
| 5752 | flags: []string{ |
| 5753 | "-require-any-client-certificate", |
| 5754 | "-enable-all-curves", |
| 5755 | }, |
| 5756 | shouldFail: true, |
| 5757 | expectedError: ":BAD_SIGNATURE:", |
| 5758 | }) |
| 5759 | |
| 5760 | testCases = append(testCases, testCase{ |
| 5761 | name: "ServerAuth-InvalidSignature" + suffix, |
| 5762 | config: Config{ |
| 5763 | MaxVersion: ver.version, |
| 5764 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 5765 | CipherSuites: signingCiphers, |
| 5766 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5767 | alg.id, |
| 5768 | }, |
| 5769 | Bugs: ProtocolBugs{ |
| 5770 | InvalidSignature: true, |
| 5771 | }, |
| 5772 | }, |
| 5773 | flags: []string{"-enable-all-curves"}, |
| 5774 | shouldFail: true, |
| 5775 | expectedError: ":BAD_SIGNATURE:", |
| 5776 | }) |
| 5777 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 5778 | |
| 5779 | if ver.version >= VersionTLS12 && !shouldFail { |
| 5780 | testCases = append(testCases, testCase{ |
| 5781 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 5782 | config: Config{ |
| 5783 | MaxVersion: ver.version, |
| 5784 | ClientAuth: RequireAnyClientCert, |
| 5785 | VerifySignatureAlgorithms: allAlgorithms, |
| 5786 | }, |
| 5787 | flags: []string{ |
| 5788 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5789 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5790 | "-enable-all-curves", |
| 5791 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5792 | }, |
| 5793 | expectedPeerSignatureAlgorithm: alg.id, |
| 5794 | }) |
| 5795 | |
| 5796 | testCases = append(testCases, testCase{ |
| 5797 | testType: serverTest, |
| 5798 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 5799 | config: Config{ |
| 5800 | MaxVersion: ver.version, |
| 5801 | CipherSuites: signingCiphers, |
| 5802 | VerifySignatureAlgorithms: allAlgorithms, |
| 5803 | }, |
| 5804 | flags: []string{ |
| 5805 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 5806 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 5807 | "-enable-all-curves", |
| 5808 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 5809 | }, |
| 5810 | expectedPeerSignatureAlgorithm: alg.id, |
| 5811 | }) |
| 5812 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 5813 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5814 | } |
| 5815 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5816 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5817 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5818 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5819 | config: Config{ |
| 5820 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5821 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5822 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5823 | signatureECDSAWithP521AndSHA512, |
| 5824 | signatureRSAPKCS1WithSHA384, |
| 5825 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5826 | }, |
| 5827 | }, |
| 5828 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5829 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5830 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5831 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5832 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5833 | }) |
| 5834 | |
| 5835 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5836 | name: "ClientAuth-SignatureType-TLS13", |
| 5837 | config: Config{ |
| 5838 | ClientAuth: RequireAnyClientCert, |
| 5839 | MaxVersion: VersionTLS13, |
| 5840 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5841 | signatureECDSAWithP521AndSHA512, |
| 5842 | signatureRSAPKCS1WithSHA384, |
| 5843 | signatureRSAPSSWithSHA384, |
| 5844 | signatureECDSAWithSHA1, |
| 5845 | }, |
| 5846 | }, |
| 5847 | flags: []string{ |
| 5848 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5849 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5850 | }, |
| 5851 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5852 | }) |
| 5853 | |
| 5854 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5855 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5856 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5857 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5858 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5859 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5860 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5861 | signatureECDSAWithP521AndSHA512, |
| 5862 | signatureRSAPKCS1WithSHA384, |
| 5863 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5864 | }, |
| 5865 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5866 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5867 | }) |
| 5868 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5869 | testCases = append(testCases, testCase{ |
| 5870 | testType: serverTest, |
| 5871 | name: "ServerAuth-SignatureType-TLS13", |
| 5872 | config: Config{ |
| 5873 | MaxVersion: VersionTLS13, |
| 5874 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5875 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 5876 | signatureECDSAWithP521AndSHA512, |
| 5877 | signatureRSAPKCS1WithSHA384, |
| 5878 | signatureRSAPSSWithSHA384, |
| 5879 | signatureECDSAWithSHA1, |
| 5880 | }, |
| 5881 | }, |
| 5882 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 5883 | }) |
| 5884 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5885 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5886 | testCases = append(testCases, testCase{ |
| 5887 | testType: serverTest, |
| 5888 | name: "Verify-ClientAuth-SignatureType", |
| 5889 | config: Config{ |
| 5890 | MaxVersion: VersionTLS12, |
| 5891 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5892 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5893 | signatureRSAPKCS1WithSHA256, |
| 5894 | }, |
| 5895 | Bugs: ProtocolBugs{ |
| 5896 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5897 | }, |
| 5898 | }, |
| 5899 | flags: []string{ |
| 5900 | "-require-any-client-certificate", |
| 5901 | }, |
| 5902 | shouldFail: true, |
| 5903 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5904 | }) |
| 5905 | |
| 5906 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5907 | testType: serverTest, |
| 5908 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 5909 | config: Config{ |
| 5910 | MaxVersion: VersionTLS13, |
| 5911 | Certificates: []Certificate{rsaCertificate}, |
| 5912 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5913 | signatureRSAPSSWithSHA256, |
| 5914 | }, |
| 5915 | Bugs: ProtocolBugs{ |
| 5916 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5917 | }, |
| 5918 | }, |
| 5919 | flags: []string{ |
| 5920 | "-require-any-client-certificate", |
| 5921 | }, |
| 5922 | shouldFail: true, |
| 5923 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5924 | }) |
| 5925 | |
| 5926 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 5927 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5928 | config: Config{ |
| 5929 | MaxVersion: VersionTLS12, |
| 5930 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5931 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 5932 | signatureRSAPKCS1WithSHA256, |
| 5933 | }, |
| 5934 | Bugs: ProtocolBugs{ |
| 5935 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5936 | }, |
| 5937 | }, |
| 5938 | shouldFail: true, |
| 5939 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5940 | }) |
| 5941 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5942 | testCases = append(testCases, testCase{ |
| 5943 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 5944 | config: Config{ |
| 5945 | MaxVersion: VersionTLS13, |
| 5946 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5947 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 5948 | signatureRSAPSSWithSHA256, |
| 5949 | }, |
| 5950 | Bugs: ProtocolBugs{ |
| 5951 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 5952 | }, |
| 5953 | }, |
| 5954 | shouldFail: true, |
| 5955 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 5956 | }) |
| 5957 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 5958 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 5959 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5960 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5961 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5962 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5963 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5964 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5965 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5966 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5967 | }, |
| 5968 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5969 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5970 | }, |
| 5971 | }, |
| 5972 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 5973 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5974 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5975 | }, |
| 5976 | }) |
| 5977 | |
| 5978 | testCases = append(testCases, testCase{ |
| 5979 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5980 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5981 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5982 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 5983 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5984 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5985 | }, |
| 5986 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 5987 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 5988 | }, |
| 5989 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 5990 | flags: []string{ |
| 5991 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5992 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5993 | }, |
| 5994 | }) |
| 5995 | |
| 5996 | testCases = append(testCases, testCase{ |
| 5997 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 5998 | config: Config{ |
| 5999 | MaxVersion: VersionTLS12, |
| 6000 | ClientAuth: RequireAnyClientCert, |
| 6001 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6002 | signatureECDSAWithSHA1, |
| 6003 | }, |
| 6004 | Bugs: ProtocolBugs{ |
| 6005 | NoSignatureAlgorithms: true, |
| 6006 | }, |
| 6007 | }, |
| 6008 | flags: []string{ |
| 6009 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6010 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6011 | }, |
| 6012 | }) |
| 6013 | |
| 6014 | testCases = append(testCases, testCase{ |
| 6015 | testType: serverTest, |
| 6016 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 6017 | config: Config{ |
| 6018 | MaxVersion: VersionTLS12, |
| 6019 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6020 | signatureECDSAWithSHA1, |
| 6021 | }, |
| 6022 | Bugs: ProtocolBugs{ |
| 6023 | NoSignatureAlgorithms: true, |
| 6024 | }, |
| 6025 | }, |
| 6026 | flags: []string{ |
| 6027 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6028 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6029 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6030 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6031 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6032 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6033 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6034 | config: Config{ |
| 6035 | MaxVersion: VersionTLS13, |
| 6036 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6037 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6038 | signatureRSAPKCS1WithSHA1, |
| 6039 | }, |
| 6040 | Bugs: ProtocolBugs{ |
| 6041 | NoSignatureAlgorithms: true, |
| 6042 | }, |
| 6043 | }, |
| 6044 | flags: []string{ |
| 6045 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6046 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6047 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 6048 | shouldFail: true, |
| 6049 | // An empty CertificateRequest signature algorithm list is a |
| 6050 | // syntax error in TLS 1.3. |
| 6051 | expectedError: ":DECODE_ERROR:", |
| 6052 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6053 | }) |
| 6054 | |
| 6055 | testCases = append(testCases, testCase{ |
| 6056 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6057 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6058 | config: Config{ |
| 6059 | MaxVersion: VersionTLS13, |
| 6060 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6061 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 6062 | signatureRSAPKCS1WithSHA1, |
| 6063 | }, |
| 6064 | Bugs: ProtocolBugs{ |
| 6065 | NoSignatureAlgorithms: true, |
| 6066 | }, |
| 6067 | }, |
| 6068 | shouldFail: true, |
| 6069 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6070 | }) |
| 6071 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6072 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 6073 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6074 | testCases = append(testCases, testCase{ |
| 6075 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6076 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6077 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6078 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6079 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6080 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6081 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6082 | }, |
| 6083 | Bugs: ProtocolBugs{ |
| 6084 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6085 | }, |
| 6086 | }, |
| 6087 | flags: []string{"-require-any-client-certificate"}, |
| 6088 | shouldFail: true, |
| 6089 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6090 | }) |
| 6091 | |
| 6092 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6093 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6094 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6095 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6096 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6097 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6098 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 6099 | }, |
| 6100 | Bugs: ProtocolBugs{ |
| 6101 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6102 | }, |
| 6103 | }, |
| 6104 | shouldFail: true, |
| 6105 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6106 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 6107 | testCases = append(testCases, testCase{ |
| 6108 | testType: serverTest, |
| 6109 | name: "ClientAuth-Enforced-TLS13", |
| 6110 | config: Config{ |
| 6111 | MaxVersion: VersionTLS13, |
| 6112 | Certificates: []Certificate{rsaCertificate}, |
| 6113 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6114 | signatureRSAPKCS1WithMD5, |
| 6115 | }, |
| 6116 | Bugs: ProtocolBugs{ |
| 6117 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6118 | IgnoreSignatureVersionChecks: true, |
| 6119 | }, |
| 6120 | }, |
| 6121 | flags: []string{"-require-any-client-certificate"}, |
| 6122 | shouldFail: true, |
| 6123 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6124 | }) |
| 6125 | |
| 6126 | testCases = append(testCases, testCase{ |
| 6127 | name: "ServerAuth-Enforced-TLS13", |
| 6128 | config: Config{ |
| 6129 | MaxVersion: VersionTLS13, |
| 6130 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6131 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6132 | signatureRSAPKCS1WithMD5, |
| 6133 | }, |
| 6134 | Bugs: ProtocolBugs{ |
| 6135 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 6136 | IgnoreSignatureVersionChecks: true, |
| 6137 | }, |
| 6138 | }, |
| 6139 | shouldFail: true, |
| 6140 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6141 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6142 | |
| 6143 | // Test that the agreed upon digest respects the client preferences and |
| 6144 | // the server digests. |
| 6145 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6146 | name: "NoCommonAlgorithms-Digests", |
| 6147 | config: Config{ |
| 6148 | MaxVersion: VersionTLS12, |
| 6149 | ClientAuth: RequireAnyClientCert, |
| 6150 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6151 | signatureRSAPKCS1WithSHA512, |
| 6152 | signatureRSAPKCS1WithSHA1, |
| 6153 | }, |
| 6154 | }, |
| 6155 | flags: []string{ |
| 6156 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6157 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6158 | "-digest-prefs", "SHA256", |
| 6159 | }, |
| 6160 | shouldFail: true, |
| 6161 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6162 | }) |
| 6163 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6164 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6165 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6166 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6167 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6168 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6169 | signatureRSAPKCS1WithSHA512, |
| 6170 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6171 | }, |
| 6172 | }, |
| 6173 | flags: []string{ |
| 6174 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6175 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6176 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6177 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6178 | shouldFail: true, |
| 6179 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6180 | }) |
| 6181 | testCases = append(testCases, testCase{ |
| 6182 | name: "NoCommonAlgorithms-TLS13", |
| 6183 | config: Config{ |
| 6184 | MaxVersion: VersionTLS13, |
| 6185 | ClientAuth: RequireAnyClientCert, |
| 6186 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6187 | signatureRSAPSSWithSHA512, |
| 6188 | signatureRSAPSSWithSHA384, |
| 6189 | }, |
| 6190 | }, |
| 6191 | flags: []string{ |
| 6192 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6193 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6194 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 6195 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 6196 | shouldFail: true, |
| 6197 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6198 | }) |
| 6199 | testCases = append(testCases, testCase{ |
| 6200 | name: "Agree-Digest-SHA256", |
| 6201 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6202 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6203 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6204 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6205 | signatureRSAPKCS1WithSHA1, |
| 6206 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6207 | }, |
| 6208 | }, |
| 6209 | flags: []string{ |
| 6210 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6211 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6212 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6213 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6214 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6215 | }) |
| 6216 | testCases = append(testCases, testCase{ |
| 6217 | name: "Agree-Digest-SHA1", |
| 6218 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6219 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6220 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6221 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6222 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6223 | }, |
| 6224 | }, |
| 6225 | flags: []string{ |
| 6226 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6227 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6228 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6229 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6230 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6231 | }) |
| 6232 | testCases = append(testCases, testCase{ |
| 6233 | name: "Agree-Digest-Default", |
| 6234 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6235 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6236 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6237 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6238 | signatureRSAPKCS1WithSHA256, |
| 6239 | signatureECDSAWithP256AndSHA256, |
| 6240 | signatureRSAPKCS1WithSHA1, |
| 6241 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6242 | }, |
| 6243 | }, |
| 6244 | flags: []string{ |
| 6245 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6246 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6247 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6248 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 6249 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6250 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6251 | // Test that the signing preference list may include extra algorithms |
| 6252 | // without negotiation problems. |
| 6253 | testCases = append(testCases, testCase{ |
| 6254 | testType: serverTest, |
| 6255 | name: "FilterExtraAlgorithms", |
| 6256 | config: Config{ |
| 6257 | MaxVersion: VersionTLS12, |
| 6258 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6259 | signatureRSAPKCS1WithSHA256, |
| 6260 | }, |
| 6261 | }, |
| 6262 | flags: []string{ |
| 6263 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6264 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6265 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 6266 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 6267 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 6268 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 6269 | }, |
| 6270 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 6271 | }) |
| 6272 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6273 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 6274 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6275 | testCases = append(testCases, testCase{ |
| 6276 | name: "CheckLeafCurve", |
| 6277 | config: Config{ |
| 6278 | MaxVersion: VersionTLS12, |
| 6279 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6280 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6281 | }, |
| 6282 | flags: []string{"-p384-only"}, |
| 6283 | shouldFail: true, |
| 6284 | expectedError: ":BAD_ECC_CERT:", |
| 6285 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 6286 | |
| 6287 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 6288 | testCases = append(testCases, testCase{ |
| 6289 | name: "CheckLeafCurve-TLS13", |
| 6290 | config: Config{ |
| 6291 | MaxVersion: VersionTLS13, |
| 6292 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6293 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 6294 | }, |
| 6295 | flags: []string{"-p384-only"}, |
| 6296 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6297 | |
| 6298 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 6299 | testCases = append(testCases, testCase{ |
| 6300 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 6301 | config: Config{ |
| 6302 | MaxVersion: VersionTLS12, |
| 6303 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6304 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6305 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6306 | signatureECDSAWithP384AndSHA384, |
| 6307 | }, |
| 6308 | }, |
| 6309 | }) |
| 6310 | |
| 6311 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 6312 | testCases = append(testCases, testCase{ |
| 6313 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 6314 | config: Config{ |
| 6315 | MaxVersion: VersionTLS13, |
| 6316 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 6317 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6318 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6319 | signatureECDSAWithP384AndSHA384, |
| 6320 | }, |
| 6321 | Bugs: ProtocolBugs{ |
| 6322 | SkipECDSACurveCheck: true, |
| 6323 | }, |
| 6324 | }, |
| 6325 | shouldFail: true, |
| 6326 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 6327 | }) |
| 6328 | |
| 6329 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 6330 | // account. |
| 6331 | testCases = append(testCases, testCase{ |
| 6332 | testType: serverTest, |
| 6333 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 6334 | config: Config{ |
| 6335 | MaxVersion: VersionTLS13, |
| 6336 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6337 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6338 | signatureECDSAWithP384AndSHA384, |
| 6339 | signatureECDSAWithP256AndSHA256, |
| 6340 | }, |
| 6341 | }, |
| 6342 | flags: []string{ |
| 6343 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 6344 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 6345 | }, |
| 6346 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6347 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 6348 | |
| 6349 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 6350 | // server does not attempt to sign in that case. |
| 6351 | testCases = append(testCases, testCase{ |
| 6352 | testType: serverTest, |
| 6353 | name: "RSA-PSS-Large", |
| 6354 | config: Config{ |
| 6355 | MaxVersion: VersionTLS13, |
| 6356 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6357 | signatureRSAPSSWithSHA512, |
| 6358 | }, |
| 6359 | }, |
| 6360 | flags: []string{ |
| 6361 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 6362 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 6363 | }, |
| 6364 | shouldFail: true, |
| 6365 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 6366 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 6367 | |
| 6368 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 6369 | testCases = append(testCases, testCase{ |
| 6370 | testType: clientTest, |
| 6371 | name: "RSA-PSS-Default-Verify", |
| 6372 | config: Config{ |
| 6373 | MaxVersion: VersionTLS12, |
| 6374 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6375 | signatureRSAPSSWithSHA256, |
| 6376 | }, |
| 6377 | }, |
| 6378 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6379 | }) |
| 6380 | |
| 6381 | testCases = append(testCases, testCase{ |
| 6382 | testType: serverTest, |
| 6383 | name: "RSA-PSS-Default-Sign", |
| 6384 | config: Config{ |
| 6385 | MaxVersion: VersionTLS12, |
| 6386 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6387 | signatureRSAPSSWithSHA256, |
| 6388 | }, |
| 6389 | }, |
| 6390 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6391 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6392 | } |
| 6393 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6394 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 6395 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 6396 | var timeouts = []time.Duration{ |
| 6397 | 1 * time.Second, |
| 6398 | 2 * time.Second, |
| 6399 | 4 * time.Second, |
| 6400 | 8 * time.Second, |
| 6401 | 16 * time.Second, |
| 6402 | 32 * time.Second, |
| 6403 | 60 * time.Second, |
| 6404 | 60 * time.Second, |
| 6405 | 60 * time.Second, |
| 6406 | 60 * time.Second, |
| 6407 | 60 * time.Second, |
| 6408 | 60 * time.Second, |
| 6409 | 60 * time.Second, |
| 6410 | } |
| 6411 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 6412 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 6413 | // initial timeout duration was set to 250ms. |
| 6414 | var shortTimeouts = []time.Duration{ |
| 6415 | 250 * time.Millisecond, |
| 6416 | 500 * time.Millisecond, |
| 6417 | 1 * time.Second, |
| 6418 | 2 * time.Second, |
| 6419 | 4 * time.Second, |
| 6420 | 8 * time.Second, |
| 6421 | 16 * time.Second, |
| 6422 | 32 * time.Second, |
| 6423 | 60 * time.Second, |
| 6424 | 60 * time.Second, |
| 6425 | 60 * time.Second, |
| 6426 | 60 * time.Second, |
| 6427 | 60 * time.Second, |
| 6428 | } |
| 6429 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6430 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6431 | // These tests work by coordinating some behavior on both the shim and |
| 6432 | // the runner. |
| 6433 | // |
| 6434 | // TimeoutSchedule configures the runner to send a series of timeout |
| 6435 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 6436 | // each peer handshake flight N. The timeout opcode both simulates a |
| 6437 | // timeout in the shim and acts as a synchronization point to help the |
| 6438 | // runner bracket each handshake flight. |
| 6439 | // |
| 6440 | // We assume the shim does not read from the channel eagerly. It must |
| 6441 | // first wait until it has sent flight N and is ready to receive |
| 6442 | // handshake flight N+1. At this point, it will process the timeout |
| 6443 | // opcode. It must then immediately respond with a timeout ACK and act |
| 6444 | // as if the shim was idle for the specified amount of time. |
| 6445 | // |
| 6446 | // The runner then drops all packets received before the ACK and |
| 6447 | // continues waiting for flight N. This ordering results in one attempt |
| 6448 | // at sending flight N to be dropped. For the test to complete, the |
| 6449 | // shim must send flight N again, testing that the shim implements DTLS |
| 6450 | // retransmit on a timeout. |
| 6451 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6452 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6453 | // likely be more epochs to cross and the final message's retransmit may |
| 6454 | // be more complex. |
| 6455 | |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6456 | for _, async := range []bool{true, false} { |
| 6457 | var tests []testCase |
| 6458 | |
| 6459 | // Test that this is indeed the timeout schedule. Stress all |
| 6460 | // four patterns of handshake. |
| 6461 | for i := 1; i < len(timeouts); i++ { |
| 6462 | number := strconv.Itoa(i) |
| 6463 | tests = append(tests, testCase{ |
| 6464 | protocol: dtls, |
| 6465 | name: "DTLS-Retransmit-Client-" + number, |
| 6466 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6467 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6468 | Bugs: ProtocolBugs{ |
| 6469 | TimeoutSchedule: timeouts[:i], |
| 6470 | }, |
| 6471 | }, |
| 6472 | resumeSession: true, |
| 6473 | }) |
| 6474 | tests = append(tests, testCase{ |
| 6475 | protocol: dtls, |
| 6476 | testType: serverTest, |
| 6477 | name: "DTLS-Retransmit-Server-" + number, |
| 6478 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6479 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6480 | Bugs: ProtocolBugs{ |
| 6481 | TimeoutSchedule: timeouts[:i], |
| 6482 | }, |
| 6483 | }, |
| 6484 | resumeSession: true, |
| 6485 | }) |
| 6486 | } |
| 6487 | |
| 6488 | // Test that exceeding the timeout schedule hits a read |
| 6489 | // timeout. |
| 6490 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6491 | protocol: dtls, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6492 | name: "DTLS-Retransmit-Timeout", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6493 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6494 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6495 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6496 | TimeoutSchedule: timeouts, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6497 | }, |
| 6498 | }, |
| 6499 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6500 | shouldFail: true, |
| 6501 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6502 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6503 | |
| 6504 | if async { |
| 6505 | // Test that timeout handling has a fudge factor, due to API |
| 6506 | // problems. |
| 6507 | tests = append(tests, testCase{ |
| 6508 | protocol: dtls, |
| 6509 | name: "DTLS-Retransmit-Fudge", |
| 6510 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6511 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6512 | Bugs: ProtocolBugs{ |
| 6513 | TimeoutSchedule: []time.Duration{ |
| 6514 | timeouts[0] - 10*time.Millisecond, |
| 6515 | }, |
| 6516 | }, |
| 6517 | }, |
| 6518 | resumeSession: true, |
| 6519 | }) |
| 6520 | } |
| 6521 | |
| 6522 | // Test that the final Finished retransmitting isn't |
| 6523 | // duplicated if the peer badly fragments everything. |
| 6524 | tests = append(tests, testCase{ |
| 6525 | testType: serverTest, |
| 6526 | protocol: dtls, |
| 6527 | name: "DTLS-Retransmit-Fragmented", |
| 6528 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6529 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6530 | Bugs: ProtocolBugs{ |
| 6531 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 6532 | MaxHandshakeRecordLength: 2, |
| 6533 | }, |
| 6534 | }, |
| 6535 | }) |
| 6536 | |
| 6537 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 6538 | tests = append(tests, testCase{ |
| 6539 | protocol: dtls, |
| 6540 | name: "DTLS-Retransmit-Short-Client", |
| 6541 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6542 | MaxVersion: VersionTLS12, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6543 | Bugs: ProtocolBugs{ |
| 6544 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 6545 | }, |
| 6546 | }, |
| 6547 | resumeSession: true, |
| 6548 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
| 6549 | }) |
| 6550 | tests = append(tests, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6551 | protocol: dtls, |
| 6552 | testType: serverTest, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6553 | name: "DTLS-Retransmit-Short-Server", |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6554 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6555 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6556 | Bugs: ProtocolBugs{ |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6557 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6558 | }, |
| 6559 | }, |
| 6560 | resumeSession: true, |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6561 | flags: []string{"-initial-timeout-duration-ms", "250"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6562 | }) |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 6563 | |
| 6564 | for _, test := range tests { |
| 6565 | if async { |
| 6566 | test.name += "-Async" |
| 6567 | test.flags = append(test.flags, "-async") |
| 6568 | } |
| 6569 | |
| 6570 | testCases = append(testCases, test) |
| 6571 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6572 | } |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 6573 | } |
| 6574 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 6575 | func addExportKeyingMaterialTests() { |
| 6576 | for _, vers := range tlsVersions { |
| 6577 | if vers.version == VersionSSL30 { |
| 6578 | continue |
| 6579 | } |
| 6580 | testCases = append(testCases, testCase{ |
| 6581 | name: "ExportKeyingMaterial-" + vers.name, |
| 6582 | config: Config{ |
| 6583 | MaxVersion: vers.version, |
| 6584 | }, |
| 6585 | exportKeyingMaterial: 1024, |
| 6586 | exportLabel: "label", |
| 6587 | exportContext: "context", |
| 6588 | useExportContext: true, |
| 6589 | }) |
| 6590 | testCases = append(testCases, testCase{ |
| 6591 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 6592 | config: Config{ |
| 6593 | MaxVersion: vers.version, |
| 6594 | }, |
| 6595 | exportKeyingMaterial: 1024, |
| 6596 | }) |
| 6597 | testCases = append(testCases, testCase{ |
| 6598 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 6599 | config: Config{ |
| 6600 | MaxVersion: vers.version, |
| 6601 | }, |
| 6602 | exportKeyingMaterial: 1024, |
| 6603 | useExportContext: true, |
| 6604 | }) |
| 6605 | testCases = append(testCases, testCase{ |
| 6606 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 6607 | config: Config{ |
| 6608 | MaxVersion: vers.version, |
| 6609 | }, |
| 6610 | exportKeyingMaterial: 1, |
| 6611 | exportLabel: "label", |
| 6612 | exportContext: "context", |
| 6613 | useExportContext: true, |
| 6614 | }) |
| 6615 | } |
| 6616 | testCases = append(testCases, testCase{ |
| 6617 | name: "ExportKeyingMaterial-SSL3", |
| 6618 | config: Config{ |
| 6619 | MaxVersion: VersionSSL30, |
| 6620 | }, |
| 6621 | exportKeyingMaterial: 1024, |
| 6622 | exportLabel: "label", |
| 6623 | exportContext: "context", |
| 6624 | useExportContext: true, |
| 6625 | shouldFail: true, |
| 6626 | expectedError: "failed to export keying material", |
| 6627 | }) |
| 6628 | } |
| 6629 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6630 | func addTLSUniqueTests() { |
| 6631 | for _, isClient := range []bool{false, true} { |
| 6632 | for _, isResumption := range []bool{false, true} { |
| 6633 | for _, hasEMS := range []bool{false, true} { |
| 6634 | var suffix string |
| 6635 | if isResumption { |
| 6636 | suffix = "Resume-" |
| 6637 | } else { |
| 6638 | suffix = "Full-" |
| 6639 | } |
| 6640 | |
| 6641 | if hasEMS { |
| 6642 | suffix += "EMS-" |
| 6643 | } else { |
| 6644 | suffix += "NoEMS-" |
| 6645 | } |
| 6646 | |
| 6647 | if isClient { |
| 6648 | suffix += "Client" |
| 6649 | } else { |
| 6650 | suffix += "Server" |
| 6651 | } |
| 6652 | |
| 6653 | test := testCase{ |
| 6654 | name: "TLSUnique-" + suffix, |
| 6655 | testTLSUnique: true, |
| 6656 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6657 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6658 | Bugs: ProtocolBugs{ |
| 6659 | NoExtendedMasterSecret: !hasEMS, |
| 6660 | }, |
| 6661 | }, |
| 6662 | } |
| 6663 | |
| 6664 | if isResumption { |
| 6665 | test.resumeSession = true |
| 6666 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6667 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 6668 | Bugs: ProtocolBugs{ |
| 6669 | NoExtendedMasterSecret: !hasEMS, |
| 6670 | }, |
| 6671 | } |
| 6672 | } |
| 6673 | |
| 6674 | if isResumption && !hasEMS { |
| 6675 | test.shouldFail = true |
| 6676 | test.expectedError = "failed to get tls-unique" |
| 6677 | } |
| 6678 | |
| 6679 | testCases = append(testCases, test) |
| 6680 | } |
| 6681 | } |
| 6682 | } |
| 6683 | } |
| 6684 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6685 | func addCustomExtensionTests() { |
| 6686 | expectedContents := "custom extension" |
| 6687 | emptyString := "" |
| 6688 | |
| 6689 | for _, isClient := range []bool{false, true} { |
| 6690 | suffix := "Server" |
| 6691 | flag := "-enable-server-custom-extension" |
| 6692 | testType := serverTest |
| 6693 | if isClient { |
| 6694 | suffix = "Client" |
| 6695 | flag = "-enable-client-custom-extension" |
| 6696 | testType = clientTest |
| 6697 | } |
| 6698 | |
| 6699 | testCases = append(testCases, testCase{ |
| 6700 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6701 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6702 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6703 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6704 | Bugs: ProtocolBugs{ |
| 6705 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6706 | ExpectedCustomExtension: &expectedContents, |
| 6707 | }, |
| 6708 | }, |
| 6709 | flags: []string{flag}, |
| 6710 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6711 | testCases = append(testCases, testCase{ |
| 6712 | testType: testType, |
| 6713 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 6714 | config: Config{ |
| 6715 | MaxVersion: VersionTLS13, |
| 6716 | Bugs: ProtocolBugs{ |
| 6717 | CustomExtension: expectedContents, |
| 6718 | ExpectedCustomExtension: &expectedContents, |
| 6719 | }, |
| 6720 | }, |
| 6721 | flags: []string{flag}, |
| 6722 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6723 | |
| 6724 | // If the parse callback fails, the handshake should also fail. |
| 6725 | testCases = append(testCases, testCase{ |
| 6726 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6727 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6728 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6729 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6730 | Bugs: ProtocolBugs{ |
| 6731 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6732 | ExpectedCustomExtension: &expectedContents, |
| 6733 | }, |
| 6734 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6735 | flags: []string{flag}, |
| 6736 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6737 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6738 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6739 | testCases = append(testCases, testCase{ |
| 6740 | testType: testType, |
| 6741 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 6742 | config: Config{ |
| 6743 | MaxVersion: VersionTLS13, |
| 6744 | Bugs: ProtocolBugs{ |
| 6745 | CustomExtension: expectedContents + "foo", |
| 6746 | ExpectedCustomExtension: &expectedContents, |
| 6747 | }, |
| 6748 | }, |
| 6749 | flags: []string{flag}, |
| 6750 | shouldFail: true, |
| 6751 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6752 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6753 | |
| 6754 | // If the add callback fails, the handshake should also fail. |
| 6755 | testCases = append(testCases, testCase{ |
| 6756 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6757 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6758 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6759 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6760 | Bugs: ProtocolBugs{ |
| 6761 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6762 | ExpectedCustomExtension: &expectedContents, |
| 6763 | }, |
| 6764 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6765 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6766 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6767 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6768 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6769 | testCases = append(testCases, testCase{ |
| 6770 | testType: testType, |
| 6771 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 6772 | config: Config{ |
| 6773 | MaxVersion: VersionTLS13, |
| 6774 | Bugs: ProtocolBugs{ |
| 6775 | CustomExtension: expectedContents, |
| 6776 | ExpectedCustomExtension: &expectedContents, |
| 6777 | }, |
| 6778 | }, |
| 6779 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 6780 | shouldFail: true, |
| 6781 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 6782 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6783 | |
| 6784 | // If the add callback returns zero, no extension should be |
| 6785 | // added. |
| 6786 | skipCustomExtension := expectedContents |
| 6787 | if isClient { |
| 6788 | // For the case where the client skips sending the |
| 6789 | // custom extension, the server must not “echo” it. |
| 6790 | skipCustomExtension = "" |
| 6791 | } |
| 6792 | testCases = append(testCases, testCase{ |
| 6793 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6794 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6795 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6796 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6797 | Bugs: ProtocolBugs{ |
| 6798 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6799 | ExpectedCustomExtension: &emptyString, |
| 6800 | }, |
| 6801 | }, |
| 6802 | flags: []string{flag, "-custom-extension-skip"}, |
| 6803 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6804 | testCases = append(testCases, testCase{ |
| 6805 | testType: testType, |
| 6806 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 6807 | config: Config{ |
| 6808 | MaxVersion: VersionTLS13, |
| 6809 | Bugs: ProtocolBugs{ |
| 6810 | CustomExtension: skipCustomExtension, |
| 6811 | ExpectedCustomExtension: &emptyString, |
| 6812 | }, |
| 6813 | }, |
| 6814 | flags: []string{flag, "-custom-extension-skip"}, |
| 6815 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6816 | } |
| 6817 | |
| 6818 | // The custom extension add callback should not be called if the client |
| 6819 | // doesn't send the extension. |
| 6820 | testCases = append(testCases, testCase{ |
| 6821 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6822 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6823 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6824 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 6825 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6826 | ExpectedCustomExtension: &emptyString, |
| 6827 | }, |
| 6828 | }, |
| 6829 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6830 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6831 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6832 | testCases = append(testCases, testCase{ |
| 6833 | testType: serverTest, |
| 6834 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 6835 | config: Config{ |
| 6836 | MaxVersion: VersionTLS13, |
| 6837 | Bugs: ProtocolBugs{ |
| 6838 | ExpectedCustomExtension: &emptyString, |
| 6839 | }, |
| 6840 | }, |
| 6841 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 6842 | }) |
| 6843 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6844 | // Test an unknown extension from the server. |
| 6845 | testCases = append(testCases, testCase{ |
| 6846 | testType: clientTest, |
| 6847 | name: "UnknownExtension-Client", |
| 6848 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6849 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6850 | Bugs: ProtocolBugs{ |
| 6851 | CustomExtension: expectedContents, |
| 6852 | }, |
| 6853 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 6854 | shouldFail: true, |
| 6855 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6856 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 6857 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6858 | testCases = append(testCases, testCase{ |
| 6859 | testType: clientTest, |
| 6860 | name: "UnknownExtension-Client-TLS13", |
| 6861 | config: Config{ |
| 6862 | MaxVersion: VersionTLS13, |
| 6863 | Bugs: ProtocolBugs{ |
| 6864 | CustomExtension: expectedContents, |
| 6865 | }, |
| 6866 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 6867 | shouldFail: true, |
| 6868 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6869 | expectedLocalError: "remote error: unsupported extension", |
| 6870 | }) |
| 6871 | |
| 6872 | // Test a known but unoffered extension from the server. |
| 6873 | testCases = append(testCases, testCase{ |
| 6874 | testType: clientTest, |
| 6875 | name: "UnofferedExtension-Client", |
| 6876 | config: Config{ |
| 6877 | MaxVersion: VersionTLS12, |
| 6878 | Bugs: ProtocolBugs{ |
| 6879 | SendALPN: "alpn", |
| 6880 | }, |
| 6881 | }, |
| 6882 | shouldFail: true, |
| 6883 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6884 | expectedLocalError: "remote error: unsupported extension", |
| 6885 | }) |
| 6886 | testCases = append(testCases, testCase{ |
| 6887 | testType: clientTest, |
| 6888 | name: "UnofferedExtension-Client-TLS13", |
| 6889 | config: Config{ |
| 6890 | MaxVersion: VersionTLS13, |
| 6891 | Bugs: ProtocolBugs{ |
| 6892 | SendALPN: "alpn", |
| 6893 | }, |
| 6894 | }, |
| 6895 | shouldFail: true, |
| 6896 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6897 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6898 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 6899 | } |
| 6900 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6901 | func addRSAClientKeyExchangeTests() { |
| 6902 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 6903 | testCases = append(testCases, testCase{ |
| 6904 | testType: serverTest, |
| 6905 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 6906 | config: Config{ |
| 6907 | // Ensure the ClientHello version and final |
| 6908 | // version are different, to detect if the |
| 6909 | // server uses the wrong one. |
| 6910 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6911 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6912 | Bugs: ProtocolBugs{ |
| 6913 | BadRSAClientKeyExchange: bad, |
| 6914 | }, |
| 6915 | }, |
| 6916 | shouldFail: true, |
| 6917 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 6918 | }) |
| 6919 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 6920 | |
| 6921 | // The server must compare whatever was in ClientHello.version for the |
| 6922 | // RSA premaster. |
| 6923 | testCases = append(testCases, testCase{ |
| 6924 | testType: serverTest, |
| 6925 | name: "SendClientVersion-RSA", |
| 6926 | config: Config{ |
| 6927 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6928 | Bugs: ProtocolBugs{ |
| 6929 | SendClientVersion: 0x1234, |
| 6930 | }, |
| 6931 | }, |
| 6932 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 6933 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 6934 | } |
| 6935 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6936 | var testCurves = []struct { |
| 6937 | name string |
| 6938 | id CurveID |
| 6939 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6940 | {"P-256", CurveP256}, |
| 6941 | {"P-384", CurveP384}, |
| 6942 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 6943 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6944 | } |
| 6945 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6946 | const bogusCurve = 0x1234 |
| 6947 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6948 | func addCurveTests() { |
| 6949 | for _, curve := range testCurves { |
| 6950 | testCases = append(testCases, testCase{ |
| 6951 | name: "CurveTest-Client-" + curve.name, |
| 6952 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6953 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6954 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6955 | CurvePreferences: []CurveID{curve.id}, |
| 6956 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6957 | flags: []string{ |
| 6958 | "-enable-all-curves", |
| 6959 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6960 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6961 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6962 | }) |
| 6963 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6964 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 6965 | config: Config{ |
| 6966 | MaxVersion: VersionTLS13, |
| 6967 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6968 | CurvePreferences: []CurveID{curve.id}, |
| 6969 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6970 | flags: []string{ |
| 6971 | "-enable-all-curves", |
| 6972 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6973 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6974 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6975 | }) |
| 6976 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6977 | testType: serverTest, |
| 6978 | name: "CurveTest-Server-" + curve.name, |
| 6979 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6980 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6981 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6982 | CurvePreferences: []CurveID{curve.id}, |
| 6983 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6984 | flags: []string{ |
| 6985 | "-enable-all-curves", |
| 6986 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 6987 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 6988 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 6989 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6990 | testCases = append(testCases, testCase{ |
| 6991 | testType: serverTest, |
| 6992 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 6993 | config: Config{ |
| 6994 | MaxVersion: VersionTLS13, |
| 6995 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6996 | CurvePreferences: []CurveID{curve.id}, |
| 6997 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 6998 | flags: []string{ |
| 6999 | "-enable-all-curves", |
| 7000 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 7001 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7002 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7003 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7004 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7005 | |
| 7006 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 7007 | testCases = append(testCases, testCase{ |
| 7008 | testType: serverTest, |
| 7009 | name: "UnknownCurve", |
| 7010 | config: Config{ |
| 7011 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7012 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 7013 | }, |
| 7014 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7015 | |
| 7016 | // The server must not consider ECDHE ciphers when there are no |
| 7017 | // supported curves. |
| 7018 | testCases = append(testCases, testCase{ |
| 7019 | testType: serverTest, |
| 7020 | name: "NoSupportedCurves", |
| 7021 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7022 | MaxVersion: VersionTLS12, |
| 7023 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7024 | Bugs: ProtocolBugs{ |
| 7025 | NoSupportedCurves: true, |
| 7026 | }, |
| 7027 | }, |
| 7028 | shouldFail: true, |
| 7029 | expectedError: ":NO_SHARED_CIPHER:", |
| 7030 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7031 | testCases = append(testCases, testCase{ |
| 7032 | testType: serverTest, |
| 7033 | name: "NoSupportedCurves-TLS13", |
| 7034 | config: Config{ |
| 7035 | MaxVersion: VersionTLS13, |
| 7036 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7037 | Bugs: ProtocolBugs{ |
| 7038 | NoSupportedCurves: true, |
| 7039 | }, |
| 7040 | }, |
| 7041 | shouldFail: true, |
| 7042 | expectedError: ":NO_SHARED_CIPHER:", |
| 7043 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7044 | |
| 7045 | // The server must fall back to another cipher when there are no |
| 7046 | // supported curves. |
| 7047 | testCases = append(testCases, testCase{ |
| 7048 | testType: serverTest, |
| 7049 | name: "NoCommonCurves", |
| 7050 | config: Config{ |
| 7051 | MaxVersion: VersionTLS12, |
| 7052 | CipherSuites: []uint16{ |
| 7053 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7054 | TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7055 | }, |
| 7056 | CurvePreferences: []CurveID{CurveP224}, |
| 7057 | }, |
| 7058 | expectedCipher: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7059 | }) |
| 7060 | |
| 7061 | // The client must reject bogus curves and disabled curves. |
| 7062 | testCases = append(testCases, testCase{ |
| 7063 | name: "BadECDHECurve", |
| 7064 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7065 | MaxVersion: VersionTLS12, |
| 7066 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7067 | Bugs: ProtocolBugs{ |
| 7068 | SendCurve: bogusCurve, |
| 7069 | }, |
| 7070 | }, |
| 7071 | shouldFail: true, |
| 7072 | expectedError: ":WRONG_CURVE:", |
| 7073 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7074 | testCases = append(testCases, testCase{ |
| 7075 | name: "BadECDHECurve-TLS13", |
| 7076 | config: Config{ |
| 7077 | MaxVersion: VersionTLS13, |
| 7078 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7079 | Bugs: ProtocolBugs{ |
| 7080 | SendCurve: bogusCurve, |
| 7081 | }, |
| 7082 | }, |
| 7083 | shouldFail: true, |
| 7084 | expectedError: ":WRONG_CURVE:", |
| 7085 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7086 | |
| 7087 | testCases = append(testCases, testCase{ |
| 7088 | name: "UnsupportedCurve", |
| 7089 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7090 | MaxVersion: VersionTLS12, |
| 7091 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7092 | CurvePreferences: []CurveID{CurveP256}, |
| 7093 | Bugs: ProtocolBugs{ |
| 7094 | IgnorePeerCurvePreferences: true, |
| 7095 | }, |
| 7096 | }, |
| 7097 | flags: []string{"-p384-only"}, |
| 7098 | shouldFail: true, |
| 7099 | expectedError: ":WRONG_CURVE:", |
| 7100 | }) |
| 7101 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 7102 | testCases = append(testCases, testCase{ |
| 7103 | // TODO(davidben): Add a TLS 1.3 version where |
| 7104 | // HelloRetryRequest requests an unsupported curve. |
| 7105 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 7106 | config: Config{ |
| 7107 | MaxVersion: VersionTLS12, |
| 7108 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7109 | CurvePreferences: []CurveID{CurveP384}, |
| 7110 | Bugs: ProtocolBugs{ |
| 7111 | SendCurve: CurveP256, |
| 7112 | }, |
| 7113 | }, |
| 7114 | flags: []string{"-p384-only"}, |
| 7115 | shouldFail: true, |
| 7116 | expectedError: ":WRONG_CURVE:", |
| 7117 | }) |
| 7118 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7119 | // Test invalid curve points. |
| 7120 | testCases = append(testCases, testCase{ |
| 7121 | name: "InvalidECDHPoint-Client", |
| 7122 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7123 | MaxVersion: VersionTLS12, |
| 7124 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7125 | CurvePreferences: []CurveID{CurveP256}, |
| 7126 | Bugs: ProtocolBugs{ |
| 7127 | InvalidECDHPoint: true, |
| 7128 | }, |
| 7129 | }, |
| 7130 | shouldFail: true, |
| 7131 | expectedError: ":INVALID_ENCODING:", |
| 7132 | }) |
| 7133 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7134 | name: "InvalidECDHPoint-Client-TLS13", |
| 7135 | config: Config{ |
| 7136 | MaxVersion: VersionTLS13, |
| 7137 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7138 | CurvePreferences: []CurveID{CurveP256}, |
| 7139 | Bugs: ProtocolBugs{ |
| 7140 | InvalidECDHPoint: true, |
| 7141 | }, |
| 7142 | }, |
| 7143 | shouldFail: true, |
| 7144 | expectedError: ":INVALID_ENCODING:", |
| 7145 | }) |
| 7146 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7147 | testType: serverTest, |
| 7148 | name: "InvalidECDHPoint-Server", |
| 7149 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7150 | MaxVersion: VersionTLS12, |
| 7151 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7152 | CurvePreferences: []CurveID{CurveP256}, |
| 7153 | Bugs: ProtocolBugs{ |
| 7154 | InvalidECDHPoint: true, |
| 7155 | }, |
| 7156 | }, |
| 7157 | shouldFail: true, |
| 7158 | expectedError: ":INVALID_ENCODING:", |
| 7159 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7160 | testCases = append(testCases, testCase{ |
| 7161 | testType: serverTest, |
| 7162 | name: "InvalidECDHPoint-Server-TLS13", |
| 7163 | config: Config{ |
| 7164 | MaxVersion: VersionTLS13, |
| 7165 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7166 | CurvePreferences: []CurveID{CurveP256}, |
| 7167 | Bugs: ProtocolBugs{ |
| 7168 | InvalidECDHPoint: true, |
| 7169 | }, |
| 7170 | }, |
| 7171 | shouldFail: true, |
| 7172 | expectedError: ":INVALID_ENCODING:", |
| 7173 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 7174 | } |
| 7175 | |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7176 | func addCECPQ1Tests() { |
| 7177 | testCases = append(testCases, testCase{ |
| 7178 | testType: clientTest, |
| 7179 | name: "CECPQ1-Client-BadX25519Part", |
| 7180 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7181 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7182 | MinVersion: VersionTLS12, |
| 7183 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7184 | Bugs: ProtocolBugs{ |
| 7185 | CECPQ1BadX25519Part: true, |
| 7186 | }, |
| 7187 | }, |
| 7188 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7189 | shouldFail: true, |
| 7190 | expectedLocalError: "local error: bad record MAC", |
| 7191 | }) |
| 7192 | testCases = append(testCases, testCase{ |
| 7193 | testType: clientTest, |
| 7194 | name: "CECPQ1-Client-BadNewhopePart", |
| 7195 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7196 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7197 | MinVersion: VersionTLS12, |
| 7198 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7199 | Bugs: ProtocolBugs{ |
| 7200 | CECPQ1BadNewhopePart: true, |
| 7201 | }, |
| 7202 | }, |
| 7203 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7204 | shouldFail: true, |
| 7205 | expectedLocalError: "local error: bad record MAC", |
| 7206 | }) |
| 7207 | testCases = append(testCases, testCase{ |
| 7208 | testType: serverTest, |
| 7209 | name: "CECPQ1-Server-BadX25519Part", |
| 7210 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7211 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7212 | MinVersion: VersionTLS12, |
| 7213 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7214 | Bugs: ProtocolBugs{ |
| 7215 | CECPQ1BadX25519Part: true, |
| 7216 | }, |
| 7217 | }, |
| 7218 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7219 | shouldFail: true, |
| 7220 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7221 | }) |
| 7222 | testCases = append(testCases, testCase{ |
| 7223 | testType: serverTest, |
| 7224 | name: "CECPQ1-Server-BadNewhopePart", |
| 7225 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7226 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 7227 | MinVersion: VersionTLS12, |
| 7228 | CipherSuites: []uint16{TLS_CECPQ1_RSA_WITH_AES_256_GCM_SHA384}, |
| 7229 | Bugs: ProtocolBugs{ |
| 7230 | CECPQ1BadNewhopePart: true, |
| 7231 | }, |
| 7232 | }, |
| 7233 | flags: []string{"-cipher", "kCECPQ1"}, |
| 7234 | shouldFail: true, |
| 7235 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7236 | }) |
| 7237 | } |
| 7238 | |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7239 | func addDHEGroupSizeTests() { |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7240 | testCases = append(testCases, testCase{ |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7241 | name: "DHEGroupSize-Client", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7242 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7243 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7244 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7245 | Bugs: ProtocolBugs{ |
| 7246 | // This is a 1234-bit prime number, generated |
| 7247 | // with: |
| 7248 | // openssl gendh 1234 | openssl asn1parse -i |
| 7249 | DHGroupPrime: bigFromHex("0215C589A86BE450D1255A86D7A08877A70E124C11F0C75E476BA6A2186B1C830D4A132555973F2D5881D5F737BB800B7F417C01EC5960AEBF79478F8E0BBB6A021269BD10590C64C57F50AD8169D5488B56EE38DC5E02DA1A16ED3B5F41FEB2AD184B78A31F3A5B2BEC8441928343DA35DE3D4F89F0D4CEDE0034045084A0D1E6182E5EF7FCA325DD33CE81BE7FA87D43613E8FA7A1457099AB53"), |
| 7250 | }, |
| 7251 | }, |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7252 | flags: []string{"-expect-dhe-group-size", "1234"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7253 | }) |
| 7254 | testCases = append(testCases, testCase{ |
| 7255 | testType: serverTest, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 7256 | name: "DHEGroupSize-Server", |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7257 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7258 | MaxVersion: VersionTLS12, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7259 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7260 | }, |
| 7261 | // bssl_shim as a server configures a 2048-bit DHE group. |
David Benjamin | 9e68f19 | 2016-06-30 14:55:33 -0400 | [diff] [blame] | 7262 | flags: []string{"-expect-dhe-group-size", "2048"}, |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7263 | }) |
David Benjamin | 4cc36ad | 2015-12-19 14:23:26 -0500 | [diff] [blame] | 7264 | } |
| 7265 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 7266 | func addTLS13RecordTests() { |
| 7267 | testCases = append(testCases, testCase{ |
| 7268 | name: "TLS13-RecordPadding", |
| 7269 | config: Config{ |
| 7270 | MaxVersion: VersionTLS13, |
| 7271 | MinVersion: VersionTLS13, |
| 7272 | Bugs: ProtocolBugs{ |
| 7273 | RecordPadding: 10, |
| 7274 | }, |
| 7275 | }, |
| 7276 | }) |
| 7277 | |
| 7278 | testCases = append(testCases, testCase{ |
| 7279 | name: "TLS13-EmptyRecords", |
| 7280 | config: Config{ |
| 7281 | MaxVersion: VersionTLS13, |
| 7282 | MinVersion: VersionTLS13, |
| 7283 | Bugs: ProtocolBugs{ |
| 7284 | OmitRecordContents: true, |
| 7285 | }, |
| 7286 | }, |
| 7287 | shouldFail: true, |
| 7288 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7289 | }) |
| 7290 | |
| 7291 | testCases = append(testCases, testCase{ |
| 7292 | name: "TLS13-OnlyPadding", |
| 7293 | config: Config{ |
| 7294 | MaxVersion: VersionTLS13, |
| 7295 | MinVersion: VersionTLS13, |
| 7296 | Bugs: ProtocolBugs{ |
| 7297 | OmitRecordContents: true, |
| 7298 | RecordPadding: 10, |
| 7299 | }, |
| 7300 | }, |
| 7301 | shouldFail: true, |
| 7302 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 7303 | }) |
| 7304 | |
| 7305 | testCases = append(testCases, testCase{ |
| 7306 | name: "TLS13-WrongOuterRecord", |
| 7307 | config: Config{ |
| 7308 | MaxVersion: VersionTLS13, |
| 7309 | MinVersion: VersionTLS13, |
| 7310 | Bugs: ProtocolBugs{ |
| 7311 | OuterRecordType: recordTypeHandshake, |
| 7312 | }, |
| 7313 | }, |
| 7314 | shouldFail: true, |
| 7315 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 7316 | }) |
| 7317 | } |
| 7318 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7319 | func addChangeCipherSpecTests() { |
| 7320 | // Test missing ChangeCipherSpecs. |
| 7321 | testCases = append(testCases, testCase{ |
| 7322 | name: "SkipChangeCipherSpec-Client", |
| 7323 | config: Config{ |
| 7324 | MaxVersion: VersionTLS12, |
| 7325 | Bugs: ProtocolBugs{ |
| 7326 | SkipChangeCipherSpec: true, |
| 7327 | }, |
| 7328 | }, |
| 7329 | shouldFail: true, |
| 7330 | expectedError: ":UNEXPECTED_RECORD:", |
| 7331 | }) |
| 7332 | testCases = append(testCases, testCase{ |
| 7333 | testType: serverTest, |
| 7334 | name: "SkipChangeCipherSpec-Server", |
| 7335 | config: Config{ |
| 7336 | MaxVersion: VersionTLS12, |
| 7337 | Bugs: ProtocolBugs{ |
| 7338 | SkipChangeCipherSpec: true, |
| 7339 | }, |
| 7340 | }, |
| 7341 | shouldFail: true, |
| 7342 | expectedError: ":UNEXPECTED_RECORD:", |
| 7343 | }) |
| 7344 | testCases = append(testCases, testCase{ |
| 7345 | testType: serverTest, |
| 7346 | name: "SkipChangeCipherSpec-Server-NPN", |
| 7347 | config: Config{ |
| 7348 | MaxVersion: VersionTLS12, |
| 7349 | NextProtos: []string{"bar"}, |
| 7350 | Bugs: ProtocolBugs{ |
| 7351 | SkipChangeCipherSpec: true, |
| 7352 | }, |
| 7353 | }, |
| 7354 | flags: []string{ |
| 7355 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7356 | }, |
| 7357 | shouldFail: true, |
| 7358 | expectedError: ":UNEXPECTED_RECORD:", |
| 7359 | }) |
| 7360 | |
| 7361 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 7362 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 7363 | // rejected. Test both with and without handshake packing to handle both |
| 7364 | // when the partial post-CCS message is in its own record and when it is |
| 7365 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7366 | for _, packed := range []bool{false, true} { |
| 7367 | var suffix string |
| 7368 | if packed { |
| 7369 | suffix = "-Packed" |
| 7370 | } |
| 7371 | |
| 7372 | testCases = append(testCases, testCase{ |
| 7373 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 7374 | config: Config{ |
| 7375 | MaxVersion: VersionTLS12, |
| 7376 | Bugs: ProtocolBugs{ |
| 7377 | FragmentAcrossChangeCipherSpec: true, |
| 7378 | PackHandshakeFlight: packed, |
| 7379 | }, |
| 7380 | }, |
| 7381 | shouldFail: true, |
| 7382 | expectedError: ":UNEXPECTED_RECORD:", |
| 7383 | }) |
| 7384 | testCases = append(testCases, testCase{ |
| 7385 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 7386 | config: Config{ |
| 7387 | MaxVersion: VersionTLS12, |
| 7388 | }, |
| 7389 | resumeSession: true, |
| 7390 | resumeConfig: &Config{ |
| 7391 | MaxVersion: VersionTLS12, |
| 7392 | Bugs: ProtocolBugs{ |
| 7393 | FragmentAcrossChangeCipherSpec: true, |
| 7394 | PackHandshakeFlight: packed, |
| 7395 | }, |
| 7396 | }, |
| 7397 | shouldFail: true, |
| 7398 | expectedError: ":UNEXPECTED_RECORD:", |
| 7399 | }) |
| 7400 | testCases = append(testCases, testCase{ |
| 7401 | testType: serverTest, |
| 7402 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 7403 | config: Config{ |
| 7404 | MaxVersion: VersionTLS12, |
| 7405 | Bugs: ProtocolBugs{ |
| 7406 | FragmentAcrossChangeCipherSpec: true, |
| 7407 | PackHandshakeFlight: packed, |
| 7408 | }, |
| 7409 | }, |
| 7410 | shouldFail: true, |
| 7411 | expectedError: ":UNEXPECTED_RECORD:", |
| 7412 | }) |
| 7413 | testCases = append(testCases, testCase{ |
| 7414 | testType: serverTest, |
| 7415 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 7416 | config: Config{ |
| 7417 | MaxVersion: VersionTLS12, |
| 7418 | }, |
| 7419 | resumeSession: true, |
| 7420 | resumeConfig: &Config{ |
| 7421 | MaxVersion: VersionTLS12, |
| 7422 | Bugs: ProtocolBugs{ |
| 7423 | FragmentAcrossChangeCipherSpec: true, |
| 7424 | PackHandshakeFlight: packed, |
| 7425 | }, |
| 7426 | }, |
| 7427 | shouldFail: true, |
| 7428 | expectedError: ":UNEXPECTED_RECORD:", |
| 7429 | }) |
| 7430 | testCases = append(testCases, testCase{ |
| 7431 | testType: serverTest, |
| 7432 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 7433 | config: Config{ |
| 7434 | MaxVersion: VersionTLS12, |
| 7435 | NextProtos: []string{"bar"}, |
| 7436 | Bugs: ProtocolBugs{ |
| 7437 | FragmentAcrossChangeCipherSpec: true, |
| 7438 | PackHandshakeFlight: packed, |
| 7439 | }, |
| 7440 | }, |
| 7441 | flags: []string{ |
| 7442 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 7443 | }, |
| 7444 | shouldFail: true, |
| 7445 | expectedError: ":UNEXPECTED_RECORD:", |
| 7446 | }) |
| 7447 | } |
| 7448 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 7449 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 7450 | // messages in the handshake queue. Do this by testing the server |
| 7451 | // reading the client Finished, reversing the flight so Finished comes |
| 7452 | // first. |
| 7453 | testCases = append(testCases, testCase{ |
| 7454 | protocol: dtls, |
| 7455 | testType: serverTest, |
| 7456 | name: "SendUnencryptedFinished-DTLS", |
| 7457 | config: Config{ |
| 7458 | MaxVersion: VersionTLS12, |
| 7459 | Bugs: ProtocolBugs{ |
| 7460 | SendUnencryptedFinished: true, |
| 7461 | ReverseHandshakeFragments: true, |
| 7462 | }, |
| 7463 | }, |
| 7464 | shouldFail: true, |
| 7465 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7466 | }) |
| 7467 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7468 | // Test synchronization between encryption changes and the handshake in |
| 7469 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 7470 | testCases = append(testCases, testCase{ |
| 7471 | name: "PartialEncryptedExtensionsWithServerHello", |
| 7472 | config: Config{ |
| 7473 | MaxVersion: VersionTLS13, |
| 7474 | Bugs: ProtocolBugs{ |
| 7475 | PartialEncryptedExtensionsWithServerHello: true, |
| 7476 | }, |
| 7477 | }, |
| 7478 | shouldFail: true, |
| 7479 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7480 | }) |
| 7481 | testCases = append(testCases, testCase{ |
| 7482 | testType: serverTest, |
| 7483 | name: "PartialClientFinishedWithClientHello", |
| 7484 | config: Config{ |
| 7485 | MaxVersion: VersionTLS13, |
| 7486 | Bugs: ProtocolBugs{ |
| 7487 | PartialClientFinishedWithClientHello: true, |
| 7488 | }, |
| 7489 | }, |
| 7490 | shouldFail: true, |
| 7491 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 7492 | }) |
| 7493 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 7494 | // Test that early ChangeCipherSpecs are handled correctly. |
| 7495 | testCases = append(testCases, testCase{ |
| 7496 | testType: serverTest, |
| 7497 | name: "EarlyChangeCipherSpec-server-1", |
| 7498 | config: Config{ |
| 7499 | MaxVersion: VersionTLS12, |
| 7500 | Bugs: ProtocolBugs{ |
| 7501 | EarlyChangeCipherSpec: 1, |
| 7502 | }, |
| 7503 | }, |
| 7504 | shouldFail: true, |
| 7505 | expectedError: ":UNEXPECTED_RECORD:", |
| 7506 | }) |
| 7507 | testCases = append(testCases, testCase{ |
| 7508 | testType: serverTest, |
| 7509 | name: "EarlyChangeCipherSpec-server-2", |
| 7510 | config: Config{ |
| 7511 | MaxVersion: VersionTLS12, |
| 7512 | Bugs: ProtocolBugs{ |
| 7513 | EarlyChangeCipherSpec: 2, |
| 7514 | }, |
| 7515 | }, |
| 7516 | shouldFail: true, |
| 7517 | expectedError: ":UNEXPECTED_RECORD:", |
| 7518 | }) |
| 7519 | testCases = append(testCases, testCase{ |
| 7520 | protocol: dtls, |
| 7521 | name: "StrayChangeCipherSpec", |
| 7522 | config: Config{ |
| 7523 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 7524 | // that stray ChangeCipherSpec messages are |
| 7525 | // rejected. |
| 7526 | MaxVersion: VersionTLS12, |
| 7527 | Bugs: ProtocolBugs{ |
| 7528 | StrayChangeCipherSpec: true, |
| 7529 | }, |
| 7530 | }, |
| 7531 | }) |
| 7532 | |
| 7533 | // Test that the contents of ChangeCipherSpec are checked. |
| 7534 | testCases = append(testCases, testCase{ |
| 7535 | name: "BadChangeCipherSpec-1", |
| 7536 | config: Config{ |
| 7537 | MaxVersion: VersionTLS12, |
| 7538 | Bugs: ProtocolBugs{ |
| 7539 | BadChangeCipherSpec: []byte{2}, |
| 7540 | }, |
| 7541 | }, |
| 7542 | shouldFail: true, |
| 7543 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7544 | }) |
| 7545 | testCases = append(testCases, testCase{ |
| 7546 | name: "BadChangeCipherSpec-2", |
| 7547 | config: Config{ |
| 7548 | MaxVersion: VersionTLS12, |
| 7549 | Bugs: ProtocolBugs{ |
| 7550 | BadChangeCipherSpec: []byte{1, 1}, |
| 7551 | }, |
| 7552 | }, |
| 7553 | shouldFail: true, |
| 7554 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7555 | }) |
| 7556 | testCases = append(testCases, testCase{ |
| 7557 | protocol: dtls, |
| 7558 | name: "BadChangeCipherSpec-DTLS-1", |
| 7559 | config: Config{ |
| 7560 | MaxVersion: VersionTLS12, |
| 7561 | Bugs: ProtocolBugs{ |
| 7562 | BadChangeCipherSpec: []byte{2}, |
| 7563 | }, |
| 7564 | }, |
| 7565 | shouldFail: true, |
| 7566 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7567 | }) |
| 7568 | testCases = append(testCases, testCase{ |
| 7569 | protocol: dtls, |
| 7570 | name: "BadChangeCipherSpec-DTLS-2", |
| 7571 | config: Config{ |
| 7572 | MaxVersion: VersionTLS12, |
| 7573 | Bugs: ProtocolBugs{ |
| 7574 | BadChangeCipherSpec: []byte{1, 1}, |
| 7575 | }, |
| 7576 | }, |
| 7577 | shouldFail: true, |
| 7578 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 7579 | }) |
| 7580 | } |
| 7581 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7582 | type perMessageTest struct { |
| 7583 | messageType uint8 |
| 7584 | test testCase |
| 7585 | } |
| 7586 | |
| 7587 | // makePerMessageTests returns a series of test templates which cover each |
| 7588 | // message in the TLS handshake. These may be used with bugs like |
| 7589 | // WrongMessageType to fully test a per-message bug. |
| 7590 | func makePerMessageTests() []perMessageTest { |
| 7591 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7592 | for _, protocol := range []protocol{tls, dtls} { |
| 7593 | var suffix string |
| 7594 | if protocol == dtls { |
| 7595 | suffix = "-DTLS" |
| 7596 | } |
| 7597 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7598 | ret = append(ret, perMessageTest{ |
| 7599 | messageType: typeClientHello, |
| 7600 | test: testCase{ |
| 7601 | protocol: protocol, |
| 7602 | testType: serverTest, |
| 7603 | name: "ClientHello" + suffix, |
| 7604 | config: Config{ |
| 7605 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7606 | }, |
| 7607 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7608 | }) |
| 7609 | |
| 7610 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7611 | ret = append(ret, perMessageTest{ |
| 7612 | messageType: typeHelloVerifyRequest, |
| 7613 | test: testCase{ |
| 7614 | protocol: protocol, |
| 7615 | name: "HelloVerifyRequest" + suffix, |
| 7616 | config: Config{ |
| 7617 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7618 | }, |
| 7619 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7620 | }) |
| 7621 | } |
| 7622 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7623 | ret = append(ret, perMessageTest{ |
| 7624 | messageType: typeServerHello, |
| 7625 | test: testCase{ |
| 7626 | protocol: protocol, |
| 7627 | name: "ServerHello" + suffix, |
| 7628 | config: Config{ |
| 7629 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7630 | }, |
| 7631 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7632 | }) |
| 7633 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7634 | ret = append(ret, perMessageTest{ |
| 7635 | messageType: typeCertificate, |
| 7636 | test: testCase{ |
| 7637 | protocol: protocol, |
| 7638 | name: "ServerCertificate" + suffix, |
| 7639 | config: Config{ |
| 7640 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7641 | }, |
| 7642 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7643 | }) |
| 7644 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7645 | ret = append(ret, perMessageTest{ |
| 7646 | messageType: typeCertificateStatus, |
| 7647 | test: testCase{ |
| 7648 | protocol: protocol, |
| 7649 | name: "CertificateStatus" + suffix, |
| 7650 | config: Config{ |
| 7651 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7652 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7653 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7654 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7655 | }) |
| 7656 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7657 | ret = append(ret, perMessageTest{ |
| 7658 | messageType: typeServerKeyExchange, |
| 7659 | test: testCase{ |
| 7660 | protocol: protocol, |
| 7661 | name: "ServerKeyExchange" + suffix, |
| 7662 | config: Config{ |
| 7663 | MaxVersion: VersionTLS12, |
| 7664 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7665 | }, |
| 7666 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7667 | }) |
| 7668 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7669 | ret = append(ret, perMessageTest{ |
| 7670 | messageType: typeCertificateRequest, |
| 7671 | test: testCase{ |
| 7672 | protocol: protocol, |
| 7673 | name: "CertificateRequest" + suffix, |
| 7674 | config: Config{ |
| 7675 | MaxVersion: VersionTLS12, |
| 7676 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7677 | }, |
| 7678 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7679 | }) |
| 7680 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7681 | ret = append(ret, perMessageTest{ |
| 7682 | messageType: typeServerHelloDone, |
| 7683 | test: testCase{ |
| 7684 | protocol: protocol, |
| 7685 | name: "ServerHelloDone" + suffix, |
| 7686 | config: Config{ |
| 7687 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7688 | }, |
| 7689 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7690 | }) |
| 7691 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7692 | ret = append(ret, perMessageTest{ |
| 7693 | messageType: typeCertificate, |
| 7694 | test: testCase{ |
| 7695 | testType: serverTest, |
| 7696 | protocol: protocol, |
| 7697 | name: "ClientCertificate" + suffix, |
| 7698 | config: Config{ |
| 7699 | Certificates: []Certificate{rsaCertificate}, |
| 7700 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7701 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7702 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7703 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7704 | }) |
| 7705 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7706 | ret = append(ret, perMessageTest{ |
| 7707 | messageType: typeCertificateVerify, |
| 7708 | test: testCase{ |
| 7709 | testType: serverTest, |
| 7710 | protocol: protocol, |
| 7711 | name: "CertificateVerify" + suffix, |
| 7712 | config: Config{ |
| 7713 | Certificates: []Certificate{rsaCertificate}, |
| 7714 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7715 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7716 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7717 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7718 | }) |
| 7719 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7720 | ret = append(ret, perMessageTest{ |
| 7721 | messageType: typeClientKeyExchange, |
| 7722 | test: testCase{ |
| 7723 | testType: serverTest, |
| 7724 | protocol: protocol, |
| 7725 | name: "ClientKeyExchange" + suffix, |
| 7726 | config: Config{ |
| 7727 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7728 | }, |
| 7729 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7730 | }) |
| 7731 | |
| 7732 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7733 | ret = append(ret, perMessageTest{ |
| 7734 | messageType: typeNextProtocol, |
| 7735 | test: testCase{ |
| 7736 | testType: serverTest, |
| 7737 | protocol: protocol, |
| 7738 | name: "NextProtocol" + suffix, |
| 7739 | config: Config{ |
| 7740 | MaxVersion: VersionTLS12, |
| 7741 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7742 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7743 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7744 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7745 | }) |
| 7746 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7747 | ret = append(ret, perMessageTest{ |
| 7748 | messageType: typeChannelID, |
| 7749 | test: testCase{ |
| 7750 | testType: serverTest, |
| 7751 | protocol: protocol, |
| 7752 | name: "ChannelID" + suffix, |
| 7753 | config: Config{ |
| 7754 | MaxVersion: VersionTLS12, |
| 7755 | ChannelID: channelIDKey, |
| 7756 | }, |
| 7757 | flags: []string{ |
| 7758 | "-expect-channel-id", |
| 7759 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7760 | }, |
| 7761 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7762 | }) |
| 7763 | } |
| 7764 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7765 | ret = append(ret, perMessageTest{ |
| 7766 | messageType: typeFinished, |
| 7767 | test: testCase{ |
| 7768 | testType: serverTest, |
| 7769 | protocol: protocol, |
| 7770 | name: "ClientFinished" + suffix, |
| 7771 | config: Config{ |
| 7772 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7773 | }, |
| 7774 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7775 | }) |
| 7776 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7777 | ret = append(ret, perMessageTest{ |
| 7778 | messageType: typeNewSessionTicket, |
| 7779 | test: testCase{ |
| 7780 | protocol: protocol, |
| 7781 | name: "NewSessionTicket" + suffix, |
| 7782 | config: Config{ |
| 7783 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7784 | }, |
| 7785 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7786 | }) |
| 7787 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7788 | ret = append(ret, perMessageTest{ |
| 7789 | messageType: typeFinished, |
| 7790 | test: testCase{ |
| 7791 | protocol: protocol, |
| 7792 | name: "ServerFinished" + suffix, |
| 7793 | config: Config{ |
| 7794 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7795 | }, |
| 7796 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7797 | }) |
| 7798 | |
| 7799 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7800 | |
| 7801 | ret = append(ret, perMessageTest{ |
| 7802 | messageType: typeClientHello, |
| 7803 | test: testCase{ |
| 7804 | testType: serverTest, |
| 7805 | name: "TLS13-ClientHello", |
| 7806 | config: Config{ |
| 7807 | MaxVersion: VersionTLS13, |
| 7808 | }, |
| 7809 | }, |
| 7810 | }) |
| 7811 | |
| 7812 | ret = append(ret, perMessageTest{ |
| 7813 | messageType: typeServerHello, |
| 7814 | test: testCase{ |
| 7815 | name: "TLS13-ServerHello", |
| 7816 | config: Config{ |
| 7817 | MaxVersion: VersionTLS13, |
| 7818 | }, |
| 7819 | }, |
| 7820 | }) |
| 7821 | |
| 7822 | ret = append(ret, perMessageTest{ |
| 7823 | messageType: typeEncryptedExtensions, |
| 7824 | test: testCase{ |
| 7825 | name: "TLS13-EncryptedExtensions", |
| 7826 | config: Config{ |
| 7827 | MaxVersion: VersionTLS13, |
| 7828 | }, |
| 7829 | }, |
| 7830 | }) |
| 7831 | |
| 7832 | ret = append(ret, perMessageTest{ |
| 7833 | messageType: typeCertificateRequest, |
| 7834 | test: testCase{ |
| 7835 | name: "TLS13-CertificateRequest", |
| 7836 | config: Config{ |
| 7837 | MaxVersion: VersionTLS13, |
| 7838 | ClientAuth: RequireAnyClientCert, |
| 7839 | }, |
| 7840 | }, |
| 7841 | }) |
| 7842 | |
| 7843 | ret = append(ret, perMessageTest{ |
| 7844 | messageType: typeCertificate, |
| 7845 | test: testCase{ |
| 7846 | name: "TLS13-ServerCertificate", |
| 7847 | config: Config{ |
| 7848 | MaxVersion: VersionTLS13, |
| 7849 | }, |
| 7850 | }, |
| 7851 | }) |
| 7852 | |
| 7853 | ret = append(ret, perMessageTest{ |
| 7854 | messageType: typeCertificateVerify, |
| 7855 | test: testCase{ |
| 7856 | name: "TLS13-ServerCertificateVerify", |
| 7857 | config: Config{ |
| 7858 | MaxVersion: VersionTLS13, |
| 7859 | }, |
| 7860 | }, |
| 7861 | }) |
| 7862 | |
| 7863 | ret = append(ret, perMessageTest{ |
| 7864 | messageType: typeFinished, |
| 7865 | test: testCase{ |
| 7866 | name: "TLS13-ServerFinished", |
| 7867 | config: Config{ |
| 7868 | MaxVersion: VersionTLS13, |
| 7869 | }, |
| 7870 | }, |
| 7871 | }) |
| 7872 | |
| 7873 | ret = append(ret, perMessageTest{ |
| 7874 | messageType: typeCertificate, |
| 7875 | test: testCase{ |
| 7876 | testType: serverTest, |
| 7877 | name: "TLS13-ClientCertificate", |
| 7878 | config: Config{ |
| 7879 | Certificates: []Certificate{rsaCertificate}, |
| 7880 | MaxVersion: VersionTLS13, |
| 7881 | }, |
| 7882 | flags: []string{"-require-any-client-certificate"}, |
| 7883 | }, |
| 7884 | }) |
| 7885 | |
| 7886 | ret = append(ret, perMessageTest{ |
| 7887 | messageType: typeCertificateVerify, |
| 7888 | test: testCase{ |
| 7889 | testType: serverTest, |
| 7890 | name: "TLS13-ClientCertificateVerify", |
| 7891 | config: Config{ |
| 7892 | Certificates: []Certificate{rsaCertificate}, |
| 7893 | MaxVersion: VersionTLS13, |
| 7894 | }, |
| 7895 | flags: []string{"-require-any-client-certificate"}, |
| 7896 | }, |
| 7897 | }) |
| 7898 | |
| 7899 | ret = append(ret, perMessageTest{ |
| 7900 | messageType: typeFinished, |
| 7901 | test: testCase{ |
| 7902 | testType: serverTest, |
| 7903 | name: "TLS13-ClientFinished", |
| 7904 | config: Config{ |
| 7905 | MaxVersion: VersionTLS13, |
| 7906 | }, |
| 7907 | }, |
| 7908 | }) |
| 7909 | |
| 7910 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 7911 | } |
| 7912 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7913 | func addWrongMessageTypeTests() { |
| 7914 | for _, t := range makePerMessageTests() { |
| 7915 | t.test.name = "WrongMessageType-" + t.test.name |
| 7916 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 7917 | t.test.shouldFail = true |
| 7918 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 7919 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7920 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7921 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 7922 | // In TLS 1.3, a bad ServerHello means the client sends |
| 7923 | // an unencrypted alert while the server expects |
| 7924 | // encryption, so the alert is not readable by runner. |
| 7925 | t.test.expectedLocalError = "local error: bad record MAC" |
| 7926 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7927 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 7928 | testCases = append(testCases, t.test) |
| 7929 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7930 | } |
| 7931 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 7932 | func addTrailingMessageDataTests() { |
| 7933 | for _, t := range makePerMessageTests() { |
| 7934 | t.test.name = "TrailingMessageData-" + t.test.name |
| 7935 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 7936 | t.test.shouldFail = true |
| 7937 | t.test.expectedError = ":DECODE_ERROR:" |
| 7938 | t.test.expectedLocalError = "remote error: error decoding message" |
| 7939 | |
| 7940 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 7941 | // In TLS 1.3, a bad ServerHello means the client sends |
| 7942 | // an unencrypted alert while the server expects |
| 7943 | // encryption, so the alert is not readable by runner. |
| 7944 | t.test.expectedLocalError = "local error: bad record MAC" |
| 7945 | } |
| 7946 | |
| 7947 | if t.messageType == typeFinished { |
| 7948 | // Bad Finished messages read as the verify data having |
| 7949 | // the wrong length. |
| 7950 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 7951 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 7952 | } |
| 7953 | |
| 7954 | testCases = append(testCases, t.test) |
| 7955 | } |
| 7956 | } |
| 7957 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7958 | func addTLS13HandshakeTests() { |
| 7959 | testCases = append(testCases, testCase{ |
| 7960 | testType: clientTest, |
| 7961 | name: "MissingKeyShare-Client", |
| 7962 | config: Config{ |
| 7963 | MaxVersion: VersionTLS13, |
| 7964 | Bugs: ProtocolBugs{ |
| 7965 | MissingKeyShare: true, |
| 7966 | }, |
| 7967 | }, |
| 7968 | shouldFail: true, |
| 7969 | expectedError: ":MISSING_KEY_SHARE:", |
| 7970 | }) |
| 7971 | |
| 7972 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 7973 | testType: serverTest, |
| 7974 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7975 | config: Config{ |
| 7976 | MaxVersion: VersionTLS13, |
| 7977 | Bugs: ProtocolBugs{ |
| 7978 | MissingKeyShare: true, |
| 7979 | }, |
| 7980 | }, |
| 7981 | shouldFail: true, |
| 7982 | expectedError: ":MISSING_KEY_SHARE:", |
| 7983 | }) |
| 7984 | |
| 7985 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7986 | testType: serverTest, |
| 7987 | name: "DuplicateKeyShares", |
| 7988 | config: Config{ |
| 7989 | MaxVersion: VersionTLS13, |
| 7990 | Bugs: ProtocolBugs{ |
| 7991 | DuplicateKeyShares: true, |
| 7992 | }, |
| 7993 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 7994 | shouldFail: true, |
| 7995 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7996 | }) |
| 7997 | |
| 7998 | testCases = append(testCases, testCase{ |
| 7999 | testType: clientTest, |
| 8000 | name: "EmptyEncryptedExtensions", |
| 8001 | config: Config{ |
| 8002 | MaxVersion: VersionTLS13, |
| 8003 | Bugs: ProtocolBugs{ |
| 8004 | EmptyEncryptedExtensions: true, |
| 8005 | }, |
| 8006 | }, |
| 8007 | shouldFail: true, |
| 8008 | expectedLocalError: "remote error: error decoding message", |
| 8009 | }) |
| 8010 | |
| 8011 | testCases = append(testCases, testCase{ |
| 8012 | testType: clientTest, |
| 8013 | name: "EncryptedExtensionsWithKeyShare", |
| 8014 | config: Config{ |
| 8015 | MaxVersion: VersionTLS13, |
| 8016 | Bugs: ProtocolBugs{ |
| 8017 | EncryptedExtensionsWithKeyShare: true, |
| 8018 | }, |
| 8019 | }, |
| 8020 | shouldFail: true, |
| 8021 | expectedLocalError: "remote error: unsupported extension", |
| 8022 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8023 | |
| 8024 | testCases = append(testCases, testCase{ |
| 8025 | testType: serverTest, |
| 8026 | name: "SendHelloRetryRequest", |
| 8027 | config: Config{ |
| 8028 | MaxVersion: VersionTLS13, |
| 8029 | // Require a HelloRetryRequest for every curve. |
| 8030 | DefaultCurves: []CurveID{}, |
| 8031 | }, |
| 8032 | expectedCurveID: CurveX25519, |
| 8033 | }) |
| 8034 | |
| 8035 | testCases = append(testCases, testCase{ |
| 8036 | testType: serverTest, |
| 8037 | name: "SendHelloRetryRequest-2", |
| 8038 | config: Config{ |
| 8039 | MaxVersion: VersionTLS13, |
| 8040 | DefaultCurves: []CurveID{CurveP384}, |
| 8041 | }, |
| 8042 | // Although the ClientHello did not predict our preferred curve, |
| 8043 | // we always select it whether it is predicted or not. |
| 8044 | expectedCurveID: CurveX25519, |
| 8045 | }) |
| 8046 | |
| 8047 | testCases = append(testCases, testCase{ |
| 8048 | name: "UnknownCurve-HelloRetryRequest", |
| 8049 | config: Config{ |
| 8050 | MaxVersion: VersionTLS13, |
| 8051 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8052 | CurvePreferences: []CurveID{CurveP384}, |
| 8053 | Bugs: ProtocolBugs{ |
| 8054 | SendHelloRetryRequestCurve: bogusCurve, |
| 8055 | }, |
| 8056 | }, |
| 8057 | shouldFail: true, |
| 8058 | expectedError: ":WRONG_CURVE:", |
| 8059 | }) |
| 8060 | |
| 8061 | testCases = append(testCases, testCase{ |
| 8062 | name: "DisabledCurve-HelloRetryRequest", |
| 8063 | config: Config{ |
| 8064 | MaxVersion: VersionTLS13, |
| 8065 | CurvePreferences: []CurveID{CurveP256}, |
| 8066 | Bugs: ProtocolBugs{ |
| 8067 | IgnorePeerCurvePreferences: true, |
| 8068 | }, |
| 8069 | }, |
| 8070 | flags: []string{"-p384-only"}, |
| 8071 | shouldFail: true, |
| 8072 | expectedError: ":WRONG_CURVE:", |
| 8073 | }) |
| 8074 | |
| 8075 | testCases = append(testCases, testCase{ |
| 8076 | name: "UnnecessaryHelloRetryRequest", |
| 8077 | config: Config{ |
| 8078 | MaxVersion: VersionTLS13, |
| 8079 | Bugs: ProtocolBugs{ |
| 8080 | UnnecessaryHelloRetryRequest: true, |
| 8081 | }, |
| 8082 | }, |
| 8083 | shouldFail: true, |
| 8084 | expectedError: ":WRONG_CURVE:", |
| 8085 | }) |
| 8086 | |
| 8087 | testCases = append(testCases, testCase{ |
| 8088 | name: "SecondHelloRetryRequest", |
| 8089 | config: Config{ |
| 8090 | MaxVersion: VersionTLS13, |
| 8091 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8092 | CurvePreferences: []CurveID{CurveP384}, |
| 8093 | Bugs: ProtocolBugs{ |
| 8094 | SecondHelloRetryRequest: true, |
| 8095 | }, |
| 8096 | }, |
| 8097 | shouldFail: true, |
| 8098 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 8099 | }) |
| 8100 | |
| 8101 | testCases = append(testCases, testCase{ |
| 8102 | testType: serverTest, |
| 8103 | name: "SecondClientHelloMissingKeyShare", |
| 8104 | config: Config{ |
| 8105 | MaxVersion: VersionTLS13, |
| 8106 | DefaultCurves: []CurveID{}, |
| 8107 | Bugs: ProtocolBugs{ |
| 8108 | SecondClientHelloMissingKeyShare: true, |
| 8109 | }, |
| 8110 | }, |
| 8111 | shouldFail: true, |
| 8112 | expectedError: ":MISSING_KEY_SHARE:", |
| 8113 | }) |
| 8114 | |
| 8115 | testCases = append(testCases, testCase{ |
| 8116 | testType: serverTest, |
| 8117 | name: "SecondClientHelloWrongCurve", |
| 8118 | config: Config{ |
| 8119 | MaxVersion: VersionTLS13, |
| 8120 | DefaultCurves: []CurveID{}, |
| 8121 | Bugs: ProtocolBugs{ |
| 8122 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 8123 | }, |
| 8124 | }, |
| 8125 | shouldFail: true, |
| 8126 | expectedError: ":WRONG_CURVE:", |
| 8127 | }) |
| 8128 | |
| 8129 | testCases = append(testCases, testCase{ |
| 8130 | name: "HelloRetryRequestVersionMismatch", |
| 8131 | config: Config{ |
| 8132 | MaxVersion: VersionTLS13, |
| 8133 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8134 | CurvePreferences: []CurveID{CurveP384}, |
| 8135 | Bugs: ProtocolBugs{ |
| 8136 | SendServerHelloVersion: 0x0305, |
| 8137 | }, |
| 8138 | }, |
| 8139 | shouldFail: true, |
| 8140 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 8141 | }) |
| 8142 | |
| 8143 | testCases = append(testCases, testCase{ |
| 8144 | name: "HelloRetryRequestCurveMismatch", |
| 8145 | config: Config{ |
| 8146 | MaxVersion: VersionTLS13, |
| 8147 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8148 | CurvePreferences: []CurveID{CurveP384}, |
| 8149 | Bugs: ProtocolBugs{ |
| 8150 | // Send P-384 (correct) in the HelloRetryRequest. |
| 8151 | SendHelloRetryRequestCurve: CurveP384, |
| 8152 | // But send P-256 in the ServerHello. |
| 8153 | SendCurve: CurveP256, |
| 8154 | }, |
| 8155 | }, |
| 8156 | shouldFail: true, |
| 8157 | expectedError: ":WRONG_CURVE:", |
| 8158 | }) |
| 8159 | |
| 8160 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 8161 | // without sending it. |
| 8162 | testCases = append(testCases, testCase{ |
| 8163 | name: "SkipHelloRetryRequest", |
| 8164 | config: Config{ |
| 8165 | MaxVersion: VersionTLS13, |
| 8166 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 8167 | CurvePreferences: []CurveID{CurveP384}, |
| 8168 | Bugs: ProtocolBugs{ |
| 8169 | SkipHelloRetryRequest: true, |
| 8170 | }, |
| 8171 | }, |
| 8172 | shouldFail: true, |
| 8173 | expectedError: ":WRONG_CURVE:", |
| 8174 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 8175 | |
| 8176 | testCases = append(testCases, testCase{ |
| 8177 | name: "TLS13-RequestContextInHandshake", |
| 8178 | config: Config{ |
| 8179 | MaxVersion: VersionTLS13, |
| 8180 | MinVersion: VersionTLS13, |
| 8181 | ClientAuth: RequireAnyClientCert, |
| 8182 | Bugs: ProtocolBugs{ |
| 8183 | SendRequestContext: []byte("request context"), |
| 8184 | }, |
| 8185 | }, |
| 8186 | flags: []string{ |
| 8187 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8188 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8189 | }, |
| 8190 | shouldFail: true, |
| 8191 | expectedError: ":DECODE_ERROR:", |
| 8192 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 8193 | |
| 8194 | testCases = append(testCases, testCase{ |
| 8195 | testType: serverTest, |
| 8196 | name: "TLS13-TrailingKeyShareData", |
| 8197 | config: Config{ |
| 8198 | MaxVersion: VersionTLS13, |
| 8199 | Bugs: ProtocolBugs{ |
| 8200 | TrailingKeyShareData: true, |
| 8201 | }, |
| 8202 | }, |
| 8203 | shouldFail: true, |
| 8204 | expectedError: ":DECODE_ERROR:", |
| 8205 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8206 | } |
| 8207 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8208 | func addPeekTests() { |
| 8209 | // Test SSL_peek works, including on empty records. |
| 8210 | testCases = append(testCases, testCase{ |
| 8211 | name: "Peek-Basic", |
| 8212 | sendEmptyRecords: 1, |
| 8213 | flags: []string{"-peek-then-read"}, |
| 8214 | }) |
| 8215 | |
| 8216 | // Test SSL_peek can drive the initial handshake. |
| 8217 | testCases = append(testCases, testCase{ |
| 8218 | name: "Peek-ImplicitHandshake", |
| 8219 | flags: []string{ |
| 8220 | "-peek-then-read", |
| 8221 | "-implicit-handshake", |
| 8222 | }, |
| 8223 | }) |
| 8224 | |
| 8225 | // Test SSL_peek can discover and drive a renegotiation. |
| 8226 | testCases = append(testCases, testCase{ |
| 8227 | name: "Peek-Renegotiate", |
| 8228 | config: Config{ |
| 8229 | MaxVersion: VersionTLS12, |
| 8230 | }, |
| 8231 | renegotiate: 1, |
| 8232 | flags: []string{ |
| 8233 | "-peek-then-read", |
| 8234 | "-renegotiate-freely", |
| 8235 | "-expect-total-renegotiations", "1", |
| 8236 | }, |
| 8237 | }) |
| 8238 | |
| 8239 | // Test SSL_peek can discover a close_notify. |
| 8240 | testCases = append(testCases, testCase{ |
| 8241 | name: "Peek-Shutdown", |
| 8242 | config: Config{ |
| 8243 | Bugs: ProtocolBugs{ |
| 8244 | ExpectCloseNotify: true, |
| 8245 | }, |
| 8246 | }, |
| 8247 | flags: []string{ |
| 8248 | "-peek-then-read", |
| 8249 | "-check-close-notify", |
| 8250 | }, |
| 8251 | }) |
| 8252 | |
| 8253 | // Test SSL_peek can discover an alert. |
| 8254 | testCases = append(testCases, testCase{ |
| 8255 | name: "Peek-Alert", |
| 8256 | config: Config{ |
| 8257 | Bugs: ProtocolBugs{ |
| 8258 | SendSpuriousAlert: alertRecordOverflow, |
| 8259 | }, |
| 8260 | }, |
| 8261 | flags: []string{"-peek-then-read"}, |
| 8262 | shouldFail: true, |
| 8263 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 8264 | }) |
| 8265 | |
| 8266 | // Test SSL_peek can handle KeyUpdate. |
| 8267 | testCases = append(testCases, testCase{ |
| 8268 | name: "Peek-KeyUpdate", |
| 8269 | config: Config{ |
| 8270 | MaxVersion: VersionTLS13, |
| 8271 | Bugs: ProtocolBugs{ |
| 8272 | SendKeyUpdateBeforeEveryAppDataRecord: true, |
| 8273 | }, |
| 8274 | }, |
| 8275 | flags: []string{"-peek-then-read"}, |
| 8276 | }) |
| 8277 | } |
| 8278 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8279 | 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] | 8280 | defer wg.Done() |
| 8281 | |
| 8282 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8283 | var err error |
| 8284 | |
| 8285 | if *mallocTest < 0 { |
| 8286 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8287 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8288 | } else { |
| 8289 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 8290 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8291 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 8292 | if err != nil { |
| 8293 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 8294 | } |
| 8295 | break |
| 8296 | } |
| 8297 | } |
| 8298 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8299 | statusChan <- statusMsg{test: test, err: err} |
| 8300 | } |
| 8301 | } |
| 8302 | |
| 8303 | type statusMsg struct { |
| 8304 | test *testCase |
| 8305 | started bool |
| 8306 | err error |
| 8307 | } |
| 8308 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8309 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8310 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8311 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8312 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8313 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8314 | if !*pipe { |
| 8315 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 8316 | var erase string |
| 8317 | for i := 0; i < lineLen; i++ { |
| 8318 | erase += "\b \b" |
| 8319 | } |
| 8320 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8321 | } |
| 8322 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8323 | if msg.started { |
| 8324 | started++ |
| 8325 | } else { |
| 8326 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8327 | |
| 8328 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8329 | if msg.err == errUnimplemented { |
| 8330 | if *pipe { |
| 8331 | // Print each test instead of a status line. |
| 8332 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 8333 | } |
| 8334 | unimplemented++ |
| 8335 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 8336 | } else { |
| 8337 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 8338 | failed++ |
| 8339 | testOutput.addResult(msg.test.name, "FAIL") |
| 8340 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8341 | } else { |
| 8342 | if *pipe { |
| 8343 | // Print each test instead of a status line. |
| 8344 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 8345 | } |
| 8346 | testOutput.addResult(msg.test.name, "PASS") |
| 8347 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8348 | } |
| 8349 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8350 | if !*pipe { |
| 8351 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8352 | 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] | 8353 | lineLen = len(line) |
| 8354 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8355 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8356 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8357 | |
| 8358 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8359 | } |
| 8360 | |
| 8361 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8362 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8363 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8364 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8365 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8366 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8367 | addCipherSuiteTests() |
| 8368 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8369 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 8370 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 8371 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 8372 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 8373 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 8374 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 8375 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 8376 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 8377 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 8378 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 8379 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8380 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8381 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8382 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8383 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8384 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8385 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8386 | addCurveTests() |
Matt Braithwaite | 54217e4 | 2016-06-13 13:03:47 -0700 | [diff] [blame] | 8387 | addCECPQ1Tests() |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8388 | addDHEGroupSizeTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8389 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 8390 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8391 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 8392 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 8393 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8394 | addTLS13HandshakeTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 8395 | addPeekTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8396 | |
| 8397 | var wg sync.WaitGroup |
| 8398 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8399 | statusChan := make(chan statusMsg, *numWorkers) |
| 8400 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8401 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8402 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8403 | if len(*shimConfigFile) != 0 { |
| 8404 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 8405 | if err != nil { |
| 8406 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 8407 | os.Exit(1) |
| 8408 | } |
| 8409 | |
| 8410 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 8411 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 8412 | os.Exit(1) |
| 8413 | } |
| 8414 | } |
| 8415 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8416 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8417 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8418 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8419 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8420 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8421 | } |
| 8422 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8423 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8424 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8425 | matched := true |
| 8426 | if len(*testToRun) != 0 { |
| 8427 | var err error |
| 8428 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 8429 | if err != nil { |
| 8430 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 8431 | os.Exit(1) |
| 8432 | } |
| 8433 | } |
| 8434 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8435 | if !*includeDisabled { |
| 8436 | for pattern := range shimConfig.DisabledTests { |
| 8437 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 8438 | if err != nil { |
| 8439 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 8440 | os.Exit(1) |
| 8441 | } |
| 8442 | |
| 8443 | if isDisabled { |
| 8444 | matched = false |
| 8445 | break |
| 8446 | } |
| 8447 | } |
| 8448 | } |
| 8449 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8450 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8451 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 8452 | testChan <- &testCases[i] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8453 | } |
| 8454 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 8455 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8456 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 8457 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 8458 | os.Exit(1) |
| 8459 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8460 | |
| 8461 | close(testChan) |
| 8462 | wg.Wait() |
| 8463 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8464 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8465 | |
| 8466 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 8467 | |
| 8468 | if *jsonOutput != "" { |
| 8469 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 8470 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 8471 | } |
| 8472 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 8473 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 8474 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 8475 | os.Exit(1) |
| 8476 | } |
| 8477 | |
| 8478 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 8479 | os.Exit(1) |
| 8480 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 8481 | } |