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" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 21 | "crypto/rand" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 22 | "crypto/x509" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 23 | "crypto/x509/pkix" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 24 | "encoding/base64" |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 25 | "encoding/hex" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 26 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 27 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 28 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 29 | "flag" |
| 30 | "fmt" |
| 31 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 32 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 33 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 34 | "net" |
| 35 | "os" |
| 36 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 37 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 38 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 39 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 40 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 41 | "strings" |
| 42 | "sync" |
| 43 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 44 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 45 | ) |
| 46 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 47 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 48 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 49 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 50 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 51 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 52 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 53 | 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.") |
| 54 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 55 | 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] | 56 | 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] | 57 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 58 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 59 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 60 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 61 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 62 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 63 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 64 | 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] | 65 | 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] | 66 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 67 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 68 | includeDHE = flag.Bool("include-dhe", false, "If true, test DHE ciphersuites.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 69 | repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 70 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 71 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 72 | // ShimConfigurations is used with the “json” package and represents a shim |
| 73 | // config file. |
| 74 | type ShimConfiguration struct { |
| 75 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 76 | // The glob pattern is used to exclude tests from being run and the |
| 77 | // freeform string is unparsed but expected to explain why the test is |
| 78 | // disabled. |
| 79 | DisabledTests map[string]string |
| 80 | |
| 81 | // ErrorMap maps from expected error strings to the correct error |
| 82 | // string for the shim in question. For example, it might map |
| 83 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 84 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 85 | ErrorMap map[string]string |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 86 | |
| 87 | // HalfRTTTickets is the number of half-RTT tickets the client should |
| 88 | // expect before half-RTT data when testing 0-RTT. |
| 89 | HalfRTTTickets int |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 90 | } |
| 91 | |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 92 | // Setup shimConfig defaults aligning with BoringSSL. |
| 93 | var shimConfig ShimConfiguration = ShimConfiguration{ |
| 94 | HalfRTTTickets: 2, |
| 95 | } |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 96 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 97 | type testCert int |
| 98 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 99 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 100 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 101 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 102 | testCertRSAChain |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 103 | testCertECDSAP224 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 104 | testCertECDSAP256 |
| 105 | testCertECDSAP384 |
| 106 | testCertECDSAP521 |
| 107 | ) |
| 108 | |
| 109 | const ( |
| 110 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 111 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 112 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 113 | ecdsaP224CertificateFile = "ecdsa_p224_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 114 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 115 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 116 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 117 | ) |
| 118 | |
| 119 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 120 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 121 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 122 | rsaChainKeyFile = "rsa_chain_key.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 123 | ecdsaP224KeyFile = "ecdsa_p224_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 124 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 125 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 126 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 127 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 128 | ) |
| 129 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 130 | var ( |
| 131 | rsaCertificate Certificate |
| 132 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 133 | rsaChainCertificate Certificate |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 134 | ecdsaP224Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 135 | ecdsaP256Certificate Certificate |
| 136 | ecdsaP384Certificate Certificate |
| 137 | ecdsaP521Certificate Certificate |
| 138 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 139 | |
| 140 | var testCerts = []struct { |
| 141 | id testCert |
| 142 | certFile, keyFile string |
| 143 | cert *Certificate |
| 144 | }{ |
| 145 | { |
| 146 | id: testCertRSA, |
| 147 | certFile: rsaCertificateFile, |
| 148 | keyFile: rsaKeyFile, |
| 149 | cert: &rsaCertificate, |
| 150 | }, |
| 151 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 152 | id: testCertRSA1024, |
| 153 | certFile: rsa1024CertificateFile, |
| 154 | keyFile: rsa1024KeyFile, |
| 155 | cert: &rsa1024Certificate, |
| 156 | }, |
| 157 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 158 | id: testCertRSAChain, |
| 159 | certFile: rsaChainCertificateFile, |
| 160 | keyFile: rsaChainKeyFile, |
| 161 | cert: &rsaChainCertificate, |
| 162 | }, |
| 163 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 164 | id: testCertECDSAP224, |
| 165 | certFile: ecdsaP224CertificateFile, |
| 166 | keyFile: ecdsaP224KeyFile, |
| 167 | cert: &ecdsaP224Certificate, |
| 168 | }, |
| 169 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 170 | id: testCertECDSAP256, |
| 171 | certFile: ecdsaP256CertificateFile, |
| 172 | keyFile: ecdsaP256KeyFile, |
| 173 | cert: &ecdsaP256Certificate, |
| 174 | }, |
| 175 | { |
| 176 | id: testCertECDSAP384, |
| 177 | certFile: ecdsaP384CertificateFile, |
| 178 | keyFile: ecdsaP384KeyFile, |
| 179 | cert: &ecdsaP384Certificate, |
| 180 | }, |
| 181 | { |
| 182 | id: testCertECDSAP521, |
| 183 | certFile: ecdsaP521CertificateFile, |
| 184 | keyFile: ecdsaP521KeyFile, |
| 185 | cert: &ecdsaP521Certificate, |
| 186 | }, |
| 187 | } |
| 188 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 189 | var channelIDKey *ecdsa.PrivateKey |
| 190 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 191 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 192 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 193 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 194 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 195 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 196 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 197 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 198 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 199 | for i := range testCerts { |
| 200 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 201 | if err != nil { |
| 202 | panic(err) |
| 203 | } |
| 204 | cert.OCSPStaple = testOCSPResponse |
| 205 | cert.SignedCertificateTimestampList = testSCTList |
| 206 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 208 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 209 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 210 | if err != nil { |
| 211 | panic(err) |
| 212 | } |
| 213 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 214 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 215 | panic("bad key type") |
| 216 | } |
| 217 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 218 | if err != nil { |
| 219 | panic(err) |
| 220 | } |
| 221 | if channelIDKey.Curve != elliptic.P256() { |
| 222 | panic("bad curve") |
| 223 | } |
| 224 | |
| 225 | channelIDBytes = make([]byte, 64) |
| 226 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 227 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 228 | } |
| 229 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 230 | func getRunnerCertificate(t testCert) Certificate { |
| 231 | for _, cert := range testCerts { |
| 232 | if cert.id == t { |
| 233 | return *cert.cert |
| 234 | } |
| 235 | } |
| 236 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 237 | } |
| 238 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 239 | func getShimCertificate(t testCert) string { |
| 240 | for _, cert := range testCerts { |
| 241 | if cert.id == t { |
| 242 | return cert.certFile |
| 243 | } |
| 244 | } |
| 245 | panic("Unknown test certificate") |
| 246 | } |
| 247 | |
| 248 | func getShimKey(t testCert) string { |
| 249 | for _, cert := range testCerts { |
| 250 | if cert.id == t { |
| 251 | return cert.keyFile |
| 252 | } |
| 253 | } |
| 254 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 257 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 258 | func encodeDERValues(values [][]byte) string { |
| 259 | var ret string |
| 260 | for i, v := range values { |
| 261 | if i > 0 { |
| 262 | ret += "," |
| 263 | } |
| 264 | ret += hex.EncodeToString(v) |
| 265 | } |
| 266 | |
| 267 | return ret |
| 268 | } |
| 269 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 270 | type testType int |
| 271 | |
| 272 | const ( |
| 273 | clientTest testType = iota |
| 274 | serverTest |
| 275 | ) |
| 276 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 277 | type protocol int |
| 278 | |
| 279 | const ( |
| 280 | tls protocol = iota |
| 281 | dtls |
| 282 | ) |
| 283 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 284 | const ( |
| 285 | alpn = 1 |
| 286 | npn = 2 |
| 287 | ) |
| 288 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 289 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 290 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 291 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 292 | name string |
| 293 | config Config |
| 294 | shouldFail bool |
| 295 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 296 | // expectedLocalError, if not empty, contains a substring that must be |
| 297 | // found in the local error. |
| 298 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 299 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 300 | // negotiated. |
| 301 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 302 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 303 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 304 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 305 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 306 | // should be negotiated. |
| 307 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 308 | // expectChannelID controls whether the connection should have |
| 309 | // negotiated a Channel ID with channelIDKey. |
| 310 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 311 | // expectedNextProto controls whether the connection should |
| 312 | // negotiate a next protocol via NPN or ALPN. |
| 313 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 314 | // expectNoNextProto, if true, means that no next protocol should be |
| 315 | // negotiated. |
| 316 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 317 | // expectedNextProtoType, if non-zero, is the expected next |
| 318 | // protocol negotiation mechanism. |
| 319 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 320 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 321 | // should be negotiated. If zero, none should be negotiated. |
| 322 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 323 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 324 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 325 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 326 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 327 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 328 | // algorithm that the peer should have used in the handshake. |
| 329 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 330 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 331 | // have used. |
| 332 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 333 | // messageLen is the length, in bytes, of the test message that will be |
| 334 | // sent. |
| 335 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 336 | // messageCount is the number of test messages that will be sent. |
| 337 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 338 | // certFile is the path to the certificate to use for the server. |
| 339 | certFile string |
| 340 | // keyFile is the path to the private key to use for the server. |
| 341 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 342 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 343 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 344 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 345 | // resumeRenewedSession controls whether a third connection should be |
| 346 | // tested which attempts to resume the second connection's session. |
| 347 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 348 | // expectResumeRejected, if true, specifies that the attempted |
| 349 | // resumption must be rejected by the client. This is only valid for a |
| 350 | // serverTest. |
| 351 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 352 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 353 | // resumption. Unless newSessionsOnResume is set, |
| 354 | // SessionTicketKey, ServerSessionCache, and |
| 355 | // ClientSessionCache are copied from the initial connection's |
| 356 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 357 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 358 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 359 | // use a different session resumption context. |
| 360 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 361 | // noSessionCache, if true, will cause the server to run without a |
| 362 | // session cache. |
| 363 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 364 | // sendPrefix sends a prefix on the socket before actually performing a |
| 365 | // handshake. |
| 366 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 367 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 368 | // message before doing a roundtrip with the runner. |
| 369 | shimWritesFirst bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 370 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 371 | // connection immediately after the handshake rather than echoing |
| 372 | // messages from the runner. |
| 373 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 374 | // renegotiate indicates the number of times the connection should be |
| 375 | // renegotiated during the exchange. |
| 376 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 377 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 378 | // HelloRequest when the handshake completes. |
| 379 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 380 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 381 | // switched in just before renegotiation. |
| 382 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 383 | // replayWrites, if true, configures the underlying transport |
| 384 | // to replay every write it makes in DTLS tests. |
| 385 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 386 | // damageFirstWrite, if true, configures the underlying transport to |
| 387 | // damage the final byte of the first application data write. |
| 388 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 389 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 390 | // keying material and verify they match. |
| 391 | exportKeyingMaterial int |
| 392 | exportLabel string |
| 393 | exportContext string |
| 394 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 395 | // flags, if not empty, contains a list of command-line flags that will |
| 396 | // be passed to the shim program. |
| 397 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 398 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 399 | // which will be compared against the expected value. |
| 400 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 401 | // sendEmptyRecords is the number of consecutive empty records to send |
| 402 | // before and after the test message. |
| 403 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 404 | // sendWarningAlerts is the number of consecutive warning alerts to send |
| 405 | // before and after the test message. |
| 406 | sendWarningAlerts int |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 407 | // sendKeyUpdates is the number of consecutive key updates to send |
| 408 | // before and after the test message. |
| 409 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 410 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 411 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 412 | // expectMessageDropped, if true, means the test message is expected to |
| 413 | // be dropped by the client rather than echoed back. |
| 414 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 415 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 416 | // is expected to send. |
| 417 | expectPeerCertificate *Certificate |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 420 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 421 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 422 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 423 | if len(data) == 0 { |
| 424 | return |
| 425 | } |
| 426 | |
| 427 | protocol := "tls" |
| 428 | if test.protocol == dtls { |
| 429 | protocol = "dtls" |
| 430 | } |
| 431 | |
| 432 | side := "client" |
| 433 | if test.testType == serverTest { |
| 434 | side = "server" |
| 435 | } |
| 436 | |
| 437 | dir := path.Join(*transcriptDir, protocol, side) |
| 438 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 439 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 440 | return |
| 441 | } |
| 442 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 443 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 444 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 445 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 446 | } |
| 447 | } |
| 448 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 449 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 450 | type timeoutConn struct { |
| 451 | net.Conn |
| 452 | timeout time.Duration |
| 453 | } |
| 454 | |
| 455 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 456 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 457 | return 0, err |
| 458 | } |
| 459 | return t.Conn.Read(b) |
| 460 | } |
| 461 | |
| 462 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 463 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 464 | return 0, err |
| 465 | } |
| 466 | return t.Conn.Write(b) |
| 467 | } |
| 468 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 469 | 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] | 470 | if !test.noSessionCache { |
| 471 | if config.ClientSessionCache == nil { |
| 472 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 473 | } |
| 474 | if config.ServerSessionCache == nil { |
| 475 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 476 | } |
| 477 | } |
| 478 | if test.testType == clientTest { |
| 479 | if len(config.Certificates) == 0 { |
| 480 | config.Certificates = []Certificate{rsaCertificate} |
| 481 | } |
| 482 | } else { |
| 483 | // Supply a ServerName to ensure a constant session cache key, |
| 484 | // rather than falling back to net.Conn.RemoteAddr. |
| 485 | if len(config.ServerName) == 0 { |
| 486 | config.ServerName = "test" |
| 487 | } |
| 488 | } |
| 489 | if *fuzzer { |
| 490 | config.Bugs.NullAllCiphers = true |
| 491 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 492 | if *deterministic { |
| 493 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 494 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 495 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 496 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 497 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 498 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 499 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 500 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 501 | } |
| 502 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 503 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 504 | local, peer := "client", "server" |
| 505 | if test.testType == clientTest { |
| 506 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 507 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 508 | connDebug := &recordingConn{ |
| 509 | Conn: conn, |
| 510 | isDatagram: test.protocol == dtls, |
| 511 | local: local, |
| 512 | peer: peer, |
| 513 | } |
| 514 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 515 | if *flagDebug { |
| 516 | defer connDebug.WriteTo(os.Stdout) |
| 517 | } |
| 518 | if len(*transcriptDir) != 0 { |
| 519 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 520 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 521 | }() |
| 522 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 523 | |
| 524 | if config.Bugs.PacketAdaptor != nil { |
| 525 | config.Bugs.PacketAdaptor.debug = connDebug |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | if test.replayWrites { |
| 530 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 531 | } |
| 532 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 533 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 534 | if test.damageFirstWrite { |
| 535 | connDamage = newDamageAdaptor(conn) |
| 536 | conn = connDamage |
| 537 | } |
| 538 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 539 | if test.sendPrefix != "" { |
| 540 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 541 | return err |
| 542 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 543 | } |
| 544 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 545 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 546 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 547 | if test.protocol == dtls { |
| 548 | tlsConn = DTLSServer(conn, config) |
| 549 | } else { |
| 550 | tlsConn = Server(conn, config) |
| 551 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 552 | } else { |
| 553 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 554 | if test.protocol == dtls { |
| 555 | tlsConn = DTLSClient(conn, config) |
| 556 | } else { |
| 557 | tlsConn = Client(conn, config) |
| 558 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 559 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 560 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 561 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 562 | if err := tlsConn.Handshake(); err != nil { |
| 563 | return err |
| 564 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 565 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 566 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 567 | // expectations struct that can be specified separately for the two |
| 568 | // legs. |
| 569 | expectedVersion := test.expectedVersion |
| 570 | if isResume && test.expectedResumeVersion != 0 { |
| 571 | expectedVersion = test.expectedResumeVersion |
| 572 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 573 | connState := tlsConn.ConnectionState() |
| 574 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 575 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 576 | } |
| 577 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 578 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 579 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 580 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 581 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 582 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 583 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 584 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 585 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 586 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 587 | if channelID == nil { |
| 588 | return fmt.Errorf("no channel ID negotiated") |
| 589 | } |
| 590 | if channelID.Curve != channelIDKey.Curve || |
| 591 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 592 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 593 | return fmt.Errorf("incorrect channel ID") |
| 594 | } |
| 595 | } |
| 596 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 597 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 598 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 599 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 600 | } |
| 601 | } |
| 602 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 603 | if test.expectNoNextProto { |
| 604 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 605 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 606 | } |
| 607 | } |
| 608 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 609 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 610 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 611 | return fmt.Errorf("next proto type mismatch") |
| 612 | } |
| 613 | } |
| 614 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 615 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 616 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 617 | } |
| 618 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 619 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 620 | 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] | 621 | } |
| 622 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 623 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 624 | return fmt.Errorf("SCT list mismatch") |
| 625 | } |
| 626 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 627 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 628 | 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] | 629 | } |
| 630 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 631 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 632 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 633 | } |
| 634 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 635 | if test.expectPeerCertificate != nil { |
| 636 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 637 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 638 | } |
| 639 | for i, cert := range connState.PeerCertificates { |
| 640 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 641 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 646 | if test.exportKeyingMaterial > 0 { |
| 647 | actual := make([]byte, test.exportKeyingMaterial) |
| 648 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 649 | return err |
| 650 | } |
| 651 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 652 | if err != nil { |
| 653 | return err |
| 654 | } |
| 655 | if !bytes.Equal(actual, expected) { |
| 656 | return fmt.Errorf("keying material mismatch") |
| 657 | } |
| 658 | } |
| 659 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 660 | if test.testTLSUnique { |
| 661 | var peersValue [12]byte |
| 662 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 663 | return err |
| 664 | } |
| 665 | expected := tlsConn.ConnectionState().TLSUnique |
| 666 | if !bytes.Equal(peersValue[:], expected) { |
| 667 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 668 | } |
| 669 | } |
| 670 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 671 | if test.shimWritesFirst { |
| 672 | var buf [5]byte |
| 673 | _, err := io.ReadFull(tlsConn, buf[:]) |
| 674 | if err != nil { |
| 675 | return err |
| 676 | } |
| 677 | if string(buf[:]) != "hello" { |
| 678 | return fmt.Errorf("bad initial message") |
| 679 | } |
| 680 | } |
| 681 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 682 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 683 | if err := tlsConn.SendKeyUpdate(test.keyUpdateRequest); err != nil { |
David Benjamin | 7f0965a | 2016-09-30 15:14:01 -0400 | [diff] [blame] | 684 | return err |
| 685 | } |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 686 | } |
| 687 | |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 688 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 689 | tlsConn.Write(nil) |
| 690 | } |
| 691 | |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 692 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 693 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 694 | } |
| 695 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 696 | if test.sendHalfHelloRequest { |
| 697 | tlsConn.SendHalfHelloRequest() |
| 698 | } |
| 699 | |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 700 | if test.renegotiate > 0 { |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 701 | if test.renegotiateCiphers != nil { |
| 702 | config.CipherSuites = test.renegotiateCiphers |
| 703 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 704 | for i := 0; i < test.renegotiate; i++ { |
| 705 | if err := tlsConn.Renegotiate(); err != nil { |
| 706 | return err |
| 707 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 708 | } |
| 709 | } else if test.renegotiateCiphers != nil { |
| 710 | panic("renegotiateCiphers without renegotiate") |
| 711 | } |
| 712 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 713 | if test.damageFirstWrite { |
| 714 | connDamage.setDamage(true) |
| 715 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 716 | connDamage.setDamage(false) |
| 717 | } |
| 718 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 719 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 720 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 721 | if test.protocol == dtls { |
| 722 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 723 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 724 | // Read until EOF. |
| 725 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 726 | return err |
| 727 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 728 | if messageLen == 0 { |
| 729 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 730 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 731 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 732 | messageCount := test.messageCount |
| 733 | if messageCount == 0 { |
| 734 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 735 | } |
| 736 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 737 | for j := 0; j < messageCount; j++ { |
| 738 | testMessage := make([]byte, messageLen) |
| 739 | for i := range testMessage { |
| 740 | testMessage[i] = 0x42 ^ byte(j) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 741 | } |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 742 | tlsConn.Write(testMessage) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 743 | |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 744 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 745 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 746 | } |
| 747 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 748 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 749 | tlsConn.Write(nil) |
| 750 | } |
| 751 | |
| 752 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 753 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 754 | } |
| 755 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 756 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 757 | // The shim will not respond. |
| 758 | continue |
| 759 | } |
| 760 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 761 | buf := make([]byte, len(testMessage)) |
| 762 | if test.protocol == dtls { |
| 763 | bufTmp := make([]byte, len(buf)+1) |
| 764 | n, err := tlsConn.Read(bufTmp) |
| 765 | if err != nil { |
| 766 | return err |
| 767 | } |
| 768 | if n != len(buf) { |
| 769 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 770 | } |
| 771 | copy(buf, bufTmp) |
| 772 | } else { |
| 773 | _, err := io.ReadFull(tlsConn, buf) |
| 774 | if err != nil { |
| 775 | return err |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | for i, v := range buf { |
| 780 | if v != testMessage[i]^0xff { |
| 781 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 782 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | |
| 786 | return nil |
| 787 | } |
| 788 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 789 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 790 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 791 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 792 | 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] | 793 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 794 | valgrindArgs = append(valgrindArgs, path) |
| 795 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 796 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 797 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 798 | } |
| 799 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 800 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 801 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 802 | xtermArgs = append(xtermArgs, path) |
| 803 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 804 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 805 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 806 | } |
| 807 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 808 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 809 | xtermArgs := []string{"-e", "lldb", "--"} |
| 810 | xtermArgs = append(xtermArgs, path) |
| 811 | xtermArgs = append(xtermArgs, args...) |
| 812 | |
| 813 | return exec.Command("xterm", xtermArgs...) |
| 814 | } |
| 815 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 816 | var ( |
| 817 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 818 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 819 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 820 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 821 | // accept accepts a connection from listener, unless waitChan signals a process |
| 822 | // exit first. |
| 823 | func acceptOrWait(listener net.Listener, waitChan chan error) (net.Conn, error) { |
| 824 | type connOrError struct { |
| 825 | conn net.Conn |
| 826 | err error |
| 827 | } |
| 828 | connChan := make(chan connOrError, 1) |
| 829 | go func() { |
| 830 | conn, err := listener.Accept() |
| 831 | connChan <- connOrError{conn, err} |
| 832 | close(connChan) |
| 833 | }() |
| 834 | select { |
| 835 | case result := <-connChan: |
| 836 | return result.conn, result.err |
| 837 | case childErr := <-waitChan: |
| 838 | waitChan <- childErr |
| 839 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 840 | } |
| 841 | } |
| 842 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 843 | func translateExpectedError(errorStr string) string { |
| 844 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 845 | return translated |
| 846 | } |
| 847 | |
| 848 | if *looseErrors { |
| 849 | return "" |
| 850 | } |
| 851 | |
| 852 | return errorStr |
| 853 | } |
| 854 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 855 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 856 | // Help debugging panics on the Go side. |
| 857 | defer func() { |
| 858 | if r := recover(); r != nil { |
| 859 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 860 | panic(r) |
| 861 | } |
| 862 | }() |
| 863 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 864 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 865 | panic("Error expected without shouldFail in " + test.name) |
| 866 | } |
| 867 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 868 | if test.expectResumeRejected && !test.resumeSession { |
| 869 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 870 | } |
| 871 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 872 | for _, ver := range tlsVersions { |
| 873 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 874 | continue |
| 875 | } |
| 876 | |
| 877 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 878 | continue |
| 879 | } |
| 880 | |
| 881 | panic(fmt.Sprintf("The name of test %q suggests that it's version specific, but min/max version in the Config is %x/%x. One of them should probably be %x", test.name, test.config.MinVersion, test.config.MaxVersion, ver.version)) |
| 882 | } |
| 883 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 884 | listener, err := net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 885 | if err != nil { |
| 886 | panic(err) |
| 887 | } |
| 888 | defer func() { |
| 889 | if listener != nil { |
| 890 | listener.Close() |
| 891 | } |
| 892 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 893 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 894 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 895 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 896 | flags = append(flags, "-server") |
| 897 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 898 | flags = append(flags, "-key-file") |
| 899 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 900 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 901 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 902 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | flags = append(flags, "-cert-file") |
| 906 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 907 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 908 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 909 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 910 | } |
| 911 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 912 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 913 | if test.protocol == dtls { |
| 914 | flags = append(flags, "-dtls") |
| 915 | } |
| 916 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 917 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 918 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 919 | resumeCount++ |
| 920 | if test.resumeRenewedSession { |
| 921 | resumeCount++ |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | if resumeCount > 0 { |
| 926 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 927 | } |
| 928 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 929 | if test.shimWritesFirst { |
| 930 | flags = append(flags, "-shim-writes-first") |
| 931 | } |
| 932 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 933 | if test.shimShutsDown { |
| 934 | flags = append(flags, "-shim-shuts-down") |
| 935 | } |
| 936 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 937 | if test.exportKeyingMaterial > 0 { |
| 938 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 939 | flags = append(flags, "-export-label", test.exportLabel) |
| 940 | flags = append(flags, "-export-context", test.exportContext) |
| 941 | if test.useExportContext { |
| 942 | flags = append(flags, "-use-export-context") |
| 943 | } |
| 944 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 945 | if test.expectResumeRejected { |
| 946 | flags = append(flags, "-expect-session-miss") |
| 947 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 948 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 949 | if test.testTLSUnique { |
| 950 | flags = append(flags, "-tls-unique") |
| 951 | } |
| 952 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 953 | flags = append(flags, test.flags...) |
| 954 | |
| 955 | var shim *exec.Cmd |
| 956 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 957 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 958 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 959 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 960 | } else if *useLLDB { |
| 961 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 962 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 963 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 964 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 965 | shim.Stdin = os.Stdin |
| 966 | var stdoutBuf, stderrBuf bytes.Buffer |
| 967 | shim.Stdout = &stdoutBuf |
| 968 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 969 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 970 | shim.Env = os.Environ() |
| 971 | 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] | 972 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 973 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 974 | } |
| 975 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 976 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 977 | |
| 978 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 979 | panic(err) |
| 980 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 981 | waitChan := make(chan error, 1) |
| 982 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 983 | |
| 984 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 985 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 986 | if *deterministic { |
| 987 | config.Rand = &deterministicRand{} |
| 988 | } |
| 989 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 990 | conn, err := acceptOrWait(listener, waitChan) |
| 991 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 992 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 993 | conn.Close() |
| 994 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 995 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 996 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 997 | var resumeConfig Config |
| 998 | if test.resumeConfig != nil { |
| 999 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1000 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1001 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1002 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1003 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1004 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1005 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1006 | } else { |
| 1007 | resumeConfig = config |
| 1008 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1009 | var connResume net.Conn |
| 1010 | connResume, err = acceptOrWait(listener, waitChan) |
| 1011 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 1012 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1013 | connResume.Close() |
| 1014 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1015 | } |
| 1016 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1017 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1018 | // open more connections than expected. |
| 1019 | listener.Close() |
| 1020 | listener = nil |
| 1021 | |
| 1022 | childErr := <-waitChan |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1023 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1024 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1025 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1026 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1027 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1028 | case 89: |
| 1029 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1030 | case 99: |
| 1031 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1032 | } |
| 1033 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1034 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1035 | // Account for Windows line endings. |
| 1036 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1037 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1038 | |
| 1039 | // Separate the errors from the shim and those from tools like |
| 1040 | // AddressSanitizer. |
| 1041 | var extraStderr string |
| 1042 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1043 | stderr = stderrParts[0] |
| 1044 | extraStderr = stderrParts[1] |
| 1045 | } |
| 1046 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1047 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1048 | expectedError := translateExpectedError(test.expectedError) |
| 1049 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1050 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1051 | localError := "none" |
| 1052 | if err != nil { |
| 1053 | localError = err.Error() |
| 1054 | } |
| 1055 | if len(test.expectedLocalError) != 0 { |
| 1056 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1057 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1058 | |
| 1059 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1060 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1061 | if childErr != nil { |
| 1062 | childError = childErr.Error() |
| 1063 | } |
| 1064 | |
| 1065 | var msg string |
| 1066 | switch { |
| 1067 | case failed && !test.shouldFail: |
| 1068 | msg = "unexpected failure" |
| 1069 | case !failed && test.shouldFail: |
| 1070 | msg = "unexpected success" |
| 1071 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1072 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1073 | default: |
| 1074 | panic("internal error") |
| 1075 | } |
| 1076 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1077 | 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] | 1078 | } |
| 1079 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1080 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1081 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1084 | if *useValgrind && isValgrindError { |
| 1085 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1086 | } |
| 1087 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1088 | return nil |
| 1089 | } |
| 1090 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1091 | type tlsVersion struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1092 | name string |
| 1093 | version uint16 |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 1094 | flag string |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1095 | hasDTLS bool |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1096 | } |
| 1097 | |
| 1098 | var tlsVersions = []tlsVersion{ |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1099 | {"SSL3", VersionSSL30, "-no-ssl3", false}, |
| 1100 | {"TLS1", VersionTLS10, "-no-tls1", true}, |
| 1101 | {"TLS11", VersionTLS11, "-no-tls11", false}, |
| 1102 | {"TLS12", VersionTLS12, "-no-tls12", true}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1103 | {"TLS13", VersionTLS13, "-no-tls13", false}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1104 | } |
| 1105 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1106 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1107 | name string |
| 1108 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1112 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1113 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1114 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1115 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1116 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1117 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1118 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1119 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1120 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1121 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1122 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1123 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1124 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1125 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1126 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1127 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1128 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1129 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1130 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1131 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1132 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1133 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1134 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1135 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1136 | {"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] | 1137 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1138 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1139 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1140 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1141 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1144 | func hasComponent(suiteName, component string) bool { |
| 1145 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1146 | } |
| 1147 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1148 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1149 | return hasComponent(suiteName, "GCM") || |
| 1150 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1151 | hasComponent(suiteName, "SHA384") || |
| 1152 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1153 | } |
| 1154 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1155 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1156 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1159 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1160 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1161 | } |
| 1162 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1163 | func bigFromHex(hex string) *big.Int { |
| 1164 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1165 | if !ok { |
| 1166 | panic("failed to parse hex number 0x" + hex) |
| 1167 | } |
| 1168 | return ret |
| 1169 | } |
| 1170 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1171 | func addBasicTests() { |
| 1172 | basicTests := []testCase{ |
| 1173 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1174 | name: "NoFallbackSCSV", |
| 1175 | config: Config{ |
| 1176 | Bugs: ProtocolBugs{ |
| 1177 | FailIfNotFallbackSCSV: true, |
| 1178 | }, |
| 1179 | }, |
| 1180 | shouldFail: true, |
| 1181 | expectedLocalError: "no fallback SCSV found", |
| 1182 | }, |
| 1183 | { |
| 1184 | name: "SendFallbackSCSV", |
| 1185 | config: Config{ |
| 1186 | Bugs: ProtocolBugs{ |
| 1187 | FailIfNotFallbackSCSV: true, |
| 1188 | }, |
| 1189 | }, |
| 1190 | flags: []string{"-fallback-scsv"}, |
| 1191 | }, |
| 1192 | { |
| 1193 | name: "ClientCertificateTypes", |
| 1194 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1195 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1196 | ClientAuth: RequestClientCert, |
| 1197 | ClientCertificateTypes: []byte{ |
| 1198 | CertTypeDSSSign, |
| 1199 | CertTypeRSASign, |
| 1200 | CertTypeECDSASign, |
| 1201 | }, |
| 1202 | }, |
| 1203 | flags: []string{ |
| 1204 | "-expect-certificate-types", |
| 1205 | base64.StdEncoding.EncodeToString([]byte{ |
| 1206 | CertTypeDSSSign, |
| 1207 | CertTypeRSASign, |
| 1208 | CertTypeECDSASign, |
| 1209 | }), |
| 1210 | }, |
| 1211 | }, |
| 1212 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1213 | name: "UnauthenticatedECDH", |
| 1214 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1215 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1216 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1217 | Bugs: ProtocolBugs{ |
| 1218 | UnauthenticatedECDH: true, |
| 1219 | }, |
| 1220 | }, |
| 1221 | shouldFail: true, |
| 1222 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1223 | }, |
| 1224 | { |
| 1225 | name: "SkipCertificateStatus", |
| 1226 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1227 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1228 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1229 | Bugs: ProtocolBugs{ |
| 1230 | SkipCertificateStatus: true, |
| 1231 | }, |
| 1232 | }, |
| 1233 | flags: []string{ |
| 1234 | "-enable-ocsp-stapling", |
| 1235 | }, |
| 1236 | }, |
| 1237 | { |
| 1238 | name: "SkipServerKeyExchange", |
| 1239 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1240 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1241 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1242 | Bugs: ProtocolBugs{ |
| 1243 | SkipServerKeyExchange: true, |
| 1244 | }, |
| 1245 | }, |
| 1246 | shouldFail: true, |
| 1247 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1248 | }, |
| 1249 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1250 | testType: serverTest, |
| 1251 | name: "Alert", |
| 1252 | config: Config{ |
| 1253 | Bugs: ProtocolBugs{ |
| 1254 | SendSpuriousAlert: alertRecordOverflow, |
| 1255 | }, |
| 1256 | }, |
| 1257 | shouldFail: true, |
| 1258 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1259 | }, |
| 1260 | { |
| 1261 | protocol: dtls, |
| 1262 | testType: serverTest, |
| 1263 | name: "Alert-DTLS", |
| 1264 | config: Config{ |
| 1265 | Bugs: ProtocolBugs{ |
| 1266 | SendSpuriousAlert: alertRecordOverflow, |
| 1267 | }, |
| 1268 | }, |
| 1269 | shouldFail: true, |
| 1270 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1271 | }, |
| 1272 | { |
| 1273 | testType: serverTest, |
| 1274 | name: "FragmentAlert", |
| 1275 | config: Config{ |
| 1276 | Bugs: ProtocolBugs{ |
| 1277 | FragmentAlert: true, |
| 1278 | SendSpuriousAlert: alertRecordOverflow, |
| 1279 | }, |
| 1280 | }, |
| 1281 | shouldFail: true, |
| 1282 | expectedError: ":BAD_ALERT:", |
| 1283 | }, |
| 1284 | { |
| 1285 | protocol: dtls, |
| 1286 | testType: serverTest, |
| 1287 | name: "FragmentAlert-DTLS", |
| 1288 | config: Config{ |
| 1289 | Bugs: ProtocolBugs{ |
| 1290 | FragmentAlert: true, |
| 1291 | SendSpuriousAlert: alertRecordOverflow, |
| 1292 | }, |
| 1293 | }, |
| 1294 | shouldFail: true, |
| 1295 | expectedError: ":BAD_ALERT:", |
| 1296 | }, |
| 1297 | { |
| 1298 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1299 | name: "DoubleAlert", |
| 1300 | config: Config{ |
| 1301 | Bugs: ProtocolBugs{ |
| 1302 | DoubleAlert: true, |
| 1303 | SendSpuriousAlert: alertRecordOverflow, |
| 1304 | }, |
| 1305 | }, |
| 1306 | shouldFail: true, |
| 1307 | expectedError: ":BAD_ALERT:", |
| 1308 | }, |
| 1309 | { |
| 1310 | protocol: dtls, |
| 1311 | testType: serverTest, |
| 1312 | name: "DoubleAlert-DTLS", |
| 1313 | config: Config{ |
| 1314 | Bugs: ProtocolBugs{ |
| 1315 | DoubleAlert: true, |
| 1316 | SendSpuriousAlert: alertRecordOverflow, |
| 1317 | }, |
| 1318 | }, |
| 1319 | shouldFail: true, |
| 1320 | expectedError: ":BAD_ALERT:", |
| 1321 | }, |
| 1322 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1323 | name: "SkipNewSessionTicket", |
| 1324 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1325 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1326 | Bugs: ProtocolBugs{ |
| 1327 | SkipNewSessionTicket: true, |
| 1328 | }, |
| 1329 | }, |
| 1330 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1331 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1332 | }, |
| 1333 | { |
| 1334 | testType: serverTest, |
| 1335 | name: "FallbackSCSV", |
| 1336 | config: Config{ |
| 1337 | MaxVersion: VersionTLS11, |
| 1338 | Bugs: ProtocolBugs{ |
| 1339 | SendFallbackSCSV: true, |
| 1340 | }, |
| 1341 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1342 | shouldFail: true, |
| 1343 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1344 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1345 | }, |
| 1346 | { |
| 1347 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1348 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1349 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1350 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1351 | Bugs: ProtocolBugs{ |
| 1352 | SendFallbackSCSV: true, |
| 1353 | }, |
| 1354 | }, |
| 1355 | }, |
| 1356 | { |
| 1357 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1358 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1359 | config: Config{ |
| 1360 | MaxVersion: VersionTLS12, |
| 1361 | Bugs: ProtocolBugs{ |
| 1362 | SendFallbackSCSV: true, |
| 1363 | }, |
| 1364 | }, |
| 1365 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1366 | }, |
| 1367 | { |
| 1368 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1369 | name: "FragmentedClientVersion", |
| 1370 | config: Config{ |
| 1371 | Bugs: ProtocolBugs{ |
| 1372 | MaxHandshakeRecordLength: 1, |
| 1373 | FragmentClientVersion: true, |
| 1374 | }, |
| 1375 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1376 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1377 | }, |
| 1378 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1379 | testType: serverTest, |
| 1380 | name: "HttpGET", |
| 1381 | sendPrefix: "GET / HTTP/1.0\n", |
| 1382 | shouldFail: true, |
| 1383 | expectedError: ":HTTP_REQUEST:", |
| 1384 | }, |
| 1385 | { |
| 1386 | testType: serverTest, |
| 1387 | name: "HttpPOST", |
| 1388 | sendPrefix: "POST / HTTP/1.0\n", |
| 1389 | shouldFail: true, |
| 1390 | expectedError: ":HTTP_REQUEST:", |
| 1391 | }, |
| 1392 | { |
| 1393 | testType: serverTest, |
| 1394 | name: "HttpHEAD", |
| 1395 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1396 | shouldFail: true, |
| 1397 | expectedError: ":HTTP_REQUEST:", |
| 1398 | }, |
| 1399 | { |
| 1400 | testType: serverTest, |
| 1401 | name: "HttpPUT", |
| 1402 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1403 | shouldFail: true, |
| 1404 | expectedError: ":HTTP_REQUEST:", |
| 1405 | }, |
| 1406 | { |
| 1407 | testType: serverTest, |
| 1408 | name: "HttpCONNECT", |
| 1409 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1410 | shouldFail: true, |
| 1411 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1412 | }, |
| 1413 | { |
| 1414 | testType: serverTest, |
| 1415 | name: "Garbage", |
| 1416 | sendPrefix: "blah", |
| 1417 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1418 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1419 | }, |
| 1420 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1421 | name: "RSAEphemeralKey", |
| 1422 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1423 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1424 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1425 | Bugs: ProtocolBugs{ |
| 1426 | RSAEphemeralKey: true, |
| 1427 | }, |
| 1428 | }, |
| 1429 | shouldFail: true, |
| 1430 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1431 | }, |
| 1432 | { |
| 1433 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1434 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1435 | shouldFail: true, |
| 1436 | expectedError: ":WRONG_SSL_VERSION:", |
| 1437 | }, |
| 1438 | { |
| 1439 | protocol: dtls, |
| 1440 | name: "DisableEverything-DTLS", |
| 1441 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1442 | shouldFail: true, |
| 1443 | expectedError: ":WRONG_SSL_VERSION:", |
| 1444 | }, |
| 1445 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1446 | protocol: dtls, |
| 1447 | testType: serverTest, |
| 1448 | name: "MTU", |
| 1449 | config: Config{ |
| 1450 | Bugs: ProtocolBugs{ |
| 1451 | MaxPacketLength: 256, |
| 1452 | }, |
| 1453 | }, |
| 1454 | flags: []string{"-mtu", "256"}, |
| 1455 | }, |
| 1456 | { |
| 1457 | protocol: dtls, |
| 1458 | testType: serverTest, |
| 1459 | name: "MTUExceeded", |
| 1460 | config: Config{ |
| 1461 | Bugs: ProtocolBugs{ |
| 1462 | MaxPacketLength: 255, |
| 1463 | }, |
| 1464 | }, |
| 1465 | flags: []string{"-mtu", "256"}, |
| 1466 | shouldFail: true, |
| 1467 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1468 | }, |
| 1469 | { |
| 1470 | name: "CertMismatchRSA", |
| 1471 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1472 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1473 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1474 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1475 | Bugs: ProtocolBugs{ |
| 1476 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 1477 | }, |
| 1478 | }, |
| 1479 | shouldFail: true, |
| 1480 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1481 | }, |
| 1482 | { |
| 1483 | name: "CertMismatchECDSA", |
| 1484 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1485 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1486 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 1487 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1488 | Bugs: ProtocolBugs{ |
| 1489 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 1490 | }, |
| 1491 | }, |
| 1492 | shouldFail: true, |
| 1493 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 1494 | }, |
| 1495 | { |
| 1496 | name: "EmptyCertificateList", |
| 1497 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1498 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1499 | Bugs: ProtocolBugs{ |
| 1500 | EmptyCertificateList: true, |
| 1501 | }, |
| 1502 | }, |
| 1503 | shouldFail: true, |
| 1504 | expectedError: ":DECODE_ERROR:", |
| 1505 | }, |
| 1506 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1507 | name: "EmptyCertificateList-TLS13", |
| 1508 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1509 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1510 | Bugs: ProtocolBugs{ |
| 1511 | EmptyCertificateList: true, |
| 1512 | }, |
| 1513 | }, |
| 1514 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1515 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1516 | }, |
| 1517 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1518 | name: "TLSFatalBadPackets", |
| 1519 | damageFirstWrite: true, |
| 1520 | shouldFail: true, |
| 1521 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1522 | }, |
| 1523 | { |
| 1524 | protocol: dtls, |
| 1525 | name: "DTLSIgnoreBadPackets", |
| 1526 | damageFirstWrite: true, |
| 1527 | }, |
| 1528 | { |
| 1529 | protocol: dtls, |
| 1530 | name: "DTLSIgnoreBadPackets-Async", |
| 1531 | damageFirstWrite: true, |
| 1532 | flags: []string{"-async"}, |
| 1533 | }, |
| 1534 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1535 | name: "AppDataBeforeHandshake", |
| 1536 | config: Config{ |
| 1537 | Bugs: ProtocolBugs{ |
| 1538 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1539 | }, |
| 1540 | }, |
| 1541 | shouldFail: true, |
| 1542 | expectedError: ":UNEXPECTED_RECORD:", |
| 1543 | }, |
| 1544 | { |
| 1545 | name: "AppDataBeforeHandshake-Empty", |
| 1546 | config: Config{ |
| 1547 | Bugs: ProtocolBugs{ |
| 1548 | AppDataBeforeHandshake: []byte{}, |
| 1549 | }, |
| 1550 | }, |
| 1551 | shouldFail: true, |
| 1552 | expectedError: ":UNEXPECTED_RECORD:", |
| 1553 | }, |
| 1554 | { |
| 1555 | protocol: dtls, |
| 1556 | name: "AppDataBeforeHandshake-DTLS", |
| 1557 | config: Config{ |
| 1558 | Bugs: ProtocolBugs{ |
| 1559 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1560 | }, |
| 1561 | }, |
| 1562 | shouldFail: true, |
| 1563 | expectedError: ":UNEXPECTED_RECORD:", |
| 1564 | }, |
| 1565 | { |
| 1566 | protocol: dtls, |
| 1567 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1568 | config: Config{ |
| 1569 | Bugs: ProtocolBugs{ |
| 1570 | AppDataBeforeHandshake: []byte{}, |
| 1571 | }, |
| 1572 | }, |
| 1573 | shouldFail: true, |
| 1574 | expectedError: ":UNEXPECTED_RECORD:", |
| 1575 | }, |
| 1576 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1577 | name: "AppDataAfterChangeCipherSpec", |
| 1578 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1579 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1580 | Bugs: ProtocolBugs{ |
| 1581 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1582 | }, |
| 1583 | }, |
| 1584 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1585 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1586 | }, |
| 1587 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1588 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1589 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1590 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1591 | Bugs: ProtocolBugs{ |
| 1592 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1593 | }, |
| 1594 | }, |
| 1595 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1596 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1597 | }, |
| 1598 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1599 | protocol: dtls, |
| 1600 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1601 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1602 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1603 | Bugs: ProtocolBugs{ |
| 1604 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1605 | }, |
| 1606 | }, |
| 1607 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1608 | // application data. |
| 1609 | }, |
| 1610 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1611 | protocol: dtls, |
| 1612 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1613 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1614 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1615 | Bugs: ProtocolBugs{ |
| 1616 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1617 | }, |
| 1618 | }, |
| 1619 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1620 | // application data. |
| 1621 | }, |
| 1622 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1623 | name: "AlertAfterChangeCipherSpec", |
| 1624 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1625 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1626 | Bugs: ProtocolBugs{ |
| 1627 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1628 | }, |
| 1629 | }, |
| 1630 | shouldFail: true, |
| 1631 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1632 | }, |
| 1633 | { |
| 1634 | protocol: dtls, |
| 1635 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1636 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1637 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1638 | Bugs: ProtocolBugs{ |
| 1639 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1640 | }, |
| 1641 | }, |
| 1642 | shouldFail: true, |
| 1643 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1644 | }, |
| 1645 | { |
| 1646 | protocol: dtls, |
| 1647 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1648 | config: Config{ |
| 1649 | Bugs: ProtocolBugs{ |
| 1650 | ReorderHandshakeFragments: true, |
| 1651 | // Small enough that every handshake message is |
| 1652 | // fragmented. |
| 1653 | MaxHandshakeRecordLength: 2, |
| 1654 | }, |
| 1655 | }, |
| 1656 | }, |
| 1657 | { |
| 1658 | protocol: dtls, |
| 1659 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1660 | config: Config{ |
| 1661 | Bugs: ProtocolBugs{ |
| 1662 | ReorderHandshakeFragments: true, |
| 1663 | // Large enough that no handshake message is |
| 1664 | // fragmented. |
| 1665 | MaxHandshakeRecordLength: 2048, |
| 1666 | }, |
| 1667 | }, |
| 1668 | }, |
| 1669 | { |
| 1670 | protocol: dtls, |
| 1671 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1672 | config: Config{ |
| 1673 | Bugs: ProtocolBugs{ |
| 1674 | ReorderHandshakeFragments: true, |
| 1675 | MixCompleteMessageWithFragments: true, |
| 1676 | MaxHandshakeRecordLength: 2, |
| 1677 | }, |
| 1678 | }, |
| 1679 | }, |
| 1680 | { |
| 1681 | name: "SendInvalidRecordType", |
| 1682 | config: Config{ |
| 1683 | Bugs: ProtocolBugs{ |
| 1684 | SendInvalidRecordType: true, |
| 1685 | }, |
| 1686 | }, |
| 1687 | shouldFail: true, |
| 1688 | expectedError: ":UNEXPECTED_RECORD:", |
| 1689 | }, |
| 1690 | { |
| 1691 | protocol: dtls, |
| 1692 | name: "SendInvalidRecordType-DTLS", |
| 1693 | config: Config{ |
| 1694 | Bugs: ProtocolBugs{ |
| 1695 | SendInvalidRecordType: true, |
| 1696 | }, |
| 1697 | }, |
| 1698 | shouldFail: true, |
| 1699 | expectedError: ":UNEXPECTED_RECORD:", |
| 1700 | }, |
| 1701 | { |
| 1702 | name: "FalseStart-SkipServerSecondLeg", |
| 1703 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1704 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1705 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1706 | NextProtos: []string{"foo"}, |
| 1707 | Bugs: ProtocolBugs{ |
| 1708 | SkipNewSessionTicket: true, |
| 1709 | SkipChangeCipherSpec: true, |
| 1710 | SkipFinished: true, |
| 1711 | ExpectFalseStart: true, |
| 1712 | }, |
| 1713 | }, |
| 1714 | flags: []string{ |
| 1715 | "-false-start", |
| 1716 | "-handshake-never-done", |
| 1717 | "-advertise-alpn", "\x03foo", |
| 1718 | }, |
| 1719 | shimWritesFirst: true, |
| 1720 | shouldFail: true, |
| 1721 | expectedError: ":UNEXPECTED_RECORD:", |
| 1722 | }, |
| 1723 | { |
| 1724 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1725 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1726 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1727 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1728 | NextProtos: []string{"foo"}, |
| 1729 | Bugs: ProtocolBugs{ |
| 1730 | SkipNewSessionTicket: true, |
| 1731 | SkipChangeCipherSpec: true, |
| 1732 | SkipFinished: true, |
| 1733 | }, |
| 1734 | }, |
| 1735 | flags: []string{ |
| 1736 | "-implicit-handshake", |
| 1737 | "-false-start", |
| 1738 | "-handshake-never-done", |
| 1739 | "-advertise-alpn", "\x03foo", |
| 1740 | }, |
| 1741 | shouldFail: true, |
| 1742 | expectedError: ":UNEXPECTED_RECORD:", |
| 1743 | }, |
| 1744 | { |
| 1745 | testType: serverTest, |
| 1746 | name: "FailEarlyCallback", |
| 1747 | flags: []string{"-fail-early-callback"}, |
| 1748 | shouldFail: true, |
| 1749 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1750 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1751 | }, |
| 1752 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1753 | name: "FailCertCallback-Client-TLS12", |
| 1754 | config: Config{ |
| 1755 | MaxVersion: VersionTLS12, |
| 1756 | ClientAuth: RequestClientCert, |
| 1757 | }, |
| 1758 | flags: []string{"-fail-cert-callback"}, |
| 1759 | shouldFail: true, |
| 1760 | expectedError: ":CERT_CB_ERROR:", |
| 1761 | expectedLocalError: "remote error: internal error", |
| 1762 | }, |
| 1763 | { |
| 1764 | testType: serverTest, |
| 1765 | name: "FailCertCallback-Server-TLS12", |
| 1766 | config: Config{ |
| 1767 | MaxVersion: VersionTLS12, |
| 1768 | }, |
| 1769 | flags: []string{"-fail-cert-callback"}, |
| 1770 | shouldFail: true, |
| 1771 | expectedError: ":CERT_CB_ERROR:", |
| 1772 | expectedLocalError: "remote error: internal error", |
| 1773 | }, |
| 1774 | { |
| 1775 | name: "FailCertCallback-Client-TLS13", |
| 1776 | config: Config{ |
| 1777 | MaxVersion: VersionTLS13, |
| 1778 | ClientAuth: RequestClientCert, |
| 1779 | }, |
| 1780 | flags: []string{"-fail-cert-callback"}, |
| 1781 | shouldFail: true, |
| 1782 | expectedError: ":CERT_CB_ERROR:", |
| 1783 | expectedLocalError: "remote error: internal error", |
| 1784 | }, |
| 1785 | { |
| 1786 | testType: serverTest, |
| 1787 | name: "FailCertCallback-Server-TLS13", |
| 1788 | config: Config{ |
| 1789 | MaxVersion: VersionTLS13, |
| 1790 | }, |
| 1791 | flags: []string{"-fail-cert-callback"}, |
| 1792 | shouldFail: true, |
| 1793 | expectedError: ":CERT_CB_ERROR:", |
| 1794 | expectedLocalError: "remote error: internal error", |
| 1795 | }, |
| 1796 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1797 | protocol: dtls, |
| 1798 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1799 | config: Config{ |
| 1800 | Bugs: ProtocolBugs{ |
| 1801 | MaxHandshakeRecordLength: 2, |
| 1802 | FragmentMessageTypeMismatch: true, |
| 1803 | }, |
| 1804 | }, |
| 1805 | shouldFail: true, |
| 1806 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1807 | }, |
| 1808 | { |
| 1809 | protocol: dtls, |
| 1810 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1811 | config: Config{ |
| 1812 | Bugs: ProtocolBugs{ |
| 1813 | MaxHandshakeRecordLength: 2, |
| 1814 | FragmentMessageLengthMismatch: true, |
| 1815 | }, |
| 1816 | }, |
| 1817 | shouldFail: true, |
| 1818 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1819 | }, |
| 1820 | { |
| 1821 | protocol: dtls, |
| 1822 | name: "SplitFragments-Header-DTLS", |
| 1823 | config: Config{ |
| 1824 | Bugs: ProtocolBugs{ |
| 1825 | SplitFragments: 2, |
| 1826 | }, |
| 1827 | }, |
| 1828 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1829 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1830 | }, |
| 1831 | { |
| 1832 | protocol: dtls, |
| 1833 | name: "SplitFragments-Boundary-DTLS", |
| 1834 | config: Config{ |
| 1835 | Bugs: ProtocolBugs{ |
| 1836 | SplitFragments: dtlsRecordHeaderLen, |
| 1837 | }, |
| 1838 | }, |
| 1839 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1840 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1841 | }, |
| 1842 | { |
| 1843 | protocol: dtls, |
| 1844 | name: "SplitFragments-Body-DTLS", |
| 1845 | config: Config{ |
| 1846 | Bugs: ProtocolBugs{ |
| 1847 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1848 | }, |
| 1849 | }, |
| 1850 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1851 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1852 | }, |
| 1853 | { |
| 1854 | protocol: dtls, |
| 1855 | name: "SendEmptyFragments-DTLS", |
| 1856 | config: Config{ |
| 1857 | Bugs: ProtocolBugs{ |
| 1858 | SendEmptyFragments: true, |
| 1859 | }, |
| 1860 | }, |
| 1861 | }, |
| 1862 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1863 | name: "BadFinished-Client", |
| 1864 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1865 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1866 | Bugs: ProtocolBugs{ |
| 1867 | BadFinished: true, |
| 1868 | }, |
| 1869 | }, |
| 1870 | shouldFail: true, |
| 1871 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1872 | }, |
| 1873 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1874 | name: "BadFinished-Client-TLS13", |
| 1875 | config: Config{ |
| 1876 | MaxVersion: VersionTLS13, |
| 1877 | Bugs: ProtocolBugs{ |
| 1878 | BadFinished: true, |
| 1879 | }, |
| 1880 | }, |
| 1881 | shouldFail: true, |
| 1882 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1883 | }, |
| 1884 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1885 | testType: serverTest, |
| 1886 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1887 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1888 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1889 | Bugs: ProtocolBugs{ |
| 1890 | BadFinished: true, |
| 1891 | }, |
| 1892 | }, |
| 1893 | shouldFail: true, |
| 1894 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1895 | }, |
| 1896 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1897 | testType: serverTest, |
| 1898 | name: "BadFinished-Server-TLS13", |
| 1899 | config: Config{ |
| 1900 | MaxVersion: VersionTLS13, |
| 1901 | Bugs: ProtocolBugs{ |
| 1902 | BadFinished: true, |
| 1903 | }, |
| 1904 | }, |
| 1905 | shouldFail: true, |
| 1906 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1907 | }, |
| 1908 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1909 | name: "FalseStart-BadFinished", |
| 1910 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1911 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1912 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1913 | NextProtos: []string{"foo"}, |
| 1914 | Bugs: ProtocolBugs{ |
| 1915 | BadFinished: true, |
| 1916 | ExpectFalseStart: true, |
| 1917 | }, |
| 1918 | }, |
| 1919 | flags: []string{ |
| 1920 | "-false-start", |
| 1921 | "-handshake-never-done", |
| 1922 | "-advertise-alpn", "\x03foo", |
| 1923 | }, |
| 1924 | shimWritesFirst: true, |
| 1925 | shouldFail: true, |
| 1926 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1927 | }, |
| 1928 | { |
| 1929 | name: "NoFalseStart-NoALPN", |
| 1930 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1931 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1932 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1933 | Bugs: ProtocolBugs{ |
| 1934 | ExpectFalseStart: true, |
| 1935 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1936 | }, |
| 1937 | }, |
| 1938 | flags: []string{ |
| 1939 | "-false-start", |
| 1940 | }, |
| 1941 | shimWritesFirst: true, |
| 1942 | shouldFail: true, |
| 1943 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1944 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1945 | }, |
| 1946 | { |
| 1947 | name: "NoFalseStart-NoAEAD", |
| 1948 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1949 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1950 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 1951 | NextProtos: []string{"foo"}, |
| 1952 | Bugs: ProtocolBugs{ |
| 1953 | ExpectFalseStart: true, |
| 1954 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1955 | }, |
| 1956 | }, |
| 1957 | flags: []string{ |
| 1958 | "-false-start", |
| 1959 | "-advertise-alpn", "\x03foo", |
| 1960 | }, |
| 1961 | shimWritesFirst: true, |
| 1962 | shouldFail: true, |
| 1963 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1964 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1965 | }, |
| 1966 | { |
| 1967 | name: "NoFalseStart-RSA", |
| 1968 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1969 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1970 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 1971 | NextProtos: []string{"foo"}, |
| 1972 | Bugs: ProtocolBugs{ |
| 1973 | ExpectFalseStart: true, |
| 1974 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1975 | }, |
| 1976 | }, |
| 1977 | flags: []string{ |
| 1978 | "-false-start", |
| 1979 | "-advertise-alpn", "\x03foo", |
| 1980 | }, |
| 1981 | shimWritesFirst: true, |
| 1982 | shouldFail: true, |
| 1983 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1984 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1985 | }, |
| 1986 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1987 | protocol: dtls, |
| 1988 | name: "SendSplitAlert-Sync", |
| 1989 | config: Config{ |
| 1990 | Bugs: ProtocolBugs{ |
| 1991 | SendSplitAlert: true, |
| 1992 | }, |
| 1993 | }, |
| 1994 | }, |
| 1995 | { |
| 1996 | protocol: dtls, |
| 1997 | name: "SendSplitAlert-Async", |
| 1998 | config: Config{ |
| 1999 | Bugs: ProtocolBugs{ |
| 2000 | SendSplitAlert: true, |
| 2001 | }, |
| 2002 | }, |
| 2003 | flags: []string{"-async"}, |
| 2004 | }, |
| 2005 | { |
| 2006 | protocol: dtls, |
| 2007 | name: "PackDTLSHandshake", |
| 2008 | config: Config{ |
| 2009 | Bugs: ProtocolBugs{ |
| 2010 | MaxHandshakeRecordLength: 2, |
| 2011 | PackHandshakeFragments: 20, |
| 2012 | PackHandshakeRecords: 200, |
| 2013 | }, |
| 2014 | }, |
| 2015 | }, |
| 2016 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2017 | name: "SendEmptyRecords-Pass", |
| 2018 | sendEmptyRecords: 32, |
| 2019 | }, |
| 2020 | { |
| 2021 | name: "SendEmptyRecords", |
| 2022 | sendEmptyRecords: 33, |
| 2023 | shouldFail: true, |
| 2024 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2025 | }, |
| 2026 | { |
| 2027 | name: "SendEmptyRecords-Async", |
| 2028 | sendEmptyRecords: 33, |
| 2029 | flags: []string{"-async"}, |
| 2030 | shouldFail: true, |
| 2031 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2032 | }, |
| 2033 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2034 | name: "SendWarningAlerts-Pass", |
| 2035 | config: Config{ |
| 2036 | MaxVersion: VersionTLS12, |
| 2037 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2038 | sendWarningAlerts: 4, |
| 2039 | }, |
| 2040 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2041 | protocol: dtls, |
| 2042 | name: "SendWarningAlerts-DTLS-Pass", |
| 2043 | config: Config{ |
| 2044 | MaxVersion: VersionTLS12, |
| 2045 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2046 | sendWarningAlerts: 4, |
| 2047 | }, |
| 2048 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2049 | name: "SendWarningAlerts-TLS13", |
| 2050 | config: Config{ |
| 2051 | MaxVersion: VersionTLS13, |
| 2052 | }, |
| 2053 | sendWarningAlerts: 4, |
| 2054 | shouldFail: true, |
| 2055 | expectedError: ":BAD_ALERT:", |
| 2056 | expectedLocalError: "remote error: error decoding message", |
| 2057 | }, |
| 2058 | { |
| 2059 | name: "SendWarningAlerts", |
| 2060 | config: Config{ |
| 2061 | MaxVersion: VersionTLS12, |
| 2062 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2063 | sendWarningAlerts: 5, |
| 2064 | shouldFail: true, |
| 2065 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2066 | }, |
| 2067 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2068 | name: "SendWarningAlerts-Async", |
| 2069 | config: Config{ |
| 2070 | MaxVersion: VersionTLS12, |
| 2071 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2072 | sendWarningAlerts: 5, |
| 2073 | flags: []string{"-async"}, |
| 2074 | shouldFail: true, |
| 2075 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2076 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2077 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2078 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2079 | config: Config{ |
| 2080 | MaxVersion: VersionTLS13, |
| 2081 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2082 | sendKeyUpdates: 33, |
| 2083 | keyUpdateRequest: keyUpdateNotRequested, |
| 2084 | shouldFail: true, |
| 2085 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2086 | }, |
| 2087 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2088 | name: "EmptySessionID", |
| 2089 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2090 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2091 | SessionTicketsDisabled: true, |
| 2092 | }, |
| 2093 | noSessionCache: true, |
| 2094 | flags: []string{"-expect-no-session"}, |
| 2095 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2096 | { |
| 2097 | name: "Unclean-Shutdown", |
| 2098 | config: Config{ |
| 2099 | Bugs: ProtocolBugs{ |
| 2100 | NoCloseNotify: true, |
| 2101 | ExpectCloseNotify: true, |
| 2102 | }, |
| 2103 | }, |
| 2104 | shimShutsDown: true, |
| 2105 | flags: []string{"-check-close-notify"}, |
| 2106 | shouldFail: true, |
| 2107 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2108 | }, |
| 2109 | { |
| 2110 | name: "Unclean-Shutdown-Ignored", |
| 2111 | config: Config{ |
| 2112 | Bugs: ProtocolBugs{ |
| 2113 | NoCloseNotify: true, |
| 2114 | }, |
| 2115 | }, |
| 2116 | shimShutsDown: true, |
| 2117 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2118 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2119 | name: "Unclean-Shutdown-Alert", |
| 2120 | config: Config{ |
| 2121 | Bugs: ProtocolBugs{ |
| 2122 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2123 | ExpectCloseNotify: true, |
| 2124 | }, |
| 2125 | }, |
| 2126 | shimShutsDown: true, |
| 2127 | flags: []string{"-check-close-notify"}, |
| 2128 | shouldFail: true, |
| 2129 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2130 | }, |
| 2131 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2132 | name: "LargePlaintext", |
| 2133 | config: Config{ |
| 2134 | Bugs: ProtocolBugs{ |
| 2135 | SendLargeRecords: true, |
| 2136 | }, |
| 2137 | }, |
| 2138 | messageLen: maxPlaintext + 1, |
| 2139 | shouldFail: true, |
| 2140 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2141 | }, |
| 2142 | { |
| 2143 | protocol: dtls, |
| 2144 | name: "LargePlaintext-DTLS", |
| 2145 | config: Config{ |
| 2146 | Bugs: ProtocolBugs{ |
| 2147 | SendLargeRecords: true, |
| 2148 | }, |
| 2149 | }, |
| 2150 | messageLen: maxPlaintext + 1, |
| 2151 | shouldFail: true, |
| 2152 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2153 | }, |
| 2154 | { |
| 2155 | name: "LargeCiphertext", |
| 2156 | config: Config{ |
| 2157 | Bugs: ProtocolBugs{ |
| 2158 | SendLargeRecords: true, |
| 2159 | }, |
| 2160 | }, |
| 2161 | messageLen: maxPlaintext * 2, |
| 2162 | shouldFail: true, |
| 2163 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2164 | }, |
| 2165 | { |
| 2166 | protocol: dtls, |
| 2167 | name: "LargeCiphertext-DTLS", |
| 2168 | config: Config{ |
| 2169 | Bugs: ProtocolBugs{ |
| 2170 | SendLargeRecords: true, |
| 2171 | }, |
| 2172 | }, |
| 2173 | messageLen: maxPlaintext * 2, |
| 2174 | // Unlike the other four cases, DTLS drops records which |
| 2175 | // are invalid before authentication, so the connection |
| 2176 | // does not fail. |
| 2177 | expectMessageDropped: true, |
| 2178 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2179 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2180 | name: "BadHelloRequest-1", |
| 2181 | renegotiate: 1, |
| 2182 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2183 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2184 | Bugs: ProtocolBugs{ |
| 2185 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2186 | }, |
| 2187 | }, |
| 2188 | flags: []string{ |
| 2189 | "-renegotiate-freely", |
| 2190 | "-expect-total-renegotiations", "1", |
| 2191 | }, |
| 2192 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2193 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2194 | }, |
| 2195 | { |
| 2196 | name: "BadHelloRequest-2", |
| 2197 | renegotiate: 1, |
| 2198 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2199 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2200 | Bugs: ProtocolBugs{ |
| 2201 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2202 | }, |
| 2203 | }, |
| 2204 | flags: []string{ |
| 2205 | "-renegotiate-freely", |
| 2206 | "-expect-total-renegotiations", "1", |
| 2207 | }, |
| 2208 | shouldFail: true, |
| 2209 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2210 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2211 | { |
| 2212 | testType: serverTest, |
| 2213 | name: "SupportTicketsWithSessionID", |
| 2214 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2215 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2216 | SessionTicketsDisabled: true, |
| 2217 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2218 | resumeConfig: &Config{ |
| 2219 | MaxVersion: VersionTLS12, |
| 2220 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2221 | resumeSession: true, |
| 2222 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2223 | { |
| 2224 | protocol: dtls, |
| 2225 | name: "DTLS-SendExtraFinished", |
| 2226 | config: Config{ |
| 2227 | Bugs: ProtocolBugs{ |
| 2228 | SendExtraFinished: true, |
| 2229 | }, |
| 2230 | }, |
| 2231 | shouldFail: true, |
| 2232 | expectedError: ":UNEXPECTED_RECORD:", |
| 2233 | }, |
| 2234 | { |
| 2235 | protocol: dtls, |
| 2236 | name: "DTLS-SendExtraFinished-Reordered", |
| 2237 | config: Config{ |
| 2238 | Bugs: ProtocolBugs{ |
| 2239 | MaxHandshakeRecordLength: 2, |
| 2240 | ReorderHandshakeFragments: true, |
| 2241 | SendExtraFinished: true, |
| 2242 | }, |
| 2243 | }, |
| 2244 | shouldFail: true, |
| 2245 | expectedError: ":UNEXPECTED_RECORD:", |
| 2246 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2247 | { |
| 2248 | testType: serverTest, |
| 2249 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2250 | config: Config{ |
| 2251 | // Choose a cipher suite that does not involve |
| 2252 | // elliptic curves, so no extensions are |
| 2253 | // involved. |
| 2254 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2255 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2256 | Bugs: ProtocolBugs{ |
| 2257 | SendV2ClientHello: true, |
| 2258 | }, |
| 2259 | }, |
| 2260 | sendPrefix: string([]byte{ |
| 2261 | byte(recordTypeHandshake), |
| 2262 | 3, 1, // version |
| 2263 | 0, 0, // length |
| 2264 | }), |
| 2265 | // A no-op empty record may not be sent before V2ClientHello. |
| 2266 | shouldFail: true, |
| 2267 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2268 | }, |
| 2269 | { |
| 2270 | testType: serverTest, |
| 2271 | name: "V2ClientHello-WarningAlertPrefix", |
| 2272 | config: Config{ |
| 2273 | // Choose a cipher suite that does not involve |
| 2274 | // elliptic curves, so no extensions are |
| 2275 | // involved. |
| 2276 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2277 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2278 | Bugs: ProtocolBugs{ |
| 2279 | SendV2ClientHello: true, |
| 2280 | }, |
| 2281 | }, |
| 2282 | sendPrefix: string([]byte{ |
| 2283 | byte(recordTypeAlert), |
| 2284 | 3, 1, // version |
| 2285 | 0, 2, // length |
| 2286 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2287 | }), |
| 2288 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2289 | shouldFail: true, |
| 2290 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2291 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2292 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2293 | name: "KeyUpdate-Client", |
| 2294 | config: Config{ |
| 2295 | MaxVersion: VersionTLS13, |
| 2296 | }, |
| 2297 | sendKeyUpdates: 1, |
| 2298 | keyUpdateRequest: keyUpdateNotRequested, |
| 2299 | }, |
| 2300 | { |
| 2301 | testType: serverTest, |
| 2302 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2303 | config: Config{ |
| 2304 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2305 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2306 | sendKeyUpdates: 1, |
| 2307 | keyUpdateRequest: keyUpdateNotRequested, |
| 2308 | }, |
| 2309 | { |
| 2310 | name: "KeyUpdate-InvalidRequestMode", |
| 2311 | config: Config{ |
| 2312 | MaxVersion: VersionTLS13, |
| 2313 | }, |
| 2314 | sendKeyUpdates: 1, |
| 2315 | keyUpdateRequest: 42, |
| 2316 | shouldFail: true, |
| 2317 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2318 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2319 | { |
| 2320 | name: "SendSNIWarningAlert", |
| 2321 | config: Config{ |
| 2322 | MaxVersion: VersionTLS12, |
| 2323 | Bugs: ProtocolBugs{ |
| 2324 | SendSNIWarningAlert: true, |
| 2325 | }, |
| 2326 | }, |
| 2327 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2328 | { |
| 2329 | testType: serverTest, |
| 2330 | name: "ExtraCompressionMethods-TLS12", |
| 2331 | config: Config{ |
| 2332 | MaxVersion: VersionTLS12, |
| 2333 | Bugs: ProtocolBugs{ |
| 2334 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2335 | }, |
| 2336 | }, |
| 2337 | }, |
| 2338 | { |
| 2339 | testType: serverTest, |
| 2340 | name: "ExtraCompressionMethods-TLS13", |
| 2341 | config: Config{ |
| 2342 | MaxVersion: VersionTLS13, |
| 2343 | Bugs: ProtocolBugs{ |
| 2344 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2345 | }, |
| 2346 | }, |
| 2347 | shouldFail: true, |
| 2348 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2349 | expectedLocalError: "remote error: illegal parameter", |
| 2350 | }, |
| 2351 | { |
| 2352 | testType: serverTest, |
| 2353 | name: "NoNullCompression-TLS12", |
| 2354 | config: Config{ |
| 2355 | MaxVersion: VersionTLS12, |
| 2356 | Bugs: ProtocolBugs{ |
| 2357 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2358 | }, |
| 2359 | }, |
| 2360 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2361 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2362 | expectedLocalError: "remote error: illegal parameter", |
| 2363 | }, |
| 2364 | { |
| 2365 | testType: serverTest, |
| 2366 | name: "NoNullCompression-TLS13", |
| 2367 | config: Config{ |
| 2368 | MaxVersion: VersionTLS13, |
| 2369 | Bugs: ProtocolBugs{ |
| 2370 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2371 | }, |
| 2372 | }, |
| 2373 | shouldFail: true, |
| 2374 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2375 | expectedLocalError: "remote error: illegal parameter", |
| 2376 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2377 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2378 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2379 | config: Config{ |
| 2380 | MaxVersion: VersionTLS12, |
| 2381 | Bugs: ProtocolBugs{ |
| 2382 | ExpectGREASE: true, |
| 2383 | }, |
| 2384 | }, |
| 2385 | flags: []string{"-enable-grease"}, |
| 2386 | }, |
| 2387 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2388 | name: "GREASE-Client-TLS13", |
| 2389 | config: Config{ |
| 2390 | MaxVersion: VersionTLS13, |
| 2391 | Bugs: ProtocolBugs{ |
| 2392 | ExpectGREASE: true, |
| 2393 | }, |
| 2394 | }, |
| 2395 | flags: []string{"-enable-grease"}, |
| 2396 | }, |
| 2397 | { |
| 2398 | testType: serverTest, |
| 2399 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2400 | config: Config{ |
| 2401 | MaxVersion: VersionTLS13, |
| 2402 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2403 | // TLS 1.3 servers are expected to |
| 2404 | // always enable GREASE. TLS 1.3 is new, |
| 2405 | // so there is no existing ecosystem to |
| 2406 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2407 | ExpectGREASE: true, |
| 2408 | }, |
| 2409 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2410 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2411 | { |
| 2412 | // Test the server so there is a large certificate as |
| 2413 | // well as application data. |
| 2414 | testType: serverTest, |
| 2415 | name: "MaxSendFragment", |
| 2416 | config: Config{ |
| 2417 | Bugs: ProtocolBugs{ |
| 2418 | MaxReceivePlaintext: 512, |
| 2419 | }, |
| 2420 | }, |
| 2421 | messageLen: 1024, |
| 2422 | flags: []string{ |
| 2423 | "-max-send-fragment", "512", |
| 2424 | "-read-size", "1024", |
| 2425 | }, |
| 2426 | }, |
| 2427 | { |
| 2428 | // Test the server so there is a large certificate as |
| 2429 | // well as application data. |
| 2430 | testType: serverTest, |
| 2431 | name: "MaxSendFragment-TooLarge", |
| 2432 | config: Config{ |
| 2433 | Bugs: ProtocolBugs{ |
| 2434 | // Ensure that some of the records are |
| 2435 | // 512. |
| 2436 | MaxReceivePlaintext: 511, |
| 2437 | }, |
| 2438 | }, |
| 2439 | messageLen: 1024, |
| 2440 | flags: []string{ |
| 2441 | "-max-send-fragment", "512", |
| 2442 | "-read-size", "1024", |
| 2443 | }, |
| 2444 | shouldFail: true, |
| 2445 | expectedLocalError: "local error: record overflow", |
| 2446 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2447 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2448 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2449 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2450 | if *includeDHE { |
| 2451 | testCases = append(testCases, testCase{ |
| 2452 | name: "NoFalseStart-DHE_RSA", |
| 2453 | config: Config{ |
| 2454 | MaxVersion: VersionTLS12, |
| 2455 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2456 | NextProtos: []string{"foo"}, |
| 2457 | Bugs: ProtocolBugs{ |
| 2458 | ExpectFalseStart: true, |
| 2459 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2460 | }, |
| 2461 | }, |
| 2462 | flags: []string{ |
| 2463 | "-false-start", |
| 2464 | "-advertise-alpn", "\x03foo", |
| 2465 | }, |
| 2466 | shimWritesFirst: true, |
| 2467 | shouldFail: true, |
| 2468 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2469 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2470 | }) |
| 2471 | } |
| 2472 | |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2473 | // Test that very large messages can be received. |
| 2474 | cert := rsaCertificate |
| 2475 | for i := 0; i < 50; i++ { |
| 2476 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2477 | } |
| 2478 | testCases = append(testCases, testCase{ |
| 2479 | name: "LargeMessage", |
| 2480 | config: Config{ |
| 2481 | Certificates: []Certificate{cert}, |
| 2482 | }, |
| 2483 | }) |
| 2484 | testCases = append(testCases, testCase{ |
| 2485 | protocol: dtls, |
| 2486 | name: "LargeMessage-DTLS", |
| 2487 | config: Config{ |
| 2488 | Certificates: []Certificate{cert}, |
| 2489 | }, |
| 2490 | }) |
| 2491 | |
| 2492 | // They are rejected if the maximum certificate chain length is capped. |
| 2493 | testCases = append(testCases, testCase{ |
| 2494 | name: "LargeMessage-Reject", |
| 2495 | config: Config{ |
| 2496 | Certificates: []Certificate{cert}, |
| 2497 | }, |
| 2498 | flags: []string{"-max-cert-list", "16384"}, |
| 2499 | shouldFail: true, |
| 2500 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2501 | }) |
| 2502 | testCases = append(testCases, testCase{ |
| 2503 | protocol: dtls, |
| 2504 | name: "LargeMessage-Reject-DTLS", |
| 2505 | config: Config{ |
| 2506 | Certificates: []Certificate{cert}, |
| 2507 | }, |
| 2508 | flags: []string{"-max-cert-list", "16384"}, |
| 2509 | shouldFail: true, |
| 2510 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2511 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2512 | } |
| 2513 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2514 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2515 | const psk = "12345" |
| 2516 | const pskIdentity = "luggage combo" |
| 2517 | |
| 2518 | var prefix string |
| 2519 | if protocol == dtls { |
| 2520 | if !ver.hasDTLS { |
| 2521 | return |
| 2522 | } |
| 2523 | prefix = "D" |
| 2524 | } |
| 2525 | |
| 2526 | var cert Certificate |
| 2527 | var certFile string |
| 2528 | var keyFile string |
| 2529 | if hasComponent(suite.name, "ECDSA") { |
| 2530 | cert = ecdsaP256Certificate |
| 2531 | certFile = ecdsaP256CertificateFile |
| 2532 | keyFile = ecdsaP256KeyFile |
| 2533 | } else { |
| 2534 | cert = rsaCertificate |
| 2535 | certFile = rsaCertificateFile |
| 2536 | keyFile = rsaKeyFile |
| 2537 | } |
| 2538 | |
| 2539 | var flags []string |
| 2540 | if hasComponent(suite.name, "PSK") { |
| 2541 | flags = append(flags, |
| 2542 | "-psk", psk, |
| 2543 | "-psk-identity", pskIdentity) |
| 2544 | } |
| 2545 | if hasComponent(suite.name, "NULL") { |
| 2546 | // NULL ciphers must be explicitly enabled. |
| 2547 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2548 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2549 | |
| 2550 | var shouldServerFail, shouldClientFail bool |
| 2551 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2552 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2553 | // a BoringSSL server will never select it |
| 2554 | // because the extension is missing. |
| 2555 | shouldServerFail = true |
| 2556 | } |
| 2557 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2558 | shouldClientFail = true |
| 2559 | shouldServerFail = true |
| 2560 | } |
| 2561 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2562 | shouldClientFail = true |
| 2563 | shouldServerFail = true |
| 2564 | } |
| 2565 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2566 | shouldClientFail = true |
| 2567 | shouldServerFail = true |
| 2568 | } |
| 2569 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2570 | shouldClientFail = true |
| 2571 | shouldServerFail = true |
| 2572 | } |
| 2573 | |
| 2574 | var sendCipherSuite uint16 |
| 2575 | var expectedServerError, expectedClientError string |
| 2576 | serverCipherSuites := []uint16{suite.id} |
| 2577 | if shouldServerFail { |
| 2578 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2579 | } |
| 2580 | if shouldClientFail { |
| 2581 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2582 | // Configure the server to select ciphers as normal but |
| 2583 | // select an incompatible cipher in ServerHello. |
| 2584 | serverCipherSuites = nil |
| 2585 | sendCipherSuite = suite.id |
| 2586 | } |
| 2587 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2588 | // For cipher suites and versions where exporters are defined, verify |
| 2589 | // that they interoperate. |
| 2590 | var exportKeyingMaterial int |
| 2591 | if ver.version > VersionSSL30 { |
| 2592 | exportKeyingMaterial = 1024 |
| 2593 | } |
| 2594 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2595 | testCases = append(testCases, testCase{ |
| 2596 | testType: serverTest, |
| 2597 | protocol: protocol, |
| 2598 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2599 | config: Config{ |
| 2600 | MinVersion: ver.version, |
| 2601 | MaxVersion: ver.version, |
| 2602 | CipherSuites: []uint16{suite.id}, |
| 2603 | Certificates: []Certificate{cert}, |
| 2604 | PreSharedKey: []byte(psk), |
| 2605 | PreSharedKeyIdentity: pskIdentity, |
| 2606 | Bugs: ProtocolBugs{ |
| 2607 | AdvertiseAllConfiguredCiphers: true, |
| 2608 | }, |
| 2609 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2610 | certFile: certFile, |
| 2611 | keyFile: keyFile, |
| 2612 | flags: flags, |
| 2613 | resumeSession: true, |
| 2614 | shouldFail: shouldServerFail, |
| 2615 | expectedError: expectedServerError, |
| 2616 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2617 | }) |
| 2618 | |
| 2619 | testCases = append(testCases, testCase{ |
| 2620 | testType: clientTest, |
| 2621 | protocol: protocol, |
| 2622 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2623 | config: Config{ |
| 2624 | MinVersion: ver.version, |
| 2625 | MaxVersion: ver.version, |
| 2626 | CipherSuites: serverCipherSuites, |
| 2627 | Certificates: []Certificate{cert}, |
| 2628 | PreSharedKey: []byte(psk), |
| 2629 | PreSharedKeyIdentity: pskIdentity, |
| 2630 | Bugs: ProtocolBugs{ |
| 2631 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2632 | SendCipherSuite: sendCipherSuite, |
| 2633 | }, |
| 2634 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2635 | flags: flags, |
| 2636 | resumeSession: true, |
| 2637 | shouldFail: shouldClientFail, |
| 2638 | expectedError: expectedClientError, |
| 2639 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2640 | }) |
| 2641 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2642 | if shouldClientFail { |
| 2643 | return |
| 2644 | } |
| 2645 | |
| 2646 | // Ensure the maximum record size is accepted. |
| 2647 | testCases = append(testCases, testCase{ |
| 2648 | protocol: protocol, |
| 2649 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2650 | config: Config{ |
| 2651 | MinVersion: ver.version, |
| 2652 | MaxVersion: ver.version, |
| 2653 | CipherSuites: []uint16{suite.id}, |
| 2654 | Certificates: []Certificate{cert}, |
| 2655 | PreSharedKey: []byte(psk), |
| 2656 | PreSharedKeyIdentity: pskIdentity, |
| 2657 | }, |
| 2658 | flags: flags, |
| 2659 | messageLen: maxPlaintext, |
| 2660 | }) |
| 2661 | |
| 2662 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2663 | // and ignored in DTLS. |
| 2664 | var shouldFail bool |
| 2665 | var expectedError string |
| 2666 | if protocol == tls { |
| 2667 | shouldFail = true |
| 2668 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2669 | } |
| 2670 | |
| 2671 | testCases = append(testCases, testCase{ |
| 2672 | protocol: protocol, |
| 2673 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2674 | config: Config{ |
| 2675 | MinVersion: ver.version, |
| 2676 | MaxVersion: ver.version, |
| 2677 | CipherSuites: []uint16{suite.id}, |
| 2678 | Certificates: []Certificate{cert}, |
| 2679 | PreSharedKey: []byte(psk), |
| 2680 | PreSharedKeyIdentity: pskIdentity, |
| 2681 | }, |
| 2682 | flags: flags, |
| 2683 | damageFirstWrite: true, |
| 2684 | messageLen: maxPlaintext, |
| 2685 | shouldFail: shouldFail, |
| 2686 | expectedError: expectedError, |
| 2687 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2688 | } |
| 2689 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2690 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2691 | const bogusCipher = 0xfe00 |
| 2692 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2693 | if *includeDHE { |
| 2694 | testCipherSuites = append(testCipherSuites, []testCipherSuite{ |
| 2695 | {"DHE-RSA-AES128-GCM", TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2696 | {"DHE-RSA-AES128-SHA", TLS_DHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2697 | {"DHE-RSA-AES128-SHA256", TLS_DHE_RSA_WITH_AES_128_CBC_SHA256}, |
| 2698 | {"DHE-RSA-AES256-GCM", TLS_DHE_RSA_WITH_AES_256_GCM_SHA384}, |
| 2699 | {"DHE-RSA-AES256-SHA", TLS_DHE_RSA_WITH_AES_256_CBC_SHA}, |
| 2700 | {"DHE-RSA-AES256-SHA256", TLS_DHE_RSA_WITH_AES_256_CBC_SHA256}, |
| 2701 | }...) |
| 2702 | } |
| 2703 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2704 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2705 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2706 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2707 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2708 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2709 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2710 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2711 | |
| 2712 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2713 | name: "NoSharedCipher", |
| 2714 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2715 | MaxVersion: VersionTLS12, |
| 2716 | CipherSuites: []uint16{}, |
| 2717 | }, |
| 2718 | shouldFail: true, |
| 2719 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2720 | }) |
| 2721 | |
| 2722 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2723 | name: "NoSharedCipher-TLS13", |
| 2724 | config: Config{ |
| 2725 | MaxVersion: VersionTLS13, |
| 2726 | CipherSuites: []uint16{}, |
| 2727 | }, |
| 2728 | shouldFail: true, |
| 2729 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2730 | }) |
| 2731 | |
| 2732 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2733 | name: "UnsupportedCipherSuite", |
| 2734 | config: Config{ |
| 2735 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2736 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2737 | Bugs: ProtocolBugs{ |
| 2738 | IgnorePeerCipherPreferences: true, |
| 2739 | }, |
| 2740 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2741 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2742 | shouldFail: true, |
| 2743 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2744 | }) |
| 2745 | |
| 2746 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2747 | name: "ServerHelloBogusCipher", |
| 2748 | config: Config{ |
| 2749 | MaxVersion: VersionTLS12, |
| 2750 | Bugs: ProtocolBugs{ |
| 2751 | SendCipherSuite: bogusCipher, |
| 2752 | }, |
| 2753 | }, |
| 2754 | shouldFail: true, |
| 2755 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2756 | }) |
| 2757 | testCases = append(testCases, testCase{ |
| 2758 | name: "ServerHelloBogusCipher-TLS13", |
| 2759 | config: Config{ |
| 2760 | MaxVersion: VersionTLS13, |
| 2761 | Bugs: ProtocolBugs{ |
| 2762 | SendCipherSuite: bogusCipher, |
| 2763 | }, |
| 2764 | }, |
| 2765 | shouldFail: true, |
| 2766 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2767 | }) |
| 2768 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2769 | if *includeDHE { |
| 2770 | testCases = append(testCases, testCase{ |
| 2771 | name: "WeakDH", |
| 2772 | config: Config{ |
| 2773 | MaxVersion: VersionTLS12, |
| 2774 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2775 | Bugs: ProtocolBugs{ |
| 2776 | // This is a 1023-bit prime number, generated |
| 2777 | // with: |
| 2778 | // openssl gendh 1023 | openssl asn1parse -i |
| 2779 | DHGroupPrime: bigFromHex("518E9B7930CE61C6E445C8360584E5FC78D9137C0FFDC880B495D5338ADF7689951A6821C17A76B3ACB8E0156AEA607B7EC406EBEDBB84D8376EB8FE8F8BA1433488BEE0C3EDDFD3A32DBB9481980A7AF6C96BFCF490A094CFFB2B8192C1BB5510B77B658436E27C2D4D023FE3718222AB0CA1273995B51F6D625A4944D0DD4B"), |
| 2780 | }, |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2781 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2782 | shouldFail: true, |
| 2783 | expectedError: ":BAD_DH_P_LENGTH:", |
| 2784 | }) |
Adam Langley | cef7583 | 2015-09-03 14:51:12 -0700 | [diff] [blame] | 2785 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2786 | testCases = append(testCases, testCase{ |
| 2787 | name: "SillyDH", |
| 2788 | config: Config{ |
| 2789 | MaxVersion: VersionTLS12, |
| 2790 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2791 | Bugs: ProtocolBugs{ |
| 2792 | // This is a 4097-bit prime number, generated |
| 2793 | // with: |
| 2794 | // openssl gendh 4097 | openssl asn1parse -i |
| 2795 | DHGroupPrime: bigFromHex("01D366FA64A47419B0CD4A45918E8D8C8430F674621956A9F52B0CA592BC104C6E38D60C58F2CA66792A2B7EBDC6F8FFE75AB7D6862C261F34E96A2AEEF53AB7C21365C2E8FB0582F71EB57B1C227C0E55AE859E9904A25EFECD7B435C4D4357BD840B03649D4A1F8037D89EA4E1967DBEEF1CC17A6111C48F12E9615FFF336D3F07064CB17C0B765A012C850B9E3AA7A6984B96D8C867DDC6D0F4AB52042572244796B7ECFF681CD3B3E2E29AAECA391A775BEE94E502FB15881B0F4AC60314EA947C0C82541C3D16FD8C0E09BB7F8F786582032859D9C13187CE6C0CB6F2D3EE6C3C9727C15F14B21D3CD2E02BDB9D119959B0E03DC9E5A91E2578762300B1517D2352FC1D0BB934A4C3E1B20CE9327DB102E89A6C64A8C3148EDFC5A94913933853442FA84451B31FD21E492F92DD5488E0D871AEBFE335A4B92431DEC69591548010E76A5B365D346786E9A2D3E589867D796AA5E25211201D757560D318A87DFB27F3E625BC373DB48BF94A63161C674C3D4265CB737418441B7650EABC209CF675A439BEB3E9D1AA1B79F67198A40CEFD1C89144F7D8BAF61D6AD36F466DA546B4174A0E0CAF5BD788C8243C7C2DDDCC3DB6FC89F12F17D19FBD9B0BC76FE92891CD6BA07BEA3B66EF12D0D85E788FD58675C1B0FBD16029DCC4D34E7A1A41471BDEDF78BF591A8B4E96D88BEC8EDC093E616292BFC096E69A916E8D624B"), |
| 2796 | }, |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2797 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2798 | shouldFail: true, |
| 2799 | expectedError: ":DH_P_TOO_LONG:", |
| 2800 | }) |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2801 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2802 | // This test ensures that Diffie-Hellman public values are padded with |
| 2803 | // zeros so that they're the same length as the prime. This is to avoid |
| 2804 | // hitting a bug in yaSSL. |
| 2805 | testCases = append(testCases, testCase{ |
| 2806 | testType: serverTest, |
| 2807 | name: "DHPublicValuePadded", |
| 2808 | config: Config{ |
| 2809 | MaxVersion: VersionTLS12, |
| 2810 | CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2811 | Bugs: ProtocolBugs{ |
| 2812 | RequireDHPublicValueLen: (1025 + 7) / 8, |
| 2813 | }, |
Adam Langley | c4f25ce | 2015-11-26 16:39:08 -0800 | [diff] [blame] | 2814 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 2815 | flags: []string{"-use-sparse-dh-prime"}, |
| 2816 | }) |
| 2817 | } |
David Benjamin | cd24a39 | 2015-11-11 13:23:05 -0800 | [diff] [blame] | 2818 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2819 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2820 | testCases = append(testCases, testCase{ |
| 2821 | testType: serverTest, |
| 2822 | name: "UnknownCipher", |
| 2823 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2824 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2825 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2826 | Bugs: ProtocolBugs{ |
| 2827 | AdvertiseAllConfiguredCiphers: true, |
| 2828 | }, |
| 2829 | }, |
| 2830 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2831 | |
| 2832 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2833 | testCases = append(testCases, testCase{ |
| 2834 | testType: serverTest, |
| 2835 | name: "UnknownCipher-TLS13", |
| 2836 | config: Config{ |
| 2837 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2838 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2839 | Bugs: ProtocolBugs{ |
| 2840 | AdvertiseAllConfiguredCiphers: true, |
| 2841 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2842 | }, |
| 2843 | }) |
| 2844 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2845 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2846 | testCases = append(testCases, testCase{ |
| 2847 | name: "EmptyECDHEPSKHint", |
| 2848 | config: Config{ |
| 2849 | MaxVersion: VersionTLS12, |
| 2850 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2851 | PreSharedKey: []byte("secret"), |
| 2852 | }, |
| 2853 | flags: []string{"-psk", "secret"}, |
| 2854 | }) |
| 2855 | |
| 2856 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2857 | // ServerKeyExchange is sent. |
| 2858 | testCases = append(testCases, testCase{ |
| 2859 | name: "ExplicitEmptyPSKHint", |
| 2860 | config: Config{ |
| 2861 | MaxVersion: VersionTLS12, |
| 2862 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2863 | PreSharedKey: []byte("secret"), |
| 2864 | Bugs: ProtocolBugs{ |
| 2865 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2866 | }, |
| 2867 | }, |
| 2868 | flags: []string{"-psk", "secret"}, |
| 2869 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2870 | } |
| 2871 | |
| 2872 | func addBadECDSASignatureTests() { |
| 2873 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2874 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2875 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2876 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2877 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2878 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2879 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2880 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2881 | Bugs: ProtocolBugs{ |
| 2882 | BadECDSAR: badR, |
| 2883 | BadECDSAS: badS, |
| 2884 | }, |
| 2885 | }, |
| 2886 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2887 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2888 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2889 | testCases = append(testCases, testCase{ |
| 2890 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2891 | config: Config{ |
| 2892 | MaxVersion: VersionTLS13, |
| 2893 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2894 | Bugs: ProtocolBugs{ |
| 2895 | BadECDSAR: badR, |
| 2896 | BadECDSAS: badS, |
| 2897 | }, |
| 2898 | }, |
| 2899 | shouldFail: true, |
| 2900 | expectedError: ":BAD_SIGNATURE:", |
| 2901 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2902 | } |
| 2903 | } |
| 2904 | } |
| 2905 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2906 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2907 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2908 | name: "MaxCBCPadding", |
| 2909 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2910 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2911 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2912 | Bugs: ProtocolBugs{ |
| 2913 | MaxPadding: true, |
| 2914 | }, |
| 2915 | }, |
| 2916 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2917 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2918 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2919 | name: "BadCBCPadding", |
| 2920 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2921 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2922 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2923 | Bugs: ProtocolBugs{ |
| 2924 | PaddingFirstByteBad: true, |
| 2925 | }, |
| 2926 | }, |
| 2927 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2928 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2929 | }) |
| 2930 | // OpenSSL previously had an issue where the first byte of padding in |
| 2931 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2932 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2933 | name: "BadCBCPadding255", |
| 2934 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2935 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2936 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2937 | Bugs: ProtocolBugs{ |
| 2938 | MaxPadding: true, |
| 2939 | PaddingFirstByteBadIf255: true, |
| 2940 | }, |
| 2941 | }, |
| 2942 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 2943 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2944 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2945 | }) |
| 2946 | } |
| 2947 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2948 | func addCBCSplittingTests() { |
| 2949 | testCases = append(testCases, testCase{ |
| 2950 | name: "CBCRecordSplitting", |
| 2951 | config: Config{ |
| 2952 | MaxVersion: VersionTLS10, |
| 2953 | MinVersion: VersionTLS10, |
| 2954 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2955 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 2956 | messageLen: -1, // read until EOF |
| 2957 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2958 | flags: []string{ |
| 2959 | "-async", |
| 2960 | "-write-different-record-sizes", |
| 2961 | "-cbc-record-splitting", |
| 2962 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 2963 | }) |
| 2964 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 2965 | name: "CBCRecordSplittingPartialWrite", |
| 2966 | config: Config{ |
| 2967 | MaxVersion: VersionTLS10, |
| 2968 | MinVersion: VersionTLS10, |
| 2969 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2970 | }, |
| 2971 | messageLen: -1, // read until EOF |
| 2972 | flags: []string{ |
| 2973 | "-async", |
| 2974 | "-write-different-record-sizes", |
| 2975 | "-cbc-record-splitting", |
| 2976 | "-partial-write", |
| 2977 | }, |
| 2978 | }) |
| 2979 | } |
| 2980 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2981 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2982 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2983 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 2984 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 2985 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 2986 | if err != nil { |
| 2987 | panic(err) |
| 2988 | } |
| 2989 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2990 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 2991 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 2992 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2993 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2994 | testCases = append(testCases, testCase{ |
| 2995 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 2996 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 2997 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 2998 | MinVersion: ver.version, |
| 2999 | MaxVersion: ver.version, |
| 3000 | ClientAuth: RequireAnyClientCert, |
| 3001 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3002 | }, |
| 3003 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3004 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3005 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3006 | }, |
| 3007 | }) |
| 3008 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3009 | testType: serverTest, |
| 3010 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3011 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3012 | MinVersion: ver.version, |
| 3013 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3014 | Certificates: []Certificate{rsaCertificate}, |
| 3015 | }, |
| 3016 | flags: []string{"-require-any-client-certificate"}, |
| 3017 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3018 | if ver.version != VersionSSL30 { |
| 3019 | testCases = append(testCases, testCase{ |
| 3020 | testType: serverTest, |
| 3021 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3022 | config: Config{ |
| 3023 | MinVersion: ver.version, |
| 3024 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3025 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3026 | }, |
| 3027 | flags: []string{"-require-any-client-certificate"}, |
| 3028 | }) |
| 3029 | testCases = append(testCases, testCase{ |
| 3030 | testType: clientTest, |
| 3031 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3032 | config: Config{ |
| 3033 | MinVersion: ver.version, |
| 3034 | MaxVersion: ver.version, |
| 3035 | ClientAuth: RequireAnyClientCert, |
| 3036 | ClientCAs: certPool, |
| 3037 | }, |
| 3038 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3039 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3040 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3041 | }, |
| 3042 | }) |
| 3043 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3044 | |
| 3045 | testCases = append(testCases, testCase{ |
| 3046 | name: "NoClientCertificate-" + ver.name, |
| 3047 | config: Config{ |
| 3048 | MinVersion: ver.version, |
| 3049 | MaxVersion: ver.version, |
| 3050 | ClientAuth: RequireAnyClientCert, |
| 3051 | }, |
| 3052 | shouldFail: true, |
| 3053 | expectedLocalError: "client didn't provide a certificate", |
| 3054 | }) |
| 3055 | |
| 3056 | testCases = append(testCases, testCase{ |
| 3057 | // Even if not configured to expect a certificate, OpenSSL will |
| 3058 | // return X509_V_OK as the verify_result. |
| 3059 | testType: serverTest, |
| 3060 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3061 | config: Config{ |
| 3062 | MinVersion: ver.version, |
| 3063 | MaxVersion: ver.version, |
| 3064 | }, |
| 3065 | flags: []string{ |
| 3066 | "-expect-verify-result", |
| 3067 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3068 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3069 | }) |
| 3070 | |
| 3071 | testCases = append(testCases, testCase{ |
| 3072 | // If a client certificate is not provided, OpenSSL will still |
| 3073 | // return X509_V_OK as the verify_result. |
| 3074 | testType: serverTest, |
| 3075 | name: "NoClientCertificate-Server-" + ver.name, |
| 3076 | config: Config{ |
| 3077 | MinVersion: ver.version, |
| 3078 | MaxVersion: ver.version, |
| 3079 | }, |
| 3080 | flags: []string{ |
| 3081 | "-expect-verify-result", |
| 3082 | "-verify-peer", |
| 3083 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3084 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3085 | }) |
| 3086 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3087 | certificateRequired := "remote error: certificate required" |
| 3088 | if ver.version < VersionTLS13 { |
| 3089 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3090 | // was used. |
| 3091 | certificateRequired = "remote error: handshake failure" |
| 3092 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3093 | testCases = append(testCases, testCase{ |
| 3094 | testType: serverTest, |
| 3095 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3096 | config: Config{ |
| 3097 | MinVersion: ver.version, |
| 3098 | MaxVersion: ver.version, |
| 3099 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3100 | flags: []string{"-require-any-client-certificate"}, |
| 3101 | shouldFail: true, |
| 3102 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3103 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3104 | }) |
| 3105 | |
| 3106 | if ver.version != VersionSSL30 { |
| 3107 | testCases = append(testCases, testCase{ |
| 3108 | testType: serverTest, |
| 3109 | name: "SkipClientCertificate-" + ver.name, |
| 3110 | config: Config{ |
| 3111 | MinVersion: ver.version, |
| 3112 | MaxVersion: ver.version, |
| 3113 | Bugs: ProtocolBugs{ |
| 3114 | SkipClientCertificate: true, |
| 3115 | }, |
| 3116 | }, |
| 3117 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3118 | flags: []string{"-verify-peer"}, |
| 3119 | shouldFail: true, |
| 3120 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3121 | }) |
| 3122 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3123 | |
| 3124 | testCases = append(testCases, testCase{ |
| 3125 | testType: serverTest, |
| 3126 | name: ver.name + "-Server-CertReq-CA-List", |
| 3127 | config: Config{ |
| 3128 | MinVersion: ver.version, |
| 3129 | MaxVersion: ver.version, |
| 3130 | Certificates: []Certificate{rsaCertificate}, |
| 3131 | Bugs: ProtocolBugs{ |
| 3132 | ExpectCertificateReqNames: caNames, |
| 3133 | }, |
| 3134 | }, |
| 3135 | flags: []string{ |
| 3136 | "-require-any-client-certificate", |
| 3137 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3138 | }, |
| 3139 | }) |
| 3140 | |
| 3141 | testCases = append(testCases, testCase{ |
| 3142 | testType: clientTest, |
| 3143 | name: ver.name + "-Client-CertReq-CA-List", |
| 3144 | config: Config{ |
| 3145 | MinVersion: ver.version, |
| 3146 | MaxVersion: ver.version, |
| 3147 | Certificates: []Certificate{rsaCertificate}, |
| 3148 | ClientAuth: RequireAnyClientCert, |
| 3149 | ClientCAs: certPool, |
| 3150 | }, |
| 3151 | flags: []string{ |
| 3152 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3153 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3154 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3155 | }, |
| 3156 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3157 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3158 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3159 | // Client auth is only legal in certificate-based ciphers. |
| 3160 | testCases = append(testCases, testCase{ |
| 3161 | testType: clientTest, |
| 3162 | name: "ClientAuth-PSK", |
| 3163 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3164 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3165 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3166 | PreSharedKey: []byte("secret"), |
| 3167 | ClientAuth: RequireAnyClientCert, |
| 3168 | }, |
| 3169 | flags: []string{ |
| 3170 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3171 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3172 | "-psk", "secret", |
| 3173 | }, |
| 3174 | shouldFail: true, |
| 3175 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3176 | }) |
| 3177 | testCases = append(testCases, testCase{ |
| 3178 | testType: clientTest, |
| 3179 | name: "ClientAuth-ECDHE_PSK", |
| 3180 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3181 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3182 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3183 | PreSharedKey: []byte("secret"), |
| 3184 | ClientAuth: RequireAnyClientCert, |
| 3185 | }, |
| 3186 | flags: []string{ |
| 3187 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3188 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3189 | "-psk", "secret", |
| 3190 | }, |
| 3191 | shouldFail: true, |
| 3192 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3193 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3194 | |
| 3195 | // Regression test for a bug where the client CA list, if explicitly |
| 3196 | // set to NULL, was mis-encoded. |
| 3197 | testCases = append(testCases, testCase{ |
| 3198 | testType: serverTest, |
| 3199 | name: "Null-Client-CA-List", |
| 3200 | config: Config{ |
| 3201 | MaxVersion: VersionTLS12, |
| 3202 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3203 | Bugs: ProtocolBugs{ |
| 3204 | ExpectCertificateReqNames: [][]byte{}, |
| 3205 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3206 | }, |
| 3207 | flags: []string{ |
| 3208 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3209 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3210 | }, |
| 3211 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3212 | } |
| 3213 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3214 | func addExtendedMasterSecretTests() { |
| 3215 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3216 | |
| 3217 | for _, with := range []bool{false, true} { |
| 3218 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3219 | if with { |
| 3220 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3221 | } |
| 3222 | |
| 3223 | for _, isClient := range []bool{false, true} { |
| 3224 | suffix := "-Server" |
| 3225 | testType := serverTest |
| 3226 | if isClient { |
| 3227 | suffix = "-Client" |
| 3228 | testType = clientTest |
| 3229 | } |
| 3230 | |
| 3231 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3232 | // In TLS 1.3, the extension is irrelevant and |
| 3233 | // always reports as enabled. |
| 3234 | var flags []string |
| 3235 | if with || ver.version >= VersionTLS13 { |
| 3236 | flags = []string{expectEMSFlag} |
| 3237 | } |
| 3238 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3239 | test := testCase{ |
| 3240 | testType: testType, |
| 3241 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3242 | config: Config{ |
| 3243 | MinVersion: ver.version, |
| 3244 | MaxVersion: ver.version, |
| 3245 | Bugs: ProtocolBugs{ |
| 3246 | NoExtendedMasterSecret: !with, |
| 3247 | RequireExtendedMasterSecret: with, |
| 3248 | }, |
| 3249 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3250 | flags: flags, |
| 3251 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3252 | } |
| 3253 | if test.shouldFail { |
| 3254 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3255 | } |
| 3256 | testCases = append(testCases, test) |
| 3257 | } |
| 3258 | } |
| 3259 | } |
| 3260 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3261 | for _, isClient := range []bool{false, true} { |
| 3262 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3263 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3264 | boolToWord := func(b bool) string { |
| 3265 | if b { |
| 3266 | return "Yes" |
| 3267 | } |
| 3268 | return "No" |
| 3269 | } |
| 3270 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3271 | if isClient { |
| 3272 | suffix += "Client" |
| 3273 | } else { |
| 3274 | suffix += "Server" |
| 3275 | } |
| 3276 | |
| 3277 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3278 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3279 | Bugs: ProtocolBugs{ |
| 3280 | RequireExtendedMasterSecret: true, |
| 3281 | }, |
| 3282 | } |
| 3283 | |
| 3284 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3285 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3286 | Bugs: ProtocolBugs{ |
| 3287 | NoExtendedMasterSecret: true, |
| 3288 | }, |
| 3289 | } |
| 3290 | |
| 3291 | test := testCase{ |
| 3292 | name: "ExtendedMasterSecret-" + suffix, |
| 3293 | resumeSession: true, |
| 3294 | } |
| 3295 | |
| 3296 | if !isClient { |
| 3297 | test.testType = serverTest |
| 3298 | } |
| 3299 | |
| 3300 | if supportedInFirstConnection { |
| 3301 | test.config = supportedConfig |
| 3302 | } else { |
| 3303 | test.config = noSupportConfig |
| 3304 | } |
| 3305 | |
| 3306 | if supportedInResumeConnection { |
| 3307 | test.resumeConfig = &supportedConfig |
| 3308 | } else { |
| 3309 | test.resumeConfig = &noSupportConfig |
| 3310 | } |
| 3311 | |
| 3312 | switch suffix { |
| 3313 | case "YesToYes-Client", "YesToYes-Server": |
| 3314 | // When a session is resumed, it should |
| 3315 | // still be aware that its master |
| 3316 | // secret was generated via EMS and |
| 3317 | // thus it's safe to use tls-unique. |
| 3318 | test.flags = []string{expectEMSFlag} |
| 3319 | case "NoToYes-Server": |
| 3320 | // If an original connection did not |
| 3321 | // contain EMS, but a resumption |
| 3322 | // handshake does, then a server should |
| 3323 | // not resume the session. |
| 3324 | test.expectResumeRejected = true |
| 3325 | case "YesToNo-Server": |
| 3326 | // Resuming an EMS session without the |
| 3327 | // EMS extension should cause the |
| 3328 | // server to abort the connection. |
| 3329 | test.shouldFail = true |
| 3330 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3331 | case "NoToYes-Client": |
| 3332 | // A client should abort a connection |
| 3333 | // where the server resumed a non-EMS |
| 3334 | // session but echoed the EMS |
| 3335 | // extension. |
| 3336 | test.shouldFail = true |
| 3337 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3338 | case "YesToNo-Client": |
| 3339 | // A client should abort a connection |
| 3340 | // where the server didn't echo EMS |
| 3341 | // when the session used it. |
| 3342 | test.shouldFail = true |
| 3343 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3344 | } |
| 3345 | |
| 3346 | testCases = append(testCases, test) |
| 3347 | } |
| 3348 | } |
| 3349 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3350 | |
| 3351 | // Switching EMS on renegotiation is forbidden. |
| 3352 | testCases = append(testCases, testCase{ |
| 3353 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3354 | config: Config{ |
| 3355 | MaxVersion: VersionTLS12, |
| 3356 | Bugs: ProtocolBugs{ |
| 3357 | NoExtendedMasterSecret: true, |
| 3358 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3359 | }, |
| 3360 | }, |
| 3361 | renegotiate: 1, |
| 3362 | flags: []string{ |
| 3363 | "-renegotiate-freely", |
| 3364 | "-expect-total-renegotiations", "1", |
| 3365 | }, |
| 3366 | }) |
| 3367 | |
| 3368 | testCases = append(testCases, testCase{ |
| 3369 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3370 | config: Config{ |
| 3371 | MaxVersion: VersionTLS12, |
| 3372 | Bugs: ProtocolBugs{ |
| 3373 | NoExtendedMasterSecret: true, |
| 3374 | }, |
| 3375 | }, |
| 3376 | renegotiate: 1, |
| 3377 | flags: []string{ |
| 3378 | "-renegotiate-freely", |
| 3379 | "-expect-total-renegotiations", "1", |
| 3380 | }, |
| 3381 | shouldFail: true, |
| 3382 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3383 | }) |
| 3384 | |
| 3385 | testCases = append(testCases, testCase{ |
| 3386 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3387 | config: Config{ |
| 3388 | MaxVersion: VersionTLS12, |
| 3389 | Bugs: ProtocolBugs{ |
| 3390 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3391 | }, |
| 3392 | }, |
| 3393 | renegotiate: 1, |
| 3394 | flags: []string{ |
| 3395 | "-renegotiate-freely", |
| 3396 | "-expect-total-renegotiations", "1", |
| 3397 | }, |
| 3398 | shouldFail: true, |
| 3399 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3400 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3401 | } |
| 3402 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3403 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3404 | protocol protocol |
| 3405 | async bool |
| 3406 | splitHandshake bool |
| 3407 | packHandshakeFlight bool |
| 3408 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3409 | } |
| 3410 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3411 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3412 | // various conditions. Some of these are redundant with other tests, but they |
| 3413 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3414 | func addAllStateMachineCoverageTests() { |
| 3415 | for _, async := range []bool{false, true} { |
| 3416 | for _, protocol := range []protocol{tls, dtls} { |
| 3417 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3418 | protocol: protocol, |
| 3419 | async: async, |
| 3420 | }) |
| 3421 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3422 | protocol: protocol, |
| 3423 | async: async, |
| 3424 | implicitHandshake: true, |
| 3425 | }) |
| 3426 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3427 | protocol: protocol, |
| 3428 | async: async, |
| 3429 | splitHandshake: true, |
| 3430 | }) |
| 3431 | if protocol == tls { |
| 3432 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3433 | protocol: protocol, |
| 3434 | async: async, |
| 3435 | packHandshakeFlight: true, |
| 3436 | }) |
| 3437 | } |
| 3438 | } |
| 3439 | } |
| 3440 | } |
| 3441 | |
| 3442 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3443 | var tests []testCase |
| 3444 | |
| 3445 | // Basic handshake, with resumption. Client and server, |
| 3446 | // session ID and session ticket. |
| 3447 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3448 | name: "Basic-Client", |
| 3449 | config: Config{ |
| 3450 | MaxVersion: VersionTLS12, |
| 3451 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3452 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3453 | // Ensure session tickets are used, not session IDs. |
| 3454 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3455 | }) |
| 3456 | tests = append(tests, testCase{ |
| 3457 | name: "Basic-Client-RenewTicket", |
| 3458 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3459 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3460 | Bugs: ProtocolBugs{ |
| 3461 | RenewTicketOnResume: true, |
| 3462 | }, |
| 3463 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3464 | flags: []string{"-expect-ticket-renewal"}, |
| 3465 | resumeSession: true, |
| 3466 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3467 | }) |
| 3468 | tests = append(tests, testCase{ |
| 3469 | name: "Basic-Client-NoTicket", |
| 3470 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3471 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3472 | SessionTicketsDisabled: true, |
| 3473 | }, |
| 3474 | resumeSession: true, |
| 3475 | }) |
| 3476 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3477 | testType: serverTest, |
| 3478 | name: "Basic-Server", |
| 3479 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3480 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3481 | Bugs: ProtocolBugs{ |
| 3482 | RequireSessionTickets: true, |
| 3483 | }, |
| 3484 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3485 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3486 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3487 | }) |
| 3488 | tests = append(tests, testCase{ |
| 3489 | testType: serverTest, |
| 3490 | name: "Basic-Server-NoTickets", |
| 3491 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3492 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3493 | SessionTicketsDisabled: true, |
| 3494 | }, |
| 3495 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3496 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3497 | }) |
| 3498 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3499 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3500 | name: "Basic-Server-EarlyCallback", |
| 3501 | config: Config{ |
| 3502 | MaxVersion: VersionTLS12, |
| 3503 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3504 | flags: []string{"-use-early-callback"}, |
| 3505 | resumeSession: true, |
| 3506 | }) |
| 3507 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3508 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3509 | if config.protocol == tls { |
| 3510 | tests = append(tests, testCase{ |
| 3511 | name: "TLS13-1RTT-Client", |
| 3512 | config: Config{ |
| 3513 | MaxVersion: VersionTLS13, |
| 3514 | MinVersion: VersionTLS13, |
| 3515 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3516 | resumeSession: true, |
| 3517 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3518 | }) |
| 3519 | |
| 3520 | tests = append(tests, testCase{ |
| 3521 | testType: serverTest, |
| 3522 | name: "TLS13-1RTT-Server", |
| 3523 | config: Config{ |
| 3524 | MaxVersion: VersionTLS13, |
| 3525 | MinVersion: VersionTLS13, |
| 3526 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3527 | resumeSession: true, |
| 3528 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3529 | // TLS 1.3 uses tickets, so the session should not be |
| 3530 | // cached statefully. |
| 3531 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3532 | }) |
| 3533 | |
| 3534 | tests = append(tests, testCase{ |
| 3535 | name: "TLS13-HelloRetryRequest-Client", |
| 3536 | config: Config{ |
| 3537 | MaxVersion: VersionTLS13, |
| 3538 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3539 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3540 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3541 | CurvePreferences: []CurveID{CurveP384}, |
| 3542 | Bugs: ProtocolBugs{ |
| 3543 | ExpectMissingKeyShare: true, |
| 3544 | }, |
| 3545 | }, |
| 3546 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3547 | resumeSession: true, |
| 3548 | }) |
| 3549 | |
| 3550 | tests = append(tests, testCase{ |
| 3551 | testType: serverTest, |
| 3552 | name: "TLS13-HelloRetryRequest-Server", |
| 3553 | config: Config{ |
| 3554 | MaxVersion: VersionTLS13, |
| 3555 | MinVersion: VersionTLS13, |
| 3556 | // Require a HelloRetryRequest for every curve. |
| 3557 | DefaultCurves: []CurveID{}, |
| 3558 | }, |
| 3559 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3560 | resumeSession: true, |
| 3561 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3562 | |
| 3563 | // TODO(svaldez): Send data on early data once implemented. |
| 3564 | tests = append(tests, testCase{ |
| 3565 | testType: clientTest, |
| 3566 | name: "TLS13-EarlyData-Client", |
| 3567 | config: Config{ |
| 3568 | MaxVersion: VersionTLS13, |
| 3569 | MinVersion: VersionTLS13, |
| 3570 | MaxEarlyDataSize: 16384, |
| 3571 | }, |
| 3572 | resumeSession: true, |
| 3573 | flags: []string{ |
| 3574 | "-enable-early-data", |
| 3575 | "-expect-early-data-info", |
| 3576 | "-expect-accept-early-data", |
| 3577 | }, |
| 3578 | }) |
| 3579 | |
| 3580 | tests = append(tests, testCase{ |
| 3581 | testType: serverTest, |
| 3582 | name: "TLS13-EarlyData-Server", |
| 3583 | config: Config{ |
| 3584 | MaxVersion: VersionTLS13, |
| 3585 | MinVersion: VersionTLS13, |
| 3586 | Bugs: ProtocolBugs{ |
| 3587 | SendEarlyData: [][]byte{}, |
| 3588 | ExpectEarlyDataAccepted: true, |
| 3589 | }, |
| 3590 | }, |
| 3591 | resumeSession: true, |
| 3592 | flags: []string{ |
| 3593 | "-enable-early-data", |
| 3594 | }, |
| 3595 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3596 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3597 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3598 | // TLS client auth. |
| 3599 | tests = append(tests, testCase{ |
| 3600 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3601 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3602 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3603 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3604 | ClientAuth: RequestClientCert, |
| 3605 | }, |
| 3606 | }) |
| 3607 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3608 | testType: serverTest, |
| 3609 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3610 | config: Config{ |
| 3611 | MaxVersion: VersionTLS12, |
| 3612 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3613 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3614 | flags: []string{"-verify-peer"}, |
| 3615 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3616 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3617 | tests = append(tests, testCase{ |
| 3618 | testType: clientTest, |
| 3619 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3620 | config: Config{ |
| 3621 | MaxVersion: VersionSSL30, |
| 3622 | ClientAuth: RequestClientCert, |
| 3623 | }, |
| 3624 | }) |
| 3625 | tests = append(tests, testCase{ |
| 3626 | testType: serverTest, |
| 3627 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3628 | config: Config{ |
| 3629 | MaxVersion: VersionSSL30, |
| 3630 | }, |
| 3631 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3632 | flags: []string{"-verify-peer"}, |
| 3633 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3634 | tests = append(tests, testCase{ |
| 3635 | testType: clientTest, |
| 3636 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3637 | config: Config{ |
| 3638 | MaxVersion: VersionTLS13, |
| 3639 | ClientAuth: RequestClientCert, |
| 3640 | }, |
| 3641 | }) |
| 3642 | tests = append(tests, testCase{ |
| 3643 | testType: serverTest, |
| 3644 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3645 | config: Config{ |
| 3646 | MaxVersion: VersionTLS13, |
| 3647 | }, |
| 3648 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3649 | flags: []string{"-verify-peer"}, |
| 3650 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3651 | } |
| 3652 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3653 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3654 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3655 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3656 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3657 | ClientAuth: RequireAnyClientCert, |
| 3658 | }, |
| 3659 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3660 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3661 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3662 | }, |
| 3663 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3664 | tests = append(tests, testCase{ |
| 3665 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3666 | name: "ClientAuth-RSA-Client-TLS13", |
| 3667 | config: Config{ |
| 3668 | MaxVersion: VersionTLS13, |
| 3669 | ClientAuth: RequireAnyClientCert, |
| 3670 | }, |
| 3671 | flags: []string{ |
| 3672 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3673 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3674 | }, |
| 3675 | }) |
| 3676 | tests = append(tests, testCase{ |
| 3677 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3678 | name: "ClientAuth-ECDSA-Client", |
| 3679 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3680 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3681 | ClientAuth: RequireAnyClientCert, |
| 3682 | }, |
| 3683 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3684 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3685 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3686 | }, |
| 3687 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3688 | tests = append(tests, testCase{ |
| 3689 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3690 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3691 | config: Config{ |
| 3692 | MaxVersion: VersionTLS13, |
| 3693 | ClientAuth: RequireAnyClientCert, |
| 3694 | }, |
| 3695 | flags: []string{ |
| 3696 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3697 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3698 | }, |
| 3699 | }) |
| 3700 | tests = append(tests, testCase{ |
| 3701 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3702 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3703 | config: Config{ |
| 3704 | MaxVersion: VersionTLS12, |
| 3705 | ClientAuth: RequestClientCert, |
| 3706 | }, |
| 3707 | flags: []string{"-use-old-client-cert-callback"}, |
| 3708 | }) |
| 3709 | tests = append(tests, testCase{ |
| 3710 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3711 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3712 | config: Config{ |
| 3713 | MaxVersion: VersionTLS13, |
| 3714 | ClientAuth: RequestClientCert, |
| 3715 | }, |
| 3716 | flags: []string{"-use-old-client-cert-callback"}, |
| 3717 | }) |
| 3718 | tests = append(tests, testCase{ |
| 3719 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3720 | name: "ClientAuth-OldCallback", |
| 3721 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3722 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3723 | ClientAuth: RequireAnyClientCert, |
| 3724 | }, |
| 3725 | flags: []string{ |
| 3726 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3727 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3728 | "-use-old-client-cert-callback", |
| 3729 | }, |
| 3730 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3731 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3732 | testType: clientTest, |
| 3733 | name: "ClientAuth-OldCallback-TLS13", |
| 3734 | config: Config{ |
| 3735 | MaxVersion: VersionTLS13, |
| 3736 | ClientAuth: RequireAnyClientCert, |
| 3737 | }, |
| 3738 | flags: []string{ |
| 3739 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3740 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3741 | "-use-old-client-cert-callback", |
| 3742 | }, |
| 3743 | }) |
| 3744 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3745 | testType: serverTest, |
| 3746 | name: "ClientAuth-Server", |
| 3747 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3748 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3749 | Certificates: []Certificate{rsaCertificate}, |
| 3750 | }, |
| 3751 | flags: []string{"-require-any-client-certificate"}, |
| 3752 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3753 | tests = append(tests, testCase{ |
| 3754 | testType: serverTest, |
| 3755 | name: "ClientAuth-Server-TLS13", |
| 3756 | config: Config{ |
| 3757 | MaxVersion: VersionTLS13, |
| 3758 | Certificates: []Certificate{rsaCertificate}, |
| 3759 | }, |
| 3760 | flags: []string{"-require-any-client-certificate"}, |
| 3761 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3762 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3763 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3764 | tests = append(tests, testCase{ |
| 3765 | testType: serverTest, |
| 3766 | name: "Basic-Server-RSA", |
| 3767 | config: Config{ |
| 3768 | MaxVersion: VersionTLS12, |
| 3769 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3770 | }, |
| 3771 | flags: []string{ |
| 3772 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3773 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3774 | }, |
| 3775 | }) |
| 3776 | tests = append(tests, testCase{ |
| 3777 | testType: serverTest, |
| 3778 | name: "Basic-Server-ECDHE-RSA", |
| 3779 | config: Config{ |
| 3780 | MaxVersion: VersionTLS12, |
| 3781 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3782 | }, |
| 3783 | flags: []string{ |
| 3784 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3785 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3786 | }, |
| 3787 | }) |
| 3788 | tests = append(tests, testCase{ |
| 3789 | testType: serverTest, |
| 3790 | name: "Basic-Server-ECDHE-ECDSA", |
| 3791 | config: Config{ |
| 3792 | MaxVersion: VersionTLS12, |
| 3793 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3794 | }, |
| 3795 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3796 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3797 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3798 | }, |
| 3799 | }) |
| 3800 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3801 | // No session ticket support; server doesn't send NewSessionTicket. |
| 3802 | tests = append(tests, testCase{ |
| 3803 | name: "SessionTicketsDisabled-Client", |
| 3804 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3805 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3806 | SessionTicketsDisabled: true, |
| 3807 | }, |
| 3808 | }) |
| 3809 | tests = append(tests, testCase{ |
| 3810 | testType: serverTest, |
| 3811 | name: "SessionTicketsDisabled-Server", |
| 3812 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3813 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3814 | SessionTicketsDisabled: true, |
| 3815 | }, |
| 3816 | }) |
| 3817 | |
| 3818 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 3819 | // identity hint. |
| 3820 | tests = append(tests, testCase{ |
| 3821 | name: "EmptyPSKHint-Client", |
| 3822 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3823 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3824 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3825 | PreSharedKey: []byte("secret"), |
| 3826 | }, |
| 3827 | flags: []string{"-psk", "secret"}, |
| 3828 | }) |
| 3829 | tests = append(tests, testCase{ |
| 3830 | testType: serverTest, |
| 3831 | name: "EmptyPSKHint-Server", |
| 3832 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3833 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3834 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3835 | PreSharedKey: []byte("secret"), |
| 3836 | }, |
| 3837 | flags: []string{"-psk", "secret"}, |
| 3838 | }) |
| 3839 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3840 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3841 | tests = append(tests, testCase{ |
| 3842 | testType: clientTest, |
| 3843 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3844 | config: Config{ |
| 3845 | MaxVersion: VersionTLS12, |
| 3846 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3847 | flags: []string{ |
| 3848 | "-enable-ocsp-stapling", |
| 3849 | "-expect-ocsp-response", |
| 3850 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3851 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3852 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3853 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3854 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3855 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3856 | testType: serverTest, |
| 3857 | name: "OCSPStapling-Server", |
| 3858 | config: Config{ |
| 3859 | MaxVersion: VersionTLS12, |
| 3860 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3861 | expectedOCSPResponse: testOCSPResponse, |
| 3862 | flags: []string{ |
| 3863 | "-ocsp-response", |
| 3864 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3865 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 3866 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3867 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3868 | tests = append(tests, testCase{ |
| 3869 | testType: clientTest, |
| 3870 | name: "OCSPStapling-Client-TLS13", |
| 3871 | config: Config{ |
| 3872 | MaxVersion: VersionTLS13, |
| 3873 | }, |
| 3874 | flags: []string{ |
| 3875 | "-enable-ocsp-stapling", |
| 3876 | "-expect-ocsp-response", |
| 3877 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3878 | "-verify-peer", |
| 3879 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3880 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3881 | }) |
| 3882 | tests = append(tests, testCase{ |
| 3883 | testType: serverTest, |
| 3884 | name: "OCSPStapling-Server-TLS13", |
| 3885 | config: Config{ |
| 3886 | MaxVersion: VersionTLS13, |
| 3887 | }, |
| 3888 | expectedOCSPResponse: testOCSPResponse, |
| 3889 | flags: []string{ |
| 3890 | "-ocsp-response", |
| 3891 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 3892 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3893 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 3894 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 3895 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3896 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3897 | for _, vers := range tlsVersions { |
| 3898 | if config.protocol == dtls && !vers.hasDTLS { |
| 3899 | continue |
| 3900 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3901 | for _, testType := range []testType{clientTest, serverTest} { |
| 3902 | suffix := "-Client" |
| 3903 | if testType == serverTest { |
| 3904 | suffix = "-Server" |
| 3905 | } |
| 3906 | suffix += "-" + vers.name |
| 3907 | |
| 3908 | flag := "-verify-peer" |
| 3909 | if testType == serverTest { |
| 3910 | flag = "-require-any-client-certificate" |
| 3911 | } |
| 3912 | |
| 3913 | tests = append(tests, testCase{ |
| 3914 | testType: testType, |
| 3915 | name: "CertificateVerificationSucceed" + suffix, |
| 3916 | config: Config{ |
| 3917 | MaxVersion: vers.version, |
| 3918 | Certificates: []Certificate{rsaCertificate}, |
| 3919 | }, |
| 3920 | flags: []string{ |
| 3921 | flag, |
| 3922 | "-expect-verify-result", |
| 3923 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3924 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3925 | }) |
| 3926 | tests = append(tests, testCase{ |
| 3927 | testType: testType, |
| 3928 | name: "CertificateVerificationFail" + suffix, |
| 3929 | config: Config{ |
| 3930 | MaxVersion: vers.version, |
| 3931 | Certificates: []Certificate{rsaCertificate}, |
| 3932 | }, |
| 3933 | flags: []string{ |
| 3934 | flag, |
| 3935 | "-verify-fail", |
| 3936 | }, |
| 3937 | shouldFail: true, |
| 3938 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 3939 | }) |
| 3940 | } |
| 3941 | |
| 3942 | // By default, the client is in a soft fail mode where the peer |
| 3943 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3944 | tests = append(tests, testCase{ |
| 3945 | testType: clientTest, |
| 3946 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 3947 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 3948 | MaxVersion: vers.version, |
| 3949 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3950 | }, |
| 3951 | flags: []string{ |
| 3952 | "-verify-fail", |
| 3953 | "-expect-verify-result", |
| 3954 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 3955 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3956 | }) |
| 3957 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 3958 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 3959 | tests = append(tests, testCase{ |
| 3960 | name: "ShimSendAlert", |
| 3961 | flags: []string{"-send-alert"}, |
| 3962 | shimWritesFirst: true, |
| 3963 | shouldFail: true, |
| 3964 | expectedLocalError: "remote error: decompression failure", |
| 3965 | }) |
| 3966 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3967 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3968 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3969 | name: "Renegotiate-Client", |
| 3970 | config: Config{ |
| 3971 | MaxVersion: VersionTLS12, |
| 3972 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 3973 | renegotiate: 1, |
| 3974 | flags: []string{ |
| 3975 | "-renegotiate-freely", |
| 3976 | "-expect-total-renegotiations", "1", |
| 3977 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3978 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3979 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 3980 | tests = append(tests, testCase{ |
| 3981 | name: "SendHalfHelloRequest", |
| 3982 | config: Config{ |
| 3983 | MaxVersion: VersionTLS12, |
| 3984 | Bugs: ProtocolBugs{ |
| 3985 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 3986 | }, |
| 3987 | }, |
| 3988 | sendHalfHelloRequest: true, |
| 3989 | flags: []string{"-renegotiate-ignore"}, |
| 3990 | shouldFail: true, |
| 3991 | expectedError: ":UNEXPECTED_RECORD:", |
| 3992 | }) |
| 3993 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3994 | // NPN on client and server; results in post-handshake message. |
| 3995 | tests = append(tests, testCase{ |
| 3996 | name: "NPN-Client", |
| 3997 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3998 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3999 | NextProtos: []string{"foo"}, |
| 4000 | }, |
| 4001 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4002 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4003 | expectedNextProto: "foo", |
| 4004 | expectedNextProtoType: npn, |
| 4005 | }) |
| 4006 | tests = append(tests, testCase{ |
| 4007 | testType: serverTest, |
| 4008 | name: "NPN-Server", |
| 4009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4010 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4011 | NextProtos: []string{"bar"}, |
| 4012 | }, |
| 4013 | flags: []string{ |
| 4014 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4015 | "-expect-next-proto", "bar", |
| 4016 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4017 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4018 | expectedNextProto: "bar", |
| 4019 | expectedNextProtoType: npn, |
| 4020 | }) |
| 4021 | |
| 4022 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4023 | |
| 4024 | // Client does False Start and negotiates NPN. |
| 4025 | tests = append(tests, testCase{ |
| 4026 | name: "FalseStart", |
| 4027 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4028 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4029 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4030 | NextProtos: []string{"foo"}, |
| 4031 | Bugs: ProtocolBugs{ |
| 4032 | ExpectFalseStart: true, |
| 4033 | }, |
| 4034 | }, |
| 4035 | flags: []string{ |
| 4036 | "-false-start", |
| 4037 | "-select-next-proto", "foo", |
| 4038 | }, |
| 4039 | shimWritesFirst: true, |
| 4040 | resumeSession: true, |
| 4041 | }) |
| 4042 | |
| 4043 | // Client does False Start and negotiates ALPN. |
| 4044 | tests = append(tests, testCase{ |
| 4045 | name: "FalseStart-ALPN", |
| 4046 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4047 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4048 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4049 | NextProtos: []string{"foo"}, |
| 4050 | Bugs: ProtocolBugs{ |
| 4051 | ExpectFalseStart: true, |
| 4052 | }, |
| 4053 | }, |
| 4054 | flags: []string{ |
| 4055 | "-false-start", |
| 4056 | "-advertise-alpn", "\x03foo", |
| 4057 | }, |
| 4058 | shimWritesFirst: true, |
| 4059 | resumeSession: true, |
| 4060 | }) |
| 4061 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4062 | // False Start without session tickets. |
| 4063 | tests = append(tests, testCase{ |
| 4064 | name: "FalseStart-SessionTicketsDisabled", |
| 4065 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4066 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4067 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4068 | NextProtos: []string{"foo"}, |
| 4069 | SessionTicketsDisabled: true, |
| 4070 | Bugs: ProtocolBugs{ |
| 4071 | ExpectFalseStart: true, |
| 4072 | }, |
| 4073 | }, |
| 4074 | flags: []string{ |
| 4075 | "-false-start", |
| 4076 | "-select-next-proto", "foo", |
| 4077 | }, |
| 4078 | shimWritesFirst: true, |
| 4079 | }) |
| 4080 | |
| 4081 | // Server parses a V2ClientHello. |
| 4082 | tests = append(tests, testCase{ |
| 4083 | testType: serverTest, |
| 4084 | name: "SendV2ClientHello", |
| 4085 | config: Config{ |
| 4086 | // Choose a cipher suite that does not involve |
| 4087 | // elliptic curves, so no extensions are |
| 4088 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4089 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4090 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4091 | Bugs: ProtocolBugs{ |
| 4092 | SendV2ClientHello: true, |
| 4093 | }, |
| 4094 | }, |
| 4095 | }) |
| 4096 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4097 | // Test Channel ID |
| 4098 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4099 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4100 | continue |
| 4101 | } |
| 4102 | // Client sends a Channel ID. |
| 4103 | tests = append(tests, testCase{ |
| 4104 | name: "ChannelID-Client-" + ver.name, |
| 4105 | config: Config{ |
| 4106 | MaxVersion: ver.version, |
| 4107 | RequestChannelID: true, |
| 4108 | }, |
| 4109 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4110 | resumeSession: true, |
| 4111 | expectChannelID: true, |
| 4112 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4113 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4114 | // Server accepts a Channel ID. |
| 4115 | tests = append(tests, testCase{ |
| 4116 | testType: serverTest, |
| 4117 | name: "ChannelID-Server-" + ver.name, |
| 4118 | config: Config{ |
| 4119 | MaxVersion: ver.version, |
| 4120 | ChannelID: channelIDKey, |
| 4121 | }, |
| 4122 | flags: []string{ |
| 4123 | "-expect-channel-id", |
| 4124 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4125 | }, |
| 4126 | resumeSession: true, |
| 4127 | expectChannelID: true, |
| 4128 | }) |
| 4129 | |
| 4130 | tests = append(tests, testCase{ |
| 4131 | testType: serverTest, |
| 4132 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4133 | config: Config{ |
| 4134 | MaxVersion: ver.version, |
| 4135 | ChannelID: channelIDKey, |
| 4136 | Bugs: ProtocolBugs{ |
| 4137 | InvalidChannelIDSignature: true, |
| 4138 | }, |
| 4139 | }, |
| 4140 | flags: []string{"-enable-channel-id"}, |
| 4141 | shouldFail: true, |
| 4142 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4143 | }) |
| 4144 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4145 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4146 | // Channel ID and NPN at the same time, to ensure their relative |
| 4147 | // ordering is correct. |
| 4148 | tests = append(tests, testCase{ |
| 4149 | name: "ChannelID-NPN-Client", |
| 4150 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4151 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4152 | RequestChannelID: true, |
| 4153 | NextProtos: []string{"foo"}, |
| 4154 | }, |
| 4155 | flags: []string{ |
| 4156 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4157 | "-select-next-proto", "foo", |
| 4158 | }, |
| 4159 | resumeSession: true, |
| 4160 | expectChannelID: true, |
| 4161 | expectedNextProto: "foo", |
| 4162 | expectedNextProtoType: npn, |
| 4163 | }) |
| 4164 | tests = append(tests, testCase{ |
| 4165 | testType: serverTest, |
| 4166 | name: "ChannelID-NPN-Server", |
| 4167 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4168 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4169 | ChannelID: channelIDKey, |
| 4170 | NextProtos: []string{"bar"}, |
| 4171 | }, |
| 4172 | flags: []string{ |
| 4173 | "-expect-channel-id", |
| 4174 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4175 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4176 | "-expect-next-proto", "bar", |
| 4177 | }, |
| 4178 | resumeSession: true, |
| 4179 | expectChannelID: true, |
| 4180 | expectedNextProto: "bar", |
| 4181 | expectedNextProtoType: npn, |
| 4182 | }) |
| 4183 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4184 | // Bidirectional shutdown with the runner initiating. |
| 4185 | tests = append(tests, testCase{ |
| 4186 | name: "Shutdown-Runner", |
| 4187 | config: Config{ |
| 4188 | Bugs: ProtocolBugs{ |
| 4189 | ExpectCloseNotify: true, |
| 4190 | }, |
| 4191 | }, |
| 4192 | flags: []string{"-check-close-notify"}, |
| 4193 | }) |
| 4194 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4195 | if !config.implicitHandshake { |
| 4196 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4197 | // in the meantime, sends garbage before the close_notify which |
| 4198 | // the shim must ignore. This test is disabled under implicit |
| 4199 | // handshake tests because the shim never reads or writes. |
| 4200 | tests = append(tests, testCase{ |
| 4201 | name: "Shutdown-Shim", |
| 4202 | config: Config{ |
| 4203 | MaxVersion: VersionTLS12, |
| 4204 | Bugs: ProtocolBugs{ |
| 4205 | ExpectCloseNotify: true, |
| 4206 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4207 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4208 | shimShutsDown: true, |
| 4209 | sendEmptyRecords: 1, |
| 4210 | sendWarningAlerts: 1, |
| 4211 | flags: []string{"-check-close-notify"}, |
| 4212 | }) |
| 4213 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4214 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4215 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4216 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4217 | tests = append(tests, testCase{ |
| 4218 | name: "SkipHelloVerifyRequest", |
| 4219 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4220 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4221 | Bugs: ProtocolBugs{ |
| 4222 | SkipHelloVerifyRequest: true, |
| 4223 | }, |
| 4224 | }, |
| 4225 | }) |
| 4226 | } |
| 4227 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4228 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4229 | test.protocol = config.protocol |
| 4230 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4231 | test.name += "-DTLS" |
| 4232 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4233 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4234 | test.name += "-Async" |
| 4235 | test.flags = append(test.flags, "-async") |
| 4236 | } else { |
| 4237 | test.name += "-Sync" |
| 4238 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4239 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4240 | test.name += "-SplitHandshakeRecords" |
| 4241 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4242 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4243 | test.config.Bugs.MaxPacketLength = 256 |
| 4244 | test.flags = append(test.flags, "-mtu", "256") |
| 4245 | } |
| 4246 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4247 | if config.packHandshakeFlight { |
| 4248 | test.name += "-PackHandshakeFlight" |
| 4249 | test.config.Bugs.PackHandshakeFlight = true |
| 4250 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4251 | if config.implicitHandshake { |
| 4252 | test.name += "-ImplicitHandshake" |
| 4253 | test.flags = append(test.flags, "-implicit-handshake") |
| 4254 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4255 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4256 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4257 | } |
| 4258 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4259 | func addDDoSCallbackTests() { |
| 4260 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4261 | for _, resume := range []bool{false, true} { |
| 4262 | suffix := "Resume" |
| 4263 | if resume { |
| 4264 | suffix = "No" + suffix |
| 4265 | } |
| 4266 | |
| 4267 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4268 | testType: serverTest, |
| 4269 | name: "Server-DDoS-OK-" + suffix, |
| 4270 | config: Config{ |
| 4271 | MaxVersion: VersionTLS12, |
| 4272 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4273 | flags: []string{"-install-ddos-callback"}, |
| 4274 | resumeSession: resume, |
| 4275 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4276 | testCases = append(testCases, testCase{ |
| 4277 | testType: serverTest, |
| 4278 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4279 | config: Config{ |
| 4280 | MaxVersion: VersionTLS13, |
| 4281 | }, |
| 4282 | flags: []string{"-install-ddos-callback"}, |
| 4283 | resumeSession: resume, |
| 4284 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4285 | |
| 4286 | failFlag := "-fail-ddos-callback" |
| 4287 | if resume { |
| 4288 | failFlag = "-fail-second-ddos-callback" |
| 4289 | } |
| 4290 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4291 | testType: serverTest, |
| 4292 | name: "Server-DDoS-Reject-" + suffix, |
| 4293 | config: Config{ |
| 4294 | MaxVersion: VersionTLS12, |
| 4295 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4296 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4297 | resumeSession: resume, |
| 4298 | shouldFail: true, |
| 4299 | expectedError: ":CONNECTION_REJECTED:", |
| 4300 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4301 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4302 | testCases = append(testCases, testCase{ |
| 4303 | testType: serverTest, |
| 4304 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4305 | config: Config{ |
| 4306 | MaxVersion: VersionTLS13, |
| 4307 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4308 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4309 | resumeSession: resume, |
| 4310 | shouldFail: true, |
| 4311 | expectedError: ":CONNECTION_REJECTED:", |
| 4312 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4313 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4314 | } |
| 4315 | } |
| 4316 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4317 | func addVersionNegotiationTests() { |
| 4318 | for i, shimVers := range tlsVersions { |
| 4319 | // Assemble flags to disable all newer versions on the shim. |
| 4320 | var flags []string |
| 4321 | for _, vers := range tlsVersions[i+1:] { |
| 4322 | flags = append(flags, vers.flag) |
| 4323 | } |
| 4324 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4325 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4326 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4327 | protocols := []protocol{tls} |
| 4328 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4329 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4330 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4331 | for _, protocol := range protocols { |
| 4332 | expectedVersion := shimVers.version |
| 4333 | if runnerVers.version < shimVers.version { |
| 4334 | expectedVersion = runnerVers.version |
| 4335 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4336 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4337 | suffix := shimVers.name + "-" + runnerVers.name |
| 4338 | if protocol == dtls { |
| 4339 | suffix += "-DTLS" |
| 4340 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4341 | |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4342 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4343 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4344 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4345 | clientVers := shimVers.version |
| 4346 | if clientVers > VersionTLS10 { |
| 4347 | clientVers = VersionTLS10 |
| 4348 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4349 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4350 | serverVers := expectedVersion |
| 4351 | if expectedVersion >= VersionTLS13 { |
| 4352 | serverVers = VersionTLS10 |
| 4353 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4354 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4355 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4356 | testCases = append(testCases, testCase{ |
| 4357 | protocol: protocol, |
| 4358 | testType: clientTest, |
| 4359 | name: "VersionNegotiation-Client-" + suffix, |
| 4360 | config: Config{ |
| 4361 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4362 | Bugs: ProtocolBugs{ |
| 4363 | ExpectInitialRecordVersion: clientVers, |
| 4364 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4365 | }, |
| 4366 | flags: flags, |
| 4367 | expectedVersion: expectedVersion, |
| 4368 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4369 | testCases = append(testCases, testCase{ |
| 4370 | protocol: protocol, |
| 4371 | testType: clientTest, |
| 4372 | name: "VersionNegotiation-Client2-" + suffix, |
| 4373 | config: Config{ |
| 4374 | MaxVersion: runnerVers.version, |
| 4375 | Bugs: ProtocolBugs{ |
| 4376 | ExpectInitialRecordVersion: clientVers, |
| 4377 | }, |
| 4378 | }, |
| 4379 | flags: []string{"-max-version", shimVersFlag}, |
| 4380 | expectedVersion: expectedVersion, |
| 4381 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4382 | |
| 4383 | testCases = append(testCases, testCase{ |
| 4384 | protocol: protocol, |
| 4385 | testType: serverTest, |
| 4386 | name: "VersionNegotiation-Server-" + suffix, |
| 4387 | config: Config{ |
| 4388 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4389 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4390 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4391 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4392 | }, |
| 4393 | flags: flags, |
| 4394 | expectedVersion: expectedVersion, |
| 4395 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4396 | testCases = append(testCases, testCase{ |
| 4397 | protocol: protocol, |
| 4398 | testType: serverTest, |
| 4399 | name: "VersionNegotiation-Server2-" + suffix, |
| 4400 | config: Config{ |
| 4401 | MaxVersion: runnerVers.version, |
| 4402 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4403 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4404 | }, |
| 4405 | }, |
| 4406 | flags: []string{"-max-version", shimVersFlag}, |
| 4407 | expectedVersion: expectedVersion, |
| 4408 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4409 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4410 | } |
| 4411 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4412 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4413 | // Test the version extension at all versions. |
| 4414 | for _, vers := range tlsVersions { |
| 4415 | protocols := []protocol{tls} |
| 4416 | if vers.hasDTLS { |
| 4417 | protocols = append(protocols, dtls) |
| 4418 | } |
| 4419 | for _, protocol := range protocols { |
| 4420 | suffix := vers.name |
| 4421 | if protocol == dtls { |
| 4422 | suffix += "-DTLS" |
| 4423 | } |
| 4424 | |
| 4425 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4426 | testCases = append(testCases, testCase{ |
| 4427 | protocol: protocol, |
| 4428 | testType: serverTest, |
| 4429 | name: "VersionNegotiationExtension-" + suffix, |
| 4430 | config: Config{ |
| 4431 | Bugs: ProtocolBugs{ |
| 4432 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4433 | }, |
| 4434 | }, |
| 4435 | expectedVersion: vers.version, |
| 4436 | }) |
| 4437 | } |
| 4438 | |
| 4439 | } |
| 4440 | |
| 4441 | // If all versions are unknown, negotiation fails. |
| 4442 | testCases = append(testCases, testCase{ |
| 4443 | testType: serverTest, |
| 4444 | name: "NoSupportedVersions", |
| 4445 | config: Config{ |
| 4446 | Bugs: ProtocolBugs{ |
| 4447 | SendSupportedVersions: []uint16{0x1111}, |
| 4448 | }, |
| 4449 | }, |
| 4450 | shouldFail: true, |
| 4451 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4452 | }) |
| 4453 | testCases = append(testCases, testCase{ |
| 4454 | protocol: dtls, |
| 4455 | testType: serverTest, |
| 4456 | name: "NoSupportedVersions-DTLS", |
| 4457 | config: Config{ |
| 4458 | Bugs: ProtocolBugs{ |
| 4459 | SendSupportedVersions: []uint16{0x1111}, |
| 4460 | }, |
| 4461 | }, |
| 4462 | shouldFail: true, |
| 4463 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4464 | }) |
| 4465 | |
| 4466 | testCases = append(testCases, testCase{ |
| 4467 | testType: serverTest, |
| 4468 | name: "ClientHelloVersionTooHigh", |
| 4469 | config: Config{ |
| 4470 | MaxVersion: VersionTLS13, |
| 4471 | Bugs: ProtocolBugs{ |
| 4472 | SendClientVersion: 0x0304, |
| 4473 | OmitSupportedVersions: true, |
| 4474 | }, |
| 4475 | }, |
| 4476 | expectedVersion: VersionTLS12, |
| 4477 | }) |
| 4478 | |
| 4479 | testCases = append(testCases, testCase{ |
| 4480 | testType: serverTest, |
| 4481 | name: "ConflictingVersionNegotiation", |
| 4482 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4483 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4484 | SendClientVersion: VersionTLS12, |
| 4485 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4486 | }, |
| 4487 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4488 | // The extension takes precedence over the ClientHello version. |
| 4489 | expectedVersion: VersionTLS11, |
| 4490 | }) |
| 4491 | |
| 4492 | testCases = append(testCases, testCase{ |
| 4493 | testType: serverTest, |
| 4494 | name: "ConflictingVersionNegotiation-2", |
| 4495 | config: Config{ |
| 4496 | Bugs: ProtocolBugs{ |
| 4497 | SendClientVersion: VersionTLS11, |
| 4498 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4499 | }, |
| 4500 | }, |
| 4501 | // The extension takes precedence over the ClientHello version. |
| 4502 | expectedVersion: VersionTLS12, |
| 4503 | }) |
| 4504 | |
| 4505 | testCases = append(testCases, testCase{ |
| 4506 | testType: serverTest, |
| 4507 | name: "RejectFinalTLS13", |
| 4508 | config: Config{ |
| 4509 | Bugs: ProtocolBugs{ |
| 4510 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4511 | }, |
| 4512 | }, |
| 4513 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4514 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4515 | expectedVersion: VersionTLS12, |
| 4516 | }) |
| 4517 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4518 | // Test that the maximum version is selected regardless of the |
| 4519 | // client-sent order. |
| 4520 | testCases = append(testCases, testCase{ |
| 4521 | testType: serverTest, |
| 4522 | name: "IgnoreClientVersionOrder", |
| 4523 | config: Config{ |
| 4524 | Bugs: ProtocolBugs{ |
| 4525 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4526 | }, |
| 4527 | }, |
| 4528 | expectedVersion: VersionTLS13, |
| 4529 | }) |
| 4530 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4531 | // Test for version tolerance. |
| 4532 | testCases = append(testCases, testCase{ |
| 4533 | testType: serverTest, |
| 4534 | name: "MinorVersionTolerance", |
| 4535 | config: Config{ |
| 4536 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4537 | SendClientVersion: 0x03ff, |
| 4538 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4539 | }, |
| 4540 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4541 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4542 | }) |
| 4543 | testCases = append(testCases, testCase{ |
| 4544 | testType: serverTest, |
| 4545 | name: "MajorVersionTolerance", |
| 4546 | config: Config{ |
| 4547 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4548 | SendClientVersion: 0x0400, |
| 4549 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4550 | }, |
| 4551 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4552 | // TLS 1.3 must be negotiated with the supported_versions |
| 4553 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4554 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4555 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4556 | testCases = append(testCases, testCase{ |
| 4557 | testType: serverTest, |
| 4558 | name: "VersionTolerance-TLS13", |
| 4559 | config: Config{ |
| 4560 | Bugs: ProtocolBugs{ |
| 4561 | // Although TLS 1.3 does not use |
| 4562 | // ClientHello.version, it still tolerates high |
| 4563 | // values there. |
| 4564 | SendClientVersion: 0x0400, |
| 4565 | }, |
| 4566 | }, |
| 4567 | expectedVersion: VersionTLS13, |
| 4568 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4569 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4570 | testCases = append(testCases, testCase{ |
| 4571 | protocol: dtls, |
| 4572 | testType: serverTest, |
| 4573 | name: "MinorVersionTolerance-DTLS", |
| 4574 | config: Config{ |
| 4575 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4576 | SendClientVersion: 0xfe00, |
| 4577 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4578 | }, |
| 4579 | }, |
| 4580 | expectedVersion: VersionTLS12, |
| 4581 | }) |
| 4582 | testCases = append(testCases, testCase{ |
| 4583 | protocol: dtls, |
| 4584 | testType: serverTest, |
| 4585 | name: "MajorVersionTolerance-DTLS", |
| 4586 | config: Config{ |
| 4587 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4588 | SendClientVersion: 0xfdff, |
| 4589 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4590 | }, |
| 4591 | }, |
| 4592 | expectedVersion: VersionTLS12, |
| 4593 | }) |
| 4594 | |
| 4595 | // Test that versions below 3.0 are rejected. |
| 4596 | testCases = append(testCases, testCase{ |
| 4597 | testType: serverTest, |
| 4598 | name: "VersionTooLow", |
| 4599 | config: Config{ |
| 4600 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4601 | SendClientVersion: 0x0200, |
| 4602 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4603 | }, |
| 4604 | }, |
| 4605 | shouldFail: true, |
| 4606 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4607 | }) |
| 4608 | testCases = append(testCases, testCase{ |
| 4609 | protocol: dtls, |
| 4610 | testType: serverTest, |
| 4611 | name: "VersionTooLow-DTLS", |
| 4612 | config: Config{ |
| 4613 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4614 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4615 | }, |
| 4616 | }, |
| 4617 | shouldFail: true, |
| 4618 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4619 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4620 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4621 | testCases = append(testCases, testCase{ |
| 4622 | name: "ServerBogusVersion", |
| 4623 | config: Config{ |
| 4624 | Bugs: ProtocolBugs{ |
| 4625 | SendServerHelloVersion: 0x1234, |
| 4626 | }, |
| 4627 | }, |
| 4628 | shouldFail: true, |
| 4629 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4630 | }) |
| 4631 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4632 | // Test TLS 1.3's downgrade signal. |
| 4633 | testCases = append(testCases, testCase{ |
| 4634 | name: "Downgrade-TLS12-Client", |
| 4635 | config: Config{ |
| 4636 | Bugs: ProtocolBugs{ |
| 4637 | NegotiateVersion: VersionTLS12, |
| 4638 | }, |
| 4639 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4640 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4641 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4642 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4643 | }) |
| 4644 | testCases = append(testCases, testCase{ |
| 4645 | testType: serverTest, |
| 4646 | name: "Downgrade-TLS12-Server", |
| 4647 | config: Config{ |
| 4648 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4649 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4650 | }, |
| 4651 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4652 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4653 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4654 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4655 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4656 | } |
| 4657 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4658 | func addMinimumVersionTests() { |
| 4659 | for i, shimVers := range tlsVersions { |
| 4660 | // Assemble flags to disable all older versions on the shim. |
| 4661 | var flags []string |
| 4662 | for _, vers := range tlsVersions[:i] { |
| 4663 | flags = append(flags, vers.flag) |
| 4664 | } |
| 4665 | |
| 4666 | for _, runnerVers := range tlsVersions { |
| 4667 | protocols := []protocol{tls} |
| 4668 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4669 | protocols = append(protocols, dtls) |
| 4670 | } |
| 4671 | for _, protocol := range protocols { |
| 4672 | suffix := shimVers.name + "-" + runnerVers.name |
| 4673 | if protocol == dtls { |
| 4674 | suffix += "-DTLS" |
| 4675 | } |
| 4676 | shimVersFlag := strconv.Itoa(int(versionToWire(shimVers.version, protocol == dtls))) |
| 4677 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4678 | var expectedVersion uint16 |
| 4679 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4680 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4681 | if runnerVers.version >= shimVers.version { |
| 4682 | expectedVersion = runnerVers.version |
| 4683 | } else { |
| 4684 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4685 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4686 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4687 | } |
| 4688 | |
| 4689 | testCases = append(testCases, testCase{ |
| 4690 | protocol: protocol, |
| 4691 | testType: clientTest, |
| 4692 | name: "MinimumVersion-Client-" + suffix, |
| 4693 | config: Config{ |
| 4694 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4695 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4696 | // Ensure the server does not decline to |
| 4697 | // select a version (versions extension) or |
| 4698 | // cipher (some ciphers depend on versions). |
| 4699 | NegotiateVersion: runnerVers.version, |
| 4700 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4701 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4702 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4703 | flags: flags, |
| 4704 | expectedVersion: expectedVersion, |
| 4705 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4706 | expectedError: expectedError, |
| 4707 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4708 | }) |
| 4709 | testCases = append(testCases, testCase{ |
| 4710 | protocol: protocol, |
| 4711 | testType: clientTest, |
| 4712 | name: "MinimumVersion-Client2-" + suffix, |
| 4713 | config: Config{ |
| 4714 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4715 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4716 | // Ensure the server does not decline to |
| 4717 | // select a version (versions extension) or |
| 4718 | // cipher (some ciphers depend on versions). |
| 4719 | NegotiateVersion: runnerVers.version, |
| 4720 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4721 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4722 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4723 | flags: []string{"-min-version", shimVersFlag}, |
| 4724 | expectedVersion: expectedVersion, |
| 4725 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4726 | expectedError: expectedError, |
| 4727 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4728 | }) |
| 4729 | |
| 4730 | testCases = append(testCases, testCase{ |
| 4731 | protocol: protocol, |
| 4732 | testType: serverTest, |
| 4733 | name: "MinimumVersion-Server-" + suffix, |
| 4734 | config: Config{ |
| 4735 | MaxVersion: runnerVers.version, |
| 4736 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4737 | flags: flags, |
| 4738 | expectedVersion: expectedVersion, |
| 4739 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4740 | expectedError: expectedError, |
| 4741 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4742 | }) |
| 4743 | testCases = append(testCases, testCase{ |
| 4744 | protocol: protocol, |
| 4745 | testType: serverTest, |
| 4746 | name: "MinimumVersion-Server2-" + suffix, |
| 4747 | config: Config{ |
| 4748 | MaxVersion: runnerVers.version, |
| 4749 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4750 | flags: []string{"-min-version", shimVersFlag}, |
| 4751 | expectedVersion: expectedVersion, |
| 4752 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4753 | expectedError: expectedError, |
| 4754 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4755 | }) |
| 4756 | } |
| 4757 | } |
| 4758 | } |
| 4759 | } |
| 4760 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4761 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4762 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4763 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4764 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4765 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4766 | // Repeat extensions tests all versions except SSL 3.0. |
| 4767 | for _, ver := range tlsVersions { |
| 4768 | if ver.version == VersionSSL30 { |
| 4769 | continue |
| 4770 | } |
| 4771 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4772 | // Test that duplicate extensions are rejected. |
| 4773 | testCases = append(testCases, testCase{ |
| 4774 | testType: clientTest, |
| 4775 | name: "DuplicateExtensionClient-" + ver.name, |
| 4776 | config: Config{ |
| 4777 | MaxVersion: ver.version, |
| 4778 | Bugs: ProtocolBugs{ |
| 4779 | DuplicateExtension: true, |
| 4780 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4781 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4782 | shouldFail: true, |
| 4783 | expectedLocalError: "remote error: error decoding message", |
| 4784 | }) |
| 4785 | testCases = append(testCases, testCase{ |
| 4786 | testType: serverTest, |
| 4787 | name: "DuplicateExtensionServer-" + ver.name, |
| 4788 | config: Config{ |
| 4789 | MaxVersion: ver.version, |
| 4790 | Bugs: ProtocolBugs{ |
| 4791 | DuplicateExtension: true, |
| 4792 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4793 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4794 | shouldFail: true, |
| 4795 | expectedLocalError: "remote error: error decoding message", |
| 4796 | }) |
| 4797 | |
| 4798 | // Test SNI. |
| 4799 | testCases = append(testCases, testCase{ |
| 4800 | testType: clientTest, |
| 4801 | name: "ServerNameExtensionClient-" + ver.name, |
| 4802 | config: Config{ |
| 4803 | MaxVersion: ver.version, |
| 4804 | Bugs: ProtocolBugs{ |
| 4805 | ExpectServerName: "example.com", |
| 4806 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4807 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4808 | flags: []string{"-host-name", "example.com"}, |
| 4809 | }) |
| 4810 | testCases = append(testCases, testCase{ |
| 4811 | testType: clientTest, |
| 4812 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 4813 | config: Config{ |
| 4814 | MaxVersion: ver.version, |
| 4815 | Bugs: ProtocolBugs{ |
| 4816 | ExpectServerName: "mismatch.com", |
| 4817 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4818 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4819 | flags: []string{"-host-name", "example.com"}, |
| 4820 | shouldFail: true, |
| 4821 | expectedLocalError: "tls: unexpected server name", |
| 4822 | }) |
| 4823 | testCases = append(testCases, testCase{ |
| 4824 | testType: clientTest, |
| 4825 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 4826 | config: Config{ |
| 4827 | MaxVersion: ver.version, |
| 4828 | Bugs: ProtocolBugs{ |
| 4829 | ExpectServerName: "missing.com", |
| 4830 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4831 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4832 | shouldFail: true, |
| 4833 | expectedLocalError: "tls: unexpected server name", |
| 4834 | }) |
| 4835 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 4836 | testType: clientTest, |
| 4837 | name: "TolerateServerNameAck-" + ver.name, |
| 4838 | config: Config{ |
| 4839 | MaxVersion: ver.version, |
| 4840 | Bugs: ProtocolBugs{ |
| 4841 | SendServerNameAck: true, |
| 4842 | }, |
| 4843 | }, |
| 4844 | flags: []string{"-host-name", "example.com"}, |
| 4845 | resumeSession: true, |
| 4846 | }) |
| 4847 | testCases = append(testCases, testCase{ |
| 4848 | testType: clientTest, |
| 4849 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 4850 | config: Config{ |
| 4851 | MaxVersion: ver.version, |
| 4852 | Bugs: ProtocolBugs{ |
| 4853 | SendServerNameAck: true, |
| 4854 | }, |
| 4855 | }, |
| 4856 | shouldFail: true, |
| 4857 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 4858 | expectedLocalError: "remote error: unsupported extension", |
| 4859 | }) |
| 4860 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4861 | testType: serverTest, |
| 4862 | name: "ServerNameExtensionServer-" + ver.name, |
| 4863 | config: Config{ |
| 4864 | MaxVersion: ver.version, |
| 4865 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 4866 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4867 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4868 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4869 | }) |
| 4870 | |
| 4871 | // Test ALPN. |
| 4872 | testCases = append(testCases, testCase{ |
| 4873 | testType: clientTest, |
| 4874 | name: "ALPNClient-" + ver.name, |
| 4875 | config: Config{ |
| 4876 | MaxVersion: ver.version, |
| 4877 | NextProtos: []string{"foo"}, |
| 4878 | }, |
| 4879 | flags: []string{ |
| 4880 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 4881 | "-expect-alpn", "foo", |
| 4882 | }, |
| 4883 | expectedNextProto: "foo", |
| 4884 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4885 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4886 | }) |
| 4887 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 4888 | testType: clientTest, |
| 4889 | name: "ALPNClient-Mismatch-" + ver.name, |
| 4890 | config: Config{ |
| 4891 | MaxVersion: ver.version, |
| 4892 | Bugs: ProtocolBugs{ |
| 4893 | SendALPN: "baz", |
| 4894 | }, |
| 4895 | }, |
| 4896 | flags: []string{ |
| 4897 | "-advertise-alpn", "\x03foo\x03bar", |
| 4898 | }, |
| 4899 | shouldFail: true, |
| 4900 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 4901 | expectedLocalError: "remote error: illegal parameter", |
| 4902 | }) |
| 4903 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4904 | testType: serverTest, |
| 4905 | name: "ALPNServer-" + ver.name, |
| 4906 | config: Config{ |
| 4907 | MaxVersion: ver.version, |
| 4908 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4909 | }, |
| 4910 | flags: []string{ |
| 4911 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4912 | "-select-alpn", "foo", |
| 4913 | }, |
| 4914 | expectedNextProto: "foo", |
| 4915 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4916 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4917 | }) |
| 4918 | testCases = append(testCases, testCase{ |
| 4919 | testType: serverTest, |
| 4920 | name: "ALPNServer-Decline-" + ver.name, |
| 4921 | config: Config{ |
| 4922 | MaxVersion: ver.version, |
| 4923 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4924 | }, |
| 4925 | flags: []string{"-decline-alpn"}, |
| 4926 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4927 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4928 | }) |
| 4929 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4930 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 4931 | // called once. |
| 4932 | testCases = append(testCases, testCase{ |
| 4933 | testType: serverTest, |
| 4934 | name: "ALPNServer-Async-" + ver.name, |
| 4935 | config: Config{ |
| 4936 | MaxVersion: ver.version, |
| 4937 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 4938 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 4939 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4940 | }, |
| 4941 | flags: []string{ |
| 4942 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4943 | "-select-alpn", "foo", |
| 4944 | "-async", |
| 4945 | }, |
| 4946 | expectedNextProto: "foo", |
| 4947 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4948 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 4949 | }) |
| 4950 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4951 | var emptyString string |
| 4952 | testCases = append(testCases, testCase{ |
| 4953 | testType: clientTest, |
| 4954 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 4955 | config: Config{ |
| 4956 | MaxVersion: ver.version, |
| 4957 | NextProtos: []string{""}, |
| 4958 | Bugs: ProtocolBugs{ |
| 4959 | // A server returning an empty ALPN protocol |
| 4960 | // should be rejected. |
| 4961 | ALPNProtocol: &emptyString, |
| 4962 | }, |
| 4963 | }, |
| 4964 | flags: []string{ |
| 4965 | "-advertise-alpn", "\x03foo", |
| 4966 | }, |
| 4967 | shouldFail: true, |
| 4968 | expectedError: ":PARSE_TLSEXT:", |
| 4969 | }) |
| 4970 | testCases = append(testCases, testCase{ |
| 4971 | testType: serverTest, |
| 4972 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 4973 | config: Config{ |
| 4974 | MaxVersion: ver.version, |
| 4975 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4976 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4977 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 4978 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4979 | flags: []string{ |
| 4980 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 4981 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4982 | shouldFail: true, |
| 4983 | expectedError: ":PARSE_TLSEXT:", |
| 4984 | }) |
| 4985 | |
| 4986 | // Test NPN and the interaction with ALPN. |
| 4987 | if ver.version < VersionTLS13 { |
| 4988 | // Test that the server prefers ALPN over NPN. |
| 4989 | testCases = append(testCases, testCase{ |
| 4990 | testType: serverTest, |
| 4991 | name: "ALPNServer-Preferred-" + ver.name, |
| 4992 | config: Config{ |
| 4993 | MaxVersion: ver.version, |
| 4994 | NextProtos: []string{"foo", "bar", "baz"}, |
| 4995 | }, |
| 4996 | flags: []string{ |
| 4997 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 4998 | "-select-alpn", "foo", |
| 4999 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5000 | }, |
| 5001 | expectedNextProto: "foo", |
| 5002 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5003 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5004 | }) |
| 5005 | testCases = append(testCases, testCase{ |
| 5006 | testType: serverTest, |
| 5007 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5008 | config: Config{ |
| 5009 | MaxVersion: ver.version, |
| 5010 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5011 | Bugs: ProtocolBugs{ |
| 5012 | SwapNPNAndALPN: true, |
| 5013 | }, |
| 5014 | }, |
| 5015 | flags: []string{ |
| 5016 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5017 | "-select-alpn", "foo", |
| 5018 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5019 | }, |
| 5020 | expectedNextProto: "foo", |
| 5021 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5022 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5023 | }) |
| 5024 | |
| 5025 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5026 | testCases = append(testCases, testCase{ |
| 5027 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5028 | config: Config{ |
| 5029 | MaxVersion: ver.version, |
| 5030 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5031 | Bugs: ProtocolBugs{ |
| 5032 | NegotiateALPNAndNPN: true, |
| 5033 | }, |
| 5034 | }, |
| 5035 | flags: []string{ |
| 5036 | "-advertise-alpn", "\x03foo", |
| 5037 | "-select-next-proto", "foo", |
| 5038 | }, |
| 5039 | shouldFail: true, |
| 5040 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5041 | }) |
| 5042 | testCases = append(testCases, testCase{ |
| 5043 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5044 | config: Config{ |
| 5045 | MaxVersion: ver.version, |
| 5046 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5047 | Bugs: ProtocolBugs{ |
| 5048 | NegotiateALPNAndNPN: true, |
| 5049 | SwapNPNAndALPN: true, |
| 5050 | }, |
| 5051 | }, |
| 5052 | flags: []string{ |
| 5053 | "-advertise-alpn", "\x03foo", |
| 5054 | "-select-next-proto", "foo", |
| 5055 | }, |
| 5056 | shouldFail: true, |
| 5057 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5058 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5059 | } |
| 5060 | |
| 5061 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5062 | |
| 5063 | // Resume with a corrupt ticket. |
| 5064 | testCases = append(testCases, testCase{ |
| 5065 | testType: serverTest, |
| 5066 | name: "CorruptTicket-" + ver.name, |
| 5067 | config: Config{ |
| 5068 | MaxVersion: ver.version, |
| 5069 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5070 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5071 | in[len(in)-1] ^= 1 |
| 5072 | return in, nil |
| 5073 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5074 | }, |
| 5075 | }, |
| 5076 | resumeSession: true, |
| 5077 | expectResumeRejected: true, |
| 5078 | }) |
| 5079 | // Test the ticket callback, with and without renewal. |
| 5080 | testCases = append(testCases, testCase{ |
| 5081 | testType: serverTest, |
| 5082 | name: "TicketCallback-" + ver.name, |
| 5083 | config: Config{ |
| 5084 | MaxVersion: ver.version, |
| 5085 | }, |
| 5086 | resumeSession: true, |
| 5087 | flags: []string{"-use-ticket-callback"}, |
| 5088 | }) |
| 5089 | testCases = append(testCases, testCase{ |
| 5090 | testType: serverTest, |
| 5091 | name: "TicketCallback-Renew-" + ver.name, |
| 5092 | config: Config{ |
| 5093 | MaxVersion: ver.version, |
| 5094 | Bugs: ProtocolBugs{ |
| 5095 | ExpectNewTicket: true, |
| 5096 | }, |
| 5097 | }, |
| 5098 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5099 | resumeSession: true, |
| 5100 | }) |
| 5101 | |
| 5102 | // Test that the ticket callback is only called once when everything before |
| 5103 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5104 | // certificate selection callbacks run. |
| 5105 | testCases = append(testCases, testCase{ |
| 5106 | testType: serverTest, |
| 5107 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5108 | config: Config{ |
| 5109 | MaxVersion: ver.version, |
| 5110 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5111 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5112 | in[len(in)-1] ^= 1 |
| 5113 | return in, nil |
| 5114 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5115 | }, |
| 5116 | }, |
| 5117 | resumeSession: true, |
| 5118 | expectResumeRejected: true, |
| 5119 | flags: []string{ |
| 5120 | "-use-ticket-callback", |
| 5121 | "-async", |
| 5122 | }, |
| 5123 | }) |
| 5124 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5125 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5126 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5127 | testCases = append(testCases, testCase{ |
| 5128 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5129 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5130 | config: Config{ |
| 5131 | MaxVersion: ver.version, |
| 5132 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5133 | EmptyTicketSessionID: true, |
| 5134 | }, |
| 5135 | }, |
| 5136 | resumeSession: true, |
| 5137 | }) |
| 5138 | testCases = append(testCases, testCase{ |
| 5139 | testType: serverTest, |
| 5140 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5141 | config: Config{ |
| 5142 | MaxVersion: ver.version, |
| 5143 | Bugs: ProtocolBugs{ |
| 5144 | TicketSessionIDLength: 16, |
| 5145 | }, |
| 5146 | }, |
| 5147 | resumeSession: true, |
| 5148 | }) |
| 5149 | testCases = append(testCases, testCase{ |
| 5150 | testType: serverTest, |
| 5151 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5152 | config: Config{ |
| 5153 | MaxVersion: ver.version, |
| 5154 | Bugs: ProtocolBugs{ |
| 5155 | TicketSessionIDLength: 32, |
| 5156 | }, |
| 5157 | }, |
| 5158 | resumeSession: true, |
| 5159 | }) |
| 5160 | testCases = append(testCases, testCase{ |
| 5161 | testType: serverTest, |
| 5162 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5163 | config: Config{ |
| 5164 | MaxVersion: ver.version, |
| 5165 | Bugs: ProtocolBugs{ |
| 5166 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5167 | }, |
| 5168 | }, |
| 5169 | resumeSession: true, |
| 5170 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5171 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5172 | expectedError: ":DECODE_ERROR:", |
| 5173 | }) |
| 5174 | } |
| 5175 | |
| 5176 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5177 | // are ignored. |
| 5178 | if ver.hasDTLS { |
| 5179 | testCases = append(testCases, testCase{ |
| 5180 | protocol: dtls, |
| 5181 | name: "SRTP-Client-" + ver.name, |
| 5182 | config: Config{ |
| 5183 | MaxVersion: ver.version, |
| 5184 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5185 | }, |
| 5186 | flags: []string{ |
| 5187 | "-srtp-profiles", |
| 5188 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5189 | }, |
| 5190 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5191 | }) |
| 5192 | testCases = append(testCases, testCase{ |
| 5193 | protocol: dtls, |
| 5194 | testType: serverTest, |
| 5195 | name: "SRTP-Server-" + ver.name, |
| 5196 | config: Config{ |
| 5197 | MaxVersion: ver.version, |
| 5198 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5199 | }, |
| 5200 | flags: []string{ |
| 5201 | "-srtp-profiles", |
| 5202 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5203 | }, |
| 5204 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5205 | }) |
| 5206 | // Test that the MKI is ignored. |
| 5207 | testCases = append(testCases, testCase{ |
| 5208 | protocol: dtls, |
| 5209 | testType: serverTest, |
| 5210 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5211 | config: Config{ |
| 5212 | MaxVersion: ver.version, |
| 5213 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5214 | Bugs: ProtocolBugs{ |
| 5215 | SRTPMasterKeyIdentifer: "bogus", |
| 5216 | }, |
| 5217 | }, |
| 5218 | flags: []string{ |
| 5219 | "-srtp-profiles", |
| 5220 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5221 | }, |
| 5222 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5223 | }) |
| 5224 | // Test that SRTP isn't negotiated on the server if there were |
| 5225 | // no matching profiles. |
| 5226 | testCases = append(testCases, testCase{ |
| 5227 | protocol: dtls, |
| 5228 | testType: serverTest, |
| 5229 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5230 | config: Config{ |
| 5231 | MaxVersion: ver.version, |
| 5232 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5233 | }, |
| 5234 | flags: []string{ |
| 5235 | "-srtp-profiles", |
| 5236 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5237 | }, |
| 5238 | expectedSRTPProtectionProfile: 0, |
| 5239 | }) |
| 5240 | // Test that the server returning an invalid SRTP profile is |
| 5241 | // flagged as an error by the client. |
| 5242 | testCases = append(testCases, testCase{ |
| 5243 | protocol: dtls, |
| 5244 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5245 | config: Config{ |
| 5246 | MaxVersion: ver.version, |
| 5247 | Bugs: ProtocolBugs{ |
| 5248 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5249 | }, |
| 5250 | }, |
| 5251 | flags: []string{ |
| 5252 | "-srtp-profiles", |
| 5253 | "SRTP_AES128_CM_SHA1_80", |
| 5254 | }, |
| 5255 | shouldFail: true, |
| 5256 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5257 | }) |
| 5258 | } |
| 5259 | |
| 5260 | // Test SCT list. |
| 5261 | testCases = append(testCases, testCase{ |
| 5262 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5263 | testType: clientTest, |
| 5264 | config: Config{ |
| 5265 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5266 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5267 | flags: []string{ |
| 5268 | "-enable-signed-cert-timestamps", |
| 5269 | "-expect-signed-cert-timestamps", |
| 5270 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5271 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5272 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5273 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5274 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5275 | var differentSCTList []byte |
| 5276 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5277 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5278 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5279 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5280 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5281 | testCases = append(testCases, testCase{ |
| 5282 | name: "SendSCTListOnResume-" + ver.name, |
| 5283 | config: Config{ |
| 5284 | MaxVersion: ver.version, |
| 5285 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5286 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5287 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5288 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5289 | flags: []string{ |
| 5290 | "-enable-signed-cert-timestamps", |
| 5291 | "-expect-signed-cert-timestamps", |
| 5292 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5293 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5294 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5295 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5296 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5297 | testCases = append(testCases, testCase{ |
| 5298 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5299 | testType: serverTest, |
| 5300 | config: Config{ |
| 5301 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5302 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5303 | flags: []string{ |
| 5304 | "-signed-cert-timestamps", |
| 5305 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5306 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5307 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5308 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5309 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5310 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5311 | emptySCTListCert := *testCerts[0].cert |
| 5312 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5313 | |
| 5314 | // Test empty SCT list. |
| 5315 | testCases = append(testCases, testCase{ |
| 5316 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5317 | testType: clientTest, |
| 5318 | config: Config{ |
| 5319 | MaxVersion: ver.version, |
| 5320 | Certificates: []Certificate{emptySCTListCert}, |
| 5321 | }, |
| 5322 | flags: []string{ |
| 5323 | "-enable-signed-cert-timestamps", |
| 5324 | }, |
| 5325 | shouldFail: true, |
| 5326 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5327 | }) |
| 5328 | |
| 5329 | emptySCTCert := *testCerts[0].cert |
| 5330 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5331 | |
| 5332 | // Test empty SCT in non-empty list. |
| 5333 | testCases = append(testCases, testCase{ |
| 5334 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5335 | testType: clientTest, |
| 5336 | config: Config{ |
| 5337 | MaxVersion: ver.version, |
| 5338 | Certificates: []Certificate{emptySCTCert}, |
| 5339 | }, |
| 5340 | flags: []string{ |
| 5341 | "-enable-signed-cert-timestamps", |
| 5342 | }, |
| 5343 | shouldFail: true, |
| 5344 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5345 | }) |
| 5346 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5347 | // Test that certificate-related extensions are not sent unsolicited. |
| 5348 | testCases = append(testCases, testCase{ |
| 5349 | testType: serverTest, |
| 5350 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5351 | config: Config{ |
| 5352 | MaxVersion: ver.version, |
| 5353 | Bugs: ProtocolBugs{ |
| 5354 | NoOCSPStapling: true, |
| 5355 | NoSignedCertificateTimestamps: true, |
| 5356 | }, |
| 5357 | }, |
| 5358 | flags: []string{ |
| 5359 | "-ocsp-response", |
| 5360 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5361 | "-signed-cert-timestamps", |
| 5362 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5363 | }, |
| 5364 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5365 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5366 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5367 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5368 | testType: clientTest, |
| 5369 | name: "ClientHelloPadding", |
| 5370 | config: Config{ |
| 5371 | Bugs: ProtocolBugs{ |
| 5372 | RequireClientHelloSize: 512, |
| 5373 | }, |
| 5374 | }, |
| 5375 | // This hostname just needs to be long enough to push the |
| 5376 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5377 | // long. |
| 5378 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5379 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5380 | |
| 5381 | // Extensions should not function in SSL 3.0. |
| 5382 | testCases = append(testCases, testCase{ |
| 5383 | testType: serverTest, |
| 5384 | name: "SSLv3Extensions-NoALPN", |
| 5385 | config: Config{ |
| 5386 | MaxVersion: VersionSSL30, |
| 5387 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5388 | }, |
| 5389 | flags: []string{ |
| 5390 | "-select-alpn", "foo", |
| 5391 | }, |
| 5392 | expectNoNextProto: true, |
| 5393 | }) |
| 5394 | |
| 5395 | // Test session tickets separately as they follow a different codepath. |
| 5396 | testCases = append(testCases, testCase{ |
| 5397 | testType: serverTest, |
| 5398 | name: "SSLv3Extensions-NoTickets", |
| 5399 | config: Config{ |
| 5400 | MaxVersion: VersionSSL30, |
| 5401 | Bugs: ProtocolBugs{ |
| 5402 | // Historically, session tickets in SSL 3.0 |
| 5403 | // failed in different ways depending on whether |
| 5404 | // the client supported renegotiation_info. |
| 5405 | NoRenegotiationInfo: true, |
| 5406 | }, |
| 5407 | }, |
| 5408 | resumeSession: true, |
| 5409 | }) |
| 5410 | testCases = append(testCases, testCase{ |
| 5411 | testType: serverTest, |
| 5412 | name: "SSLv3Extensions-NoTickets2", |
| 5413 | config: Config{ |
| 5414 | MaxVersion: VersionSSL30, |
| 5415 | }, |
| 5416 | resumeSession: true, |
| 5417 | }) |
| 5418 | |
| 5419 | // But SSL 3.0 does send and process renegotiation_info. |
| 5420 | testCases = append(testCases, testCase{ |
| 5421 | testType: serverTest, |
| 5422 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5423 | config: Config{ |
| 5424 | MaxVersion: VersionSSL30, |
| 5425 | Bugs: ProtocolBugs{ |
| 5426 | RequireRenegotiationInfo: true, |
| 5427 | }, |
| 5428 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5429 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5430 | }) |
| 5431 | testCases = append(testCases, testCase{ |
| 5432 | testType: serverTest, |
| 5433 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5434 | config: Config{ |
| 5435 | MaxVersion: VersionSSL30, |
| 5436 | Bugs: ProtocolBugs{ |
| 5437 | NoRenegotiationInfo: true, |
| 5438 | SendRenegotiationSCSV: true, |
| 5439 | RequireRenegotiationInfo: true, |
| 5440 | }, |
| 5441 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5442 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5443 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5444 | |
| 5445 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5446 | // in ServerHello. |
| 5447 | testCases = append(testCases, testCase{ |
| 5448 | name: "NPN-Forbidden-TLS13", |
| 5449 | config: Config{ |
| 5450 | MaxVersion: VersionTLS13, |
| 5451 | NextProtos: []string{"foo"}, |
| 5452 | Bugs: ProtocolBugs{ |
| 5453 | NegotiateNPNAtAllVersions: true, |
| 5454 | }, |
| 5455 | }, |
| 5456 | flags: []string{"-select-next-proto", "foo"}, |
| 5457 | shouldFail: true, |
| 5458 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5459 | }) |
| 5460 | testCases = append(testCases, testCase{ |
| 5461 | name: "EMS-Forbidden-TLS13", |
| 5462 | config: Config{ |
| 5463 | MaxVersion: VersionTLS13, |
| 5464 | Bugs: ProtocolBugs{ |
| 5465 | NegotiateEMSAtAllVersions: true, |
| 5466 | }, |
| 5467 | }, |
| 5468 | shouldFail: true, |
| 5469 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5470 | }) |
| 5471 | testCases = append(testCases, testCase{ |
| 5472 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5473 | config: Config{ |
| 5474 | MaxVersion: VersionTLS13, |
| 5475 | Bugs: ProtocolBugs{ |
| 5476 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5477 | }, |
| 5478 | }, |
| 5479 | shouldFail: true, |
| 5480 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5481 | }) |
| 5482 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5483 | name: "Ticket-Forbidden-TLS13", |
| 5484 | config: Config{ |
| 5485 | MaxVersion: VersionTLS12, |
| 5486 | }, |
| 5487 | resumeConfig: &Config{ |
| 5488 | MaxVersion: VersionTLS13, |
| 5489 | Bugs: ProtocolBugs{ |
| 5490 | AdvertiseTicketExtension: true, |
| 5491 | }, |
| 5492 | }, |
| 5493 | resumeSession: true, |
| 5494 | shouldFail: true, |
| 5495 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5496 | }) |
| 5497 | |
| 5498 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5499 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5500 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5501 | // implicit in every test.) |
| 5502 | testCases = append(testCases, testCase{ |
| 5503 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5504 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5505 | config: Config{ |
| 5506 | MaxVersion: VersionTLS13, |
| 5507 | NextProtos: []string{"bar"}, |
| 5508 | }, |
| 5509 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5510 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5511 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5512 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5513 | // tolerated. |
| 5514 | testCases = append(testCases, testCase{ |
| 5515 | name: "SendOCSPResponseOnResume-TLS12", |
| 5516 | config: Config{ |
| 5517 | MaxVersion: VersionTLS12, |
| 5518 | Bugs: ProtocolBugs{ |
| 5519 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5520 | }, |
| 5521 | }, |
| 5522 | flags: []string{ |
| 5523 | "-enable-ocsp-stapling", |
| 5524 | "-expect-ocsp-response", |
| 5525 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5526 | }, |
| 5527 | resumeSession: true, |
| 5528 | }) |
| 5529 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5530 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5531 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5532 | config: Config{ |
| 5533 | MaxVersion: VersionTLS13, |
| 5534 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5535 | SendExtensionOnCertificate: testOCSPExtension, |
| 5536 | }, |
| 5537 | }, |
| 5538 | shouldFail: true, |
| 5539 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5540 | }) |
| 5541 | |
| 5542 | testCases = append(testCases, testCase{ |
| 5543 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5544 | config: Config{ |
| 5545 | MaxVersion: VersionTLS13, |
| 5546 | Bugs: ProtocolBugs{ |
| 5547 | SendExtensionOnCertificate: testSCTExtension, |
| 5548 | }, |
| 5549 | }, |
| 5550 | shouldFail: true, |
| 5551 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5552 | }) |
| 5553 | |
| 5554 | // Test that extensions on client certificates are never accepted. |
| 5555 | testCases = append(testCases, testCase{ |
| 5556 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5557 | testType: serverTest, |
| 5558 | config: Config{ |
| 5559 | MaxVersion: VersionTLS13, |
| 5560 | Certificates: []Certificate{rsaCertificate}, |
| 5561 | Bugs: ProtocolBugs{ |
| 5562 | SendExtensionOnCertificate: testOCSPExtension, |
| 5563 | }, |
| 5564 | }, |
| 5565 | flags: []string{ |
| 5566 | "-enable-ocsp-stapling", |
| 5567 | "-require-any-client-certificate", |
| 5568 | }, |
| 5569 | shouldFail: true, |
| 5570 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5571 | }) |
| 5572 | |
| 5573 | testCases = append(testCases, testCase{ |
| 5574 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5575 | config: Config{ |
| 5576 | MaxVersion: VersionTLS13, |
| 5577 | Bugs: ProtocolBugs{ |
| 5578 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5579 | }, |
| 5580 | }, |
| 5581 | shouldFail: true, |
| 5582 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5583 | }) |
| 5584 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5585 | var differentSCTList []byte |
| 5586 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5587 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5588 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5589 | // Test that extensions on intermediates are allowed but ignored. |
| 5590 | testCases = append(testCases, testCase{ |
| 5591 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5592 | config: Config{ |
| 5593 | MaxVersion: VersionTLS13, |
| 5594 | Certificates: []Certificate{rsaChainCertificate}, |
| 5595 | Bugs: ProtocolBugs{ |
| 5596 | // Send different values on the intermediate. This tests |
| 5597 | // the intermediate's extensions do not override the |
| 5598 | // leaf's. |
| 5599 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5600 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5601 | }, |
| 5602 | }, |
| 5603 | flags: []string{ |
| 5604 | "-enable-ocsp-stapling", |
| 5605 | "-expect-ocsp-response", |
| 5606 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5607 | "-enable-signed-cert-timestamps", |
| 5608 | "-expect-signed-cert-timestamps", |
| 5609 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5610 | }, |
| 5611 | resumeSession: true, |
| 5612 | }) |
| 5613 | |
| 5614 | // Test that extensions are not sent on intermediates when configured |
| 5615 | // only for a leaf. |
| 5616 | testCases = append(testCases, testCase{ |
| 5617 | testType: serverTest, |
| 5618 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5619 | config: Config{ |
| 5620 | MaxVersion: VersionTLS13, |
| 5621 | Bugs: ProtocolBugs{ |
| 5622 | ExpectNoExtensionsOnIntermediate: true, |
| 5623 | }, |
| 5624 | }, |
| 5625 | flags: []string{ |
| 5626 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5627 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5628 | "-ocsp-response", |
| 5629 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5630 | "-signed-cert-timestamps", |
| 5631 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5632 | }, |
| 5633 | }) |
| 5634 | |
| 5635 | // Test that extensions are not sent on client certificates. |
| 5636 | testCases = append(testCases, testCase{ |
| 5637 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5638 | config: Config{ |
| 5639 | MaxVersion: VersionTLS13, |
| 5640 | ClientAuth: RequireAnyClientCert, |
| 5641 | }, |
| 5642 | flags: []string{ |
| 5643 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5644 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5645 | "-ocsp-response", |
| 5646 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5647 | "-signed-cert-timestamps", |
| 5648 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5649 | }, |
| 5650 | }) |
| 5651 | |
| 5652 | testCases = append(testCases, testCase{ |
| 5653 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5654 | config: Config{ |
| 5655 | MaxVersion: VersionTLS13, |
| 5656 | Bugs: ProtocolBugs{ |
| 5657 | SendDuplicateCertExtensions: true, |
| 5658 | }, |
| 5659 | }, |
| 5660 | flags: []string{ |
| 5661 | "-enable-ocsp-stapling", |
| 5662 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5663 | }, |
| 5664 | resumeSession: true, |
| 5665 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5666 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5667 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5668 | |
| 5669 | testCases = append(testCases, testCase{ |
| 5670 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5671 | testType: serverTest, |
| 5672 | flags: []string{ |
| 5673 | "-signed-cert-timestamps", |
| 5674 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5675 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5676 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5677 | expectedError: ":INVALID_SCT_LIST:", |
| 5678 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5679 | } |
| 5680 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5681 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5682 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5683 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5684 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5685 | // have session IDs, so skip their cross-resumption |
| 5686 | // tests. |
| 5687 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5688 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5689 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5690 | } |
| 5691 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5692 | protocols := []protocol{tls} |
| 5693 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5694 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5695 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5696 | for _, protocol := range protocols { |
| 5697 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5698 | if protocol == dtls { |
| 5699 | suffix += "-DTLS" |
| 5700 | } |
| 5701 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5702 | if sessionVers.version == resumeVers.version { |
| 5703 | testCases = append(testCases, testCase{ |
| 5704 | protocol: protocol, |
| 5705 | name: "Resume-Client" + suffix, |
| 5706 | resumeSession: true, |
| 5707 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5708 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5709 | Bugs: ProtocolBugs{ |
| 5710 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5711 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5712 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5713 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5714 | expectedVersion: sessionVers.version, |
| 5715 | expectedResumeVersion: resumeVers.version, |
| 5716 | }) |
| 5717 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5718 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5719 | |
| 5720 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5721 | // there is no way to convince a non-lookahead client the |
| 5722 | // session was resumed. It will appear to the client that a |
| 5723 | // stray ChangeCipherSpec was sent. |
| 5724 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5725 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5726 | } |
| 5727 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5728 | testCases = append(testCases, testCase{ |
| 5729 | protocol: protocol, |
| 5730 | name: "Resume-Client-Mismatch" + suffix, |
| 5731 | resumeSession: true, |
| 5732 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5733 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5734 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5735 | expectedVersion: sessionVers.version, |
| 5736 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5737 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5738 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5739 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5740 | }, |
| 5741 | }, |
| 5742 | expectedResumeVersion: resumeVers.version, |
| 5743 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5744 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5745 | }) |
| 5746 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5747 | |
| 5748 | testCases = append(testCases, testCase{ |
| 5749 | protocol: protocol, |
| 5750 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5751 | resumeSession: true, |
| 5752 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5753 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5754 | }, |
| 5755 | expectedVersion: sessionVers.version, |
| 5756 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5757 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5758 | }, |
| 5759 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5760 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5761 | expectedResumeVersion: resumeVers.version, |
| 5762 | }) |
| 5763 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5764 | testCases = append(testCases, testCase{ |
| 5765 | protocol: protocol, |
| 5766 | testType: serverTest, |
| 5767 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5768 | resumeSession: true, |
| 5769 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5770 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5771 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 5772 | expectedVersion: sessionVers.version, |
| 5773 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5774 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5775 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5776 | Bugs: ProtocolBugs{ |
| 5777 | SendBothTickets: true, |
| 5778 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5779 | }, |
| 5780 | expectedResumeVersion: resumeVers.version, |
| 5781 | }) |
| 5782 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5783 | } |
| 5784 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5785 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5786 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5787 | testCases = append(testCases, testCase{ |
| 5788 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5789 | name: "ShimTicketRewritable", |
| 5790 | resumeSession: true, |
| 5791 | config: Config{ |
| 5792 | MaxVersion: VersionTLS12, |
| 5793 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5794 | Bugs: ProtocolBugs{ |
| 5795 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5796 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 5797 | if err != nil { |
| 5798 | return nil, err |
| 5799 | } |
| 5800 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5801 | }, |
| 5802 | }, |
| 5803 | }, |
| 5804 | flags: []string{ |
| 5805 | "-ticket-key", |
| 5806 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5807 | }, |
| 5808 | }) |
| 5809 | |
| 5810 | // Resumptions are declined if the version does not match. |
| 5811 | testCases = append(testCases, testCase{ |
| 5812 | testType: serverTest, |
| 5813 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5814 | resumeSession: true, |
| 5815 | config: Config{ |
| 5816 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5817 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5818 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5819 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5820 | return SetShimTicketVersion(in, VersionTLS13) |
| 5821 | }, |
| 5822 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5823 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5824 | flags: []string{ |
| 5825 | "-ticket-key", |
| 5826 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5827 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5828 | expectResumeRejected: true, |
| 5829 | }) |
| 5830 | |
| 5831 | testCases = append(testCases, testCase{ |
| 5832 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5833 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5834 | resumeSession: true, |
| 5835 | config: Config{ |
| 5836 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5837 | Bugs: ProtocolBugs{ |
| 5838 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5839 | return SetShimTicketVersion(in, VersionTLS12) |
| 5840 | }, |
| 5841 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5842 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5843 | flags: []string{ |
| 5844 | "-ticket-key", |
| 5845 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5846 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 5847 | expectResumeRejected: true, |
| 5848 | }) |
| 5849 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5850 | // Resumptions are declined if the cipher is invalid or disabled. |
| 5851 | testCases = append(testCases, testCase{ |
| 5852 | testType: serverTest, |
| 5853 | name: "Resume-Server-DeclineBadCipher", |
| 5854 | resumeSession: true, |
| 5855 | config: Config{ |
| 5856 | MaxVersion: VersionTLS12, |
| 5857 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5858 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5859 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5860 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5861 | }, |
| 5862 | }, |
| 5863 | }, |
| 5864 | flags: []string{ |
| 5865 | "-ticket-key", |
| 5866 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5867 | }, |
| 5868 | expectResumeRejected: true, |
| 5869 | }) |
| 5870 | |
| 5871 | testCases = append(testCases, testCase{ |
| 5872 | testType: serverTest, |
| 5873 | name: "Resume-Server-DeclineBadCipher-2", |
| 5874 | resumeSession: true, |
| 5875 | config: Config{ |
| 5876 | MaxVersion: VersionTLS12, |
| 5877 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5878 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5879 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5880 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 5881 | }, |
| 5882 | }, |
| 5883 | }, |
| 5884 | flags: []string{ |
| 5885 | "-cipher", "AES128", |
| 5886 | "-ticket-key", |
| 5887 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5888 | }, |
| 5889 | expectResumeRejected: true, |
| 5890 | }) |
| 5891 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5892 | // Sessions are not resumed if they do not use the preferred cipher. |
| 5893 | testCases = append(testCases, testCase{ |
| 5894 | testType: serverTest, |
| 5895 | name: "Resume-Server-CipherNotPreferred", |
| 5896 | resumeSession: true, |
| 5897 | config: Config{ |
| 5898 | MaxVersion: VersionTLS12, |
| 5899 | Bugs: ProtocolBugs{ |
| 5900 | ExpectNewTicket: true, |
| 5901 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5902 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 5903 | }, |
| 5904 | }, |
| 5905 | }, |
| 5906 | flags: []string{ |
| 5907 | "-ticket-key", |
| 5908 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5909 | }, |
| 5910 | shouldFail: false, |
| 5911 | expectResumeRejected: true, |
| 5912 | }) |
| 5913 | |
| 5914 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 5915 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 5916 | testCases = append(testCases, testCase{ |
| 5917 | testType: serverTest, |
| 5918 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 5919 | resumeSession: true, |
| 5920 | config: Config{ |
| 5921 | MaxVersion: VersionTLS13, |
| 5922 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 5923 | Bugs: ProtocolBugs{ |
| 5924 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5925 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 5926 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 5927 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 5928 | }, |
| 5929 | }, |
| 5930 | }, |
| 5931 | flags: []string{ |
| 5932 | "-ticket-key", |
| 5933 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5934 | }, |
| 5935 | shouldFail: false, |
| 5936 | expectResumeRejected: true, |
| 5937 | }) |
| 5938 | |
| 5939 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5940 | testCases = append(testCases, testCase{ |
| 5941 | testType: serverTest, |
| 5942 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 5943 | resumeSession: true, |
| 5944 | config: Config{ |
| 5945 | MaxVersion: VersionTLS13, |
| 5946 | Bugs: ProtocolBugs{ |
| 5947 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5948 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 5949 | }, |
| 5950 | }, |
| 5951 | }, |
| 5952 | flags: []string{ |
| 5953 | "-ticket-key", |
| 5954 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 5955 | }, |
| 5956 | expectResumeRejected: true, |
| 5957 | }) |
| 5958 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5959 | // If the client does not offer the cipher from the session, decline to |
| 5960 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 5961 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5962 | testCases = append(testCases, testCase{ |
| 5963 | testType: serverTest, |
| 5964 | name: "Resume-Server-UnofferedCipher", |
| 5965 | resumeSession: true, |
| 5966 | config: Config{ |
| 5967 | MaxVersion: VersionTLS12, |
| 5968 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5969 | }, |
| 5970 | resumeConfig: &Config{ |
| 5971 | MaxVersion: VersionTLS12, |
| 5972 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 5973 | Bugs: ProtocolBugs{ |
| 5974 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 5975 | }, |
| 5976 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5977 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5978 | }) |
| 5979 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5980 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 5981 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 5982 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 5983 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 5984 | testCases = append(testCases, testCase{ |
| 5985 | testType: serverTest, |
| 5986 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 5987 | resumeSession: true, |
| 5988 | config: Config{ |
| 5989 | MaxVersion: VersionTLS13, |
| 5990 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5991 | }, |
| 5992 | resumeConfig: &Config{ |
| 5993 | MaxVersion: VersionTLS13, |
| 5994 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 5995 | Bugs: ProtocolBugs{ |
| 5996 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 5997 | }, |
| 5998 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 5999 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6000 | }) |
| 6001 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6002 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6003 | testCases = append(testCases, testCase{ |
| 6004 | name: "Resume-Client-CipherMismatch", |
| 6005 | resumeSession: true, |
| 6006 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6007 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6008 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6009 | }, |
| 6010 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6011 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6012 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6013 | Bugs: ProtocolBugs{ |
| 6014 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6015 | }, |
| 6016 | }, |
| 6017 | shouldFail: true, |
| 6018 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6019 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6020 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6021 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6022 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6023 | testCases = append(testCases, testCase{ |
| 6024 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6025 | resumeSession: true, |
| 6026 | config: Config{ |
| 6027 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6028 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6029 | }, |
| 6030 | resumeConfig: &Config{ |
| 6031 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6032 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6033 | }, |
| 6034 | }) |
| 6035 | |
| 6036 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6037 | testCases = append(testCases, testCase{ |
| 6038 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6039 | resumeSession: true, |
| 6040 | config: Config{ |
| 6041 | MaxVersion: VersionTLS13, |
| 6042 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6043 | }, |
| 6044 | resumeConfig: &Config{ |
| 6045 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6046 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6047 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6048 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6049 | }, |
| 6050 | }, |
| 6051 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6052 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6053 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6054 | |
| 6055 | testCases = append(testCases, testCase{ |
| 6056 | testType: serverTest, |
| 6057 | name: "Resume-Server-BinderWrongLength", |
| 6058 | resumeSession: true, |
| 6059 | config: Config{ |
| 6060 | MaxVersion: VersionTLS13, |
| 6061 | Bugs: ProtocolBugs{ |
| 6062 | SendShortPSKBinder: true, |
| 6063 | }, |
| 6064 | }, |
| 6065 | shouldFail: true, |
| 6066 | expectedLocalError: "remote error: error decrypting message", |
| 6067 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6068 | }) |
| 6069 | |
| 6070 | testCases = append(testCases, testCase{ |
| 6071 | testType: serverTest, |
| 6072 | name: "Resume-Server-NoPSKBinder", |
| 6073 | resumeSession: true, |
| 6074 | config: Config{ |
| 6075 | MaxVersion: VersionTLS13, |
| 6076 | Bugs: ProtocolBugs{ |
| 6077 | SendNoPSKBinder: true, |
| 6078 | }, |
| 6079 | }, |
| 6080 | shouldFail: true, |
| 6081 | expectedLocalError: "remote error: error decoding message", |
| 6082 | expectedError: ":DECODE_ERROR:", |
| 6083 | }) |
| 6084 | |
| 6085 | testCases = append(testCases, testCase{ |
| 6086 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6087 | name: "Resume-Server-ExtraPSKBinder", |
| 6088 | resumeSession: true, |
| 6089 | config: Config{ |
| 6090 | MaxVersion: VersionTLS13, |
| 6091 | Bugs: ProtocolBugs{ |
| 6092 | SendExtraPSKBinder: true, |
| 6093 | }, |
| 6094 | }, |
| 6095 | shouldFail: true, |
| 6096 | expectedLocalError: "remote error: illegal parameter", |
| 6097 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6098 | }) |
| 6099 | |
| 6100 | testCases = append(testCases, testCase{ |
| 6101 | testType: serverTest, |
| 6102 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6103 | resumeSession: true, |
| 6104 | config: Config{ |
| 6105 | MaxVersion: VersionTLS13, |
| 6106 | Bugs: ProtocolBugs{ |
| 6107 | ExtraPSKIdentity: true, |
| 6108 | }, |
| 6109 | }, |
| 6110 | shouldFail: true, |
| 6111 | expectedLocalError: "remote error: illegal parameter", |
| 6112 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6113 | }) |
| 6114 | |
| 6115 | testCases = append(testCases, testCase{ |
| 6116 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6117 | name: "Resume-Server-InvalidPSKBinder", |
| 6118 | resumeSession: true, |
| 6119 | config: Config{ |
| 6120 | MaxVersion: VersionTLS13, |
| 6121 | Bugs: ProtocolBugs{ |
| 6122 | SendInvalidPSKBinder: true, |
| 6123 | }, |
| 6124 | }, |
| 6125 | shouldFail: true, |
| 6126 | expectedLocalError: "remote error: error decrypting message", |
| 6127 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6128 | }) |
| 6129 | |
| 6130 | testCases = append(testCases, testCase{ |
| 6131 | testType: serverTest, |
| 6132 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6133 | resumeSession: true, |
| 6134 | config: Config{ |
| 6135 | MaxVersion: VersionTLS13, |
| 6136 | Bugs: ProtocolBugs{ |
| 6137 | PSKBinderFirst: true, |
| 6138 | }, |
| 6139 | }, |
| 6140 | shouldFail: true, |
| 6141 | expectedLocalError: "remote error: illegal parameter", |
| 6142 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6143 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6144 | } |
| 6145 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6146 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6147 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6148 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6149 | testType: serverTest, |
| 6150 | name: "Renegotiate-Server-Forbidden", |
| 6151 | config: Config{ |
| 6152 | MaxVersion: VersionTLS12, |
| 6153 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6154 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6155 | shouldFail: true, |
| 6156 | expectedError: ":NO_RENEGOTIATION:", |
| 6157 | expectedLocalError: "remote error: no renegotiation", |
| 6158 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6159 | // The server shouldn't echo the renegotiation extension unless |
| 6160 | // requested by the client. |
| 6161 | testCases = append(testCases, testCase{ |
| 6162 | testType: serverTest, |
| 6163 | name: "Renegotiate-Server-NoExt", |
| 6164 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6165 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6166 | Bugs: ProtocolBugs{ |
| 6167 | NoRenegotiationInfo: true, |
| 6168 | RequireRenegotiationInfo: true, |
| 6169 | }, |
| 6170 | }, |
| 6171 | shouldFail: true, |
| 6172 | expectedLocalError: "renegotiation extension missing", |
| 6173 | }) |
| 6174 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6175 | // the extension. |
| 6176 | testCases = append(testCases, testCase{ |
| 6177 | testType: serverTest, |
| 6178 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6179 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6180 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6181 | Bugs: ProtocolBugs{ |
| 6182 | NoRenegotiationInfo: true, |
| 6183 | SendRenegotiationSCSV: true, |
| 6184 | RequireRenegotiationInfo: true, |
| 6185 | }, |
| 6186 | }, |
| 6187 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6188 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6189 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6190 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6191 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6192 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6193 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6194 | }, |
| 6195 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6196 | renegotiate: 1, |
| 6197 | flags: []string{ |
| 6198 | "-renegotiate-freely", |
| 6199 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6200 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6201 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6202 | }) |
| 6203 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6204 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6205 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6206 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6207 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6208 | Bugs: ProtocolBugs{ |
| 6209 | EmptyRenegotiationInfo: true, |
| 6210 | }, |
| 6211 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6212 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6213 | shouldFail: true, |
| 6214 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6215 | }) |
| 6216 | testCases = append(testCases, testCase{ |
| 6217 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6218 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6219 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6220 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6221 | Bugs: ProtocolBugs{ |
| 6222 | BadRenegotiationInfo: true, |
| 6223 | }, |
| 6224 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6225 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6226 | shouldFail: true, |
| 6227 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6228 | }) |
| 6229 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6230 | name: "Renegotiate-Client-Downgrade", |
| 6231 | renegotiate: 1, |
| 6232 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6233 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6234 | Bugs: ProtocolBugs{ |
| 6235 | NoRenegotiationInfoAfterInitial: true, |
| 6236 | }, |
| 6237 | }, |
| 6238 | flags: []string{"-renegotiate-freely"}, |
| 6239 | shouldFail: true, |
| 6240 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6241 | }) |
| 6242 | testCases = append(testCases, testCase{ |
| 6243 | name: "Renegotiate-Client-Upgrade", |
| 6244 | renegotiate: 1, |
| 6245 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6246 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6247 | Bugs: ProtocolBugs{ |
| 6248 | NoRenegotiationInfoInInitial: true, |
| 6249 | }, |
| 6250 | }, |
| 6251 | flags: []string{"-renegotiate-freely"}, |
| 6252 | shouldFail: true, |
| 6253 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6254 | }) |
| 6255 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6256 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6257 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6258 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6259 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6260 | Bugs: ProtocolBugs{ |
| 6261 | NoRenegotiationInfo: true, |
| 6262 | }, |
| 6263 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6264 | flags: []string{ |
| 6265 | "-renegotiate-freely", |
| 6266 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6267 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6268 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6269 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6270 | |
| 6271 | // Test that the server may switch ciphers on renegotiation without |
| 6272 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6273 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6274 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6275 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6276 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6277 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6278 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6279 | }, |
| 6280 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6281 | flags: []string{ |
| 6282 | "-renegotiate-freely", |
| 6283 | "-expect-total-renegotiations", "1", |
| 6284 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6285 | }) |
| 6286 | testCases = append(testCases, testCase{ |
| 6287 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6288 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6289 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6290 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6291 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6292 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6293 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6294 | flags: []string{ |
| 6295 | "-renegotiate-freely", |
| 6296 | "-expect-total-renegotiations", "1", |
| 6297 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6298 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6299 | |
| 6300 | // Test that the server may not switch versions on renegotiation. |
| 6301 | testCases = append(testCases, testCase{ |
| 6302 | name: "Renegotiate-Client-SwitchVersion", |
| 6303 | config: Config{ |
| 6304 | MaxVersion: VersionTLS12, |
| 6305 | // Pick a cipher which exists at both versions. |
| 6306 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6307 | Bugs: ProtocolBugs{ |
| 6308 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6309 | // Avoid failing early at the record layer. |
| 6310 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6311 | }, |
| 6312 | }, |
| 6313 | renegotiate: 1, |
| 6314 | flags: []string{ |
| 6315 | "-renegotiate-freely", |
| 6316 | "-expect-total-renegotiations", "1", |
| 6317 | }, |
| 6318 | shouldFail: true, |
| 6319 | expectedError: ":WRONG_SSL_VERSION:", |
| 6320 | }) |
| 6321 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6322 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6323 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6324 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6325 | config: Config{ |
| 6326 | MaxVersion: VersionTLS10, |
| 6327 | Bugs: ProtocolBugs{ |
| 6328 | RequireSameRenegoClientVersion: true, |
| 6329 | }, |
| 6330 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6331 | flags: []string{ |
| 6332 | "-renegotiate-freely", |
| 6333 | "-expect-total-renegotiations", "1", |
| 6334 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6335 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6336 | testCases = append(testCases, testCase{ |
| 6337 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6338 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6339 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6340 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6341 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6342 | NextProtos: []string{"foo"}, |
| 6343 | }, |
| 6344 | flags: []string{ |
| 6345 | "-false-start", |
| 6346 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6347 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6348 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6349 | }, |
| 6350 | shimWritesFirst: true, |
| 6351 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6352 | |
| 6353 | // Client-side renegotiation controls. |
| 6354 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6355 | name: "Renegotiate-Client-Forbidden-1", |
| 6356 | config: Config{ |
| 6357 | MaxVersion: VersionTLS12, |
| 6358 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6359 | renegotiate: 1, |
| 6360 | shouldFail: true, |
| 6361 | expectedError: ":NO_RENEGOTIATION:", |
| 6362 | expectedLocalError: "remote error: no renegotiation", |
| 6363 | }) |
| 6364 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6365 | name: "Renegotiate-Client-Once-1", |
| 6366 | config: Config{ |
| 6367 | MaxVersion: VersionTLS12, |
| 6368 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6369 | renegotiate: 1, |
| 6370 | flags: []string{ |
| 6371 | "-renegotiate-once", |
| 6372 | "-expect-total-renegotiations", "1", |
| 6373 | }, |
| 6374 | }) |
| 6375 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6376 | name: "Renegotiate-Client-Freely-1", |
| 6377 | config: Config{ |
| 6378 | MaxVersion: VersionTLS12, |
| 6379 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6380 | renegotiate: 1, |
| 6381 | flags: []string{ |
| 6382 | "-renegotiate-freely", |
| 6383 | "-expect-total-renegotiations", "1", |
| 6384 | }, |
| 6385 | }) |
| 6386 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6387 | name: "Renegotiate-Client-Once-2", |
| 6388 | config: Config{ |
| 6389 | MaxVersion: VersionTLS12, |
| 6390 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6391 | renegotiate: 2, |
| 6392 | flags: []string{"-renegotiate-once"}, |
| 6393 | shouldFail: true, |
| 6394 | expectedError: ":NO_RENEGOTIATION:", |
| 6395 | expectedLocalError: "remote error: no renegotiation", |
| 6396 | }) |
| 6397 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6398 | name: "Renegotiate-Client-Freely-2", |
| 6399 | config: Config{ |
| 6400 | MaxVersion: VersionTLS12, |
| 6401 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6402 | renegotiate: 2, |
| 6403 | flags: []string{ |
| 6404 | "-renegotiate-freely", |
| 6405 | "-expect-total-renegotiations", "2", |
| 6406 | }, |
| 6407 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6408 | testCases = append(testCases, testCase{ |
| 6409 | name: "Renegotiate-Client-NoIgnore", |
| 6410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6411 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6412 | Bugs: ProtocolBugs{ |
| 6413 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6414 | }, |
| 6415 | }, |
| 6416 | shouldFail: true, |
| 6417 | expectedError: ":NO_RENEGOTIATION:", |
| 6418 | }) |
| 6419 | testCases = append(testCases, testCase{ |
| 6420 | name: "Renegotiate-Client-Ignore", |
| 6421 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6422 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6423 | Bugs: ProtocolBugs{ |
| 6424 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6425 | }, |
| 6426 | }, |
| 6427 | flags: []string{ |
| 6428 | "-renegotiate-ignore", |
| 6429 | "-expect-total-renegotiations", "0", |
| 6430 | }, |
| 6431 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6432 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6433 | // Renegotiation is not allowed at SSL 3.0. |
| 6434 | testCases = append(testCases, testCase{ |
| 6435 | name: "Renegotiate-Client-SSL3", |
| 6436 | config: Config{ |
| 6437 | MaxVersion: VersionSSL30, |
| 6438 | }, |
| 6439 | renegotiate: 1, |
| 6440 | flags: []string{ |
| 6441 | "-renegotiate-freely", |
| 6442 | "-expect-total-renegotiations", "1", |
| 6443 | }, |
| 6444 | shouldFail: true, |
| 6445 | expectedError: ":NO_RENEGOTIATION:", |
| 6446 | expectedLocalError: "remote error: no renegotiation", |
| 6447 | }) |
| 6448 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6449 | // Renegotiation is not allowed when there is an unfinished write. |
| 6450 | testCases = append(testCases, testCase{ |
| 6451 | name: "Renegotiate-Client-UnfinishedWrite", |
| 6452 | config: Config{ |
| 6453 | MaxVersion: VersionTLS12, |
| 6454 | }, |
| 6455 | renegotiate: 1, |
| 6456 | flags: []string{ |
| 6457 | "-async", |
| 6458 | "-renegotiate-freely", |
| 6459 | "-read-with-unfinished-write", |
| 6460 | }, |
| 6461 | shouldFail: true, |
| 6462 | expectedError: ":NO_RENEGOTIATION:", |
| 6463 | // We do not successfully send the no_renegotiation alert in |
| 6464 | // this case. https://crbug.com/boringssl/130 |
| 6465 | }) |
| 6466 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6467 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6468 | testCases = append(testCases, testCase{ |
| 6469 | name: "StrayHelloRequest", |
| 6470 | config: Config{ |
| 6471 | MaxVersion: VersionTLS12, |
| 6472 | Bugs: ProtocolBugs{ |
| 6473 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6474 | }, |
| 6475 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6476 | shouldFail: true, |
| 6477 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6478 | }) |
| 6479 | testCases = append(testCases, testCase{ |
| 6480 | name: "StrayHelloRequest-Packed", |
| 6481 | config: Config{ |
| 6482 | MaxVersion: VersionTLS12, |
| 6483 | Bugs: ProtocolBugs{ |
| 6484 | PackHandshakeFlight: true, |
| 6485 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6486 | }, |
| 6487 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6488 | shouldFail: true, |
| 6489 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6490 | }) |
| 6491 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6492 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6493 | // the same record. |
| 6494 | testCases = append(testCases, testCase{ |
| 6495 | name: "Renegotiate-Client-Packed", |
| 6496 | config: Config{ |
| 6497 | MaxVersion: VersionTLS12, |
| 6498 | Bugs: ProtocolBugs{ |
| 6499 | PackHandshakeFlight: true, |
| 6500 | PackHelloRequestWithFinished: true, |
| 6501 | }, |
| 6502 | }, |
| 6503 | renegotiate: 1, |
| 6504 | flags: []string{ |
| 6505 | "-renegotiate-freely", |
| 6506 | "-expect-total-renegotiations", "1", |
| 6507 | }, |
| 6508 | }) |
| 6509 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6510 | // Renegotiation is forbidden in TLS 1.3. |
| 6511 | testCases = append(testCases, testCase{ |
| 6512 | name: "Renegotiate-Client-TLS13", |
| 6513 | config: Config{ |
| 6514 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6515 | Bugs: ProtocolBugs{ |
| 6516 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6517 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6518 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6519 | flags: []string{ |
| 6520 | "-renegotiate-freely", |
| 6521 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6522 | shouldFail: true, |
| 6523 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6524 | }) |
| 6525 | |
| 6526 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6527 | testCases = append(testCases, testCase{ |
| 6528 | name: "StrayHelloRequest-TLS13", |
| 6529 | config: Config{ |
| 6530 | MaxVersion: VersionTLS13, |
| 6531 | Bugs: ProtocolBugs{ |
| 6532 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6533 | }, |
| 6534 | }, |
| 6535 | shouldFail: true, |
| 6536 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6537 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6538 | |
| 6539 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 6540 | // always reads as supporting it, regardless of whether it was |
| 6541 | // negotiated. |
| 6542 | testCases = append(testCases, testCase{ |
| 6543 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 6544 | config: Config{ |
| 6545 | MaxVersion: VersionTLS13, |
| 6546 | Bugs: ProtocolBugs{ |
| 6547 | NoRenegotiationInfo: true, |
| 6548 | }, |
| 6549 | }, |
| 6550 | flags: []string{ |
| 6551 | "-expect-secure-renegotiation", |
| 6552 | }, |
| 6553 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 6554 | |
| 6555 | // Certificates may not change on renegotiation. |
| 6556 | testCases = append(testCases, testCase{ |
| 6557 | name: "Renegotiation-CertificateChange", |
| 6558 | config: Config{ |
| 6559 | MaxVersion: VersionTLS12, |
| 6560 | Certificates: []Certificate{rsaCertificate}, |
| 6561 | Bugs: ProtocolBugs{ |
| 6562 | RenegotiationCertificate: &rsaChainCertificate, |
| 6563 | }, |
| 6564 | }, |
| 6565 | renegotiate: 1, |
| 6566 | flags: []string{"-renegotiate-freely"}, |
| 6567 | shouldFail: true, |
| 6568 | expectedError: ":SERVER_CERT_CHANGED:", |
| 6569 | }) |
| 6570 | testCases = append(testCases, testCase{ |
| 6571 | name: "Renegotiation-CertificateChange-2", |
| 6572 | config: Config{ |
| 6573 | MaxVersion: VersionTLS12, |
| 6574 | Certificates: []Certificate{rsaCertificate}, |
| 6575 | Bugs: ProtocolBugs{ |
| 6576 | RenegotiationCertificate: &rsa1024Certificate, |
| 6577 | }, |
| 6578 | }, |
| 6579 | renegotiate: 1, |
| 6580 | flags: []string{"-renegotiate-freely"}, |
| 6581 | shouldFail: true, |
| 6582 | expectedError: ":SERVER_CERT_CHANGED:", |
| 6583 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 6584 | |
| 6585 | // We do not negotiate ALPN after the initial handshake. This is |
| 6586 | // error-prone and only risks bugs in consumers. |
| 6587 | testCases = append(testCases, testCase{ |
| 6588 | testType: clientTest, |
| 6589 | name: "Renegotiation-ForbidALPN", |
| 6590 | config: Config{ |
| 6591 | MaxVersion: VersionTLS12, |
| 6592 | Bugs: ProtocolBugs{ |
| 6593 | // Forcibly negotiate ALPN on both initial and |
| 6594 | // renegotiation handshakes. The test stack will |
| 6595 | // internally check the client does not offer |
| 6596 | // it. |
| 6597 | SendALPN: "foo", |
| 6598 | }, |
| 6599 | }, |
| 6600 | flags: []string{ |
| 6601 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 6602 | "-expect-alpn", "foo", |
| 6603 | "-renegotiate-freely", |
| 6604 | }, |
| 6605 | renegotiate: 1, |
| 6606 | shouldFail: true, |
| 6607 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6608 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6609 | } |
| 6610 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6611 | func addDTLSReplayTests() { |
| 6612 | // Test that sequence number replays are detected. |
| 6613 | testCases = append(testCases, testCase{ |
| 6614 | protocol: dtls, |
| 6615 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6616 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6617 | replayWrites: true, |
| 6618 | }) |
| 6619 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6620 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6621 | // than the retransmit window. |
| 6622 | testCases = append(testCases, testCase{ |
| 6623 | protocol: dtls, |
| 6624 | name: "DTLS-Replay-LargeGaps", |
| 6625 | config: Config{ |
| 6626 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6627 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6628 | return in * 127 |
| 6629 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6630 | }, |
| 6631 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6632 | messageCount: 200, |
| 6633 | replayWrites: true, |
| 6634 | }) |
| 6635 | |
| 6636 | // Test the incoming sequence number changing non-monotonically. |
| 6637 | testCases = append(testCases, testCase{ |
| 6638 | protocol: dtls, |
| 6639 | name: "DTLS-Replay-NonMonotonic", |
| 6640 | config: Config{ |
| 6641 | Bugs: ProtocolBugs{ |
| 6642 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6643 | return in ^ 31 |
| 6644 | }, |
| 6645 | }, |
| 6646 | }, |
| 6647 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6648 | replayWrites: true, |
| 6649 | }) |
| 6650 | } |
| 6651 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6652 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6653 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6654 | id signatureAlgorithm |
| 6655 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6656 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6657 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6658 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6659 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6660 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6661 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6662 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6663 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6664 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6665 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6666 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6667 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6668 | // Tests for key types prior to TLS 1.2. |
| 6669 | {"RSA", 0, testCertRSA}, |
| 6670 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6671 | } |
| 6672 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6673 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6674 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6675 | |
| 6676 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6677 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6678 | // versions a signing cipher. |
| 6679 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6680 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6681 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6682 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6683 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6684 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 6685 | } |
| 6686 | if *includeDHE { |
| 6687 | signingCiphers = append(signingCiphers, TLS_DHE_RSA_WITH_AES_128_CBC_SHA) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6688 | } |
| 6689 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6690 | var allAlgorithms []signatureAlgorithm |
| 6691 | for _, alg := range testSignatureAlgorithms { |
| 6692 | if alg.id != 0 { |
| 6693 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6694 | } |
| 6695 | } |
| 6696 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6697 | // Make sure each signature algorithm works. Include some fake values in |
| 6698 | // the list and ensure they're ignored. |
| 6699 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6700 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6701 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6702 | continue |
| 6703 | } |
| 6704 | |
| 6705 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6706 | // or remove it in C. |
| 6707 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6708 | continue |
| 6709 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6710 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6711 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6712 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6713 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6714 | shouldSignFail = true |
| 6715 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6716 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6717 | // RSA-PKCS1 does not exist in TLS 1.3. |
| 6718 | if ver.version == VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6719 | shouldSignFail = true |
| 6720 | shouldVerifyFail = true |
| 6721 | } |
| 6722 | |
| 6723 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6724 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6725 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6726 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6727 | |
| 6728 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6729 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6730 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6731 | } |
| 6732 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6733 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6734 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6735 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6736 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6737 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6738 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6739 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6740 | config: Config{ |
| 6741 | MaxVersion: ver.version, |
| 6742 | ClientAuth: RequireAnyClientCert, |
| 6743 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6744 | fakeSigAlg1, |
| 6745 | alg.id, |
| 6746 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6747 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6748 | }, |
| 6749 | flags: []string{ |
| 6750 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6751 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6752 | "-enable-all-curves", |
| 6753 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6754 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6755 | expectedError: signError, |
| 6756 | expectedPeerSignatureAlgorithm: alg.id, |
| 6757 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6758 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6759 | testCases = append(testCases, testCase{ |
| 6760 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6761 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6762 | config: Config{ |
| 6763 | MaxVersion: ver.version, |
| 6764 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6765 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6766 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6767 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6768 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6769 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6770 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6771 | // Some signature algorithms may not be advertised. |
| 6772 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6773 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6774 | }, |
| 6775 | flags: []string{ |
| 6776 | "-require-any-client-certificate", |
| 6777 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6778 | "-enable-all-curves", |
| 6779 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6780 | // Resume the session to assert the peer signature |
| 6781 | // algorithm is reported on both handshakes. |
| 6782 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6783 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6784 | expectedError: verifyError, |
| 6785 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6786 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 6787 | // No signing cipher for SSL 3.0. |
| 6788 | if *includeDHE || ver.version > VersionSSL30 { |
| 6789 | testCases = append(testCases, testCase{ |
| 6790 | testType: serverTest, |
| 6791 | name: "ServerAuth-Sign" + suffix, |
| 6792 | config: Config{ |
| 6793 | MaxVersion: ver.version, |
| 6794 | CipherSuites: signingCiphers, |
| 6795 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6796 | fakeSigAlg1, |
| 6797 | alg.id, |
| 6798 | fakeSigAlg2, |
| 6799 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6800 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 6801 | flags: []string{ |
| 6802 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6803 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6804 | "-enable-all-curves", |
| 6805 | }, |
| 6806 | shouldFail: shouldSignFail, |
| 6807 | expectedError: signError, |
| 6808 | expectedPeerSignatureAlgorithm: alg.id, |
| 6809 | }) |
| 6810 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6811 | |
| 6812 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6813 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6814 | config: Config{ |
| 6815 | MaxVersion: ver.version, |
| 6816 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6817 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6818 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6819 | alg.id, |
| 6820 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6821 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6822 | SkipECDSACurveCheck: shouldVerifyFail, |
| 6823 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 6824 | // Some signature algorithms may not be advertised. |
| 6825 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6826 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6827 | }, |
| 6828 | flags: []string{ |
| 6829 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 6830 | "-enable-all-curves", |
| 6831 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 6832 | // Resume the session to assert the peer signature |
| 6833 | // algorithm is reported on both handshakes. |
| 6834 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6835 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6836 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6837 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6838 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6839 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6840 | testCases = append(testCases, testCase{ |
| 6841 | testType: serverTest, |
| 6842 | name: "ClientAuth-InvalidSignature" + suffix, |
| 6843 | config: Config{ |
| 6844 | MaxVersion: ver.version, |
| 6845 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6846 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6847 | alg.id, |
| 6848 | }, |
| 6849 | Bugs: ProtocolBugs{ |
| 6850 | InvalidSignature: true, |
| 6851 | }, |
| 6852 | }, |
| 6853 | flags: []string{ |
| 6854 | "-require-any-client-certificate", |
| 6855 | "-enable-all-curves", |
| 6856 | }, |
| 6857 | shouldFail: true, |
| 6858 | expectedError: ":BAD_SIGNATURE:", |
| 6859 | }) |
| 6860 | |
| 6861 | testCases = append(testCases, testCase{ |
| 6862 | name: "ServerAuth-InvalidSignature" + suffix, |
| 6863 | config: Config{ |
| 6864 | MaxVersion: ver.version, |
| 6865 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 6866 | CipherSuites: signingCiphers, |
| 6867 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 6868 | alg.id, |
| 6869 | }, |
| 6870 | Bugs: ProtocolBugs{ |
| 6871 | InvalidSignature: true, |
| 6872 | }, |
| 6873 | }, |
| 6874 | flags: []string{"-enable-all-curves"}, |
| 6875 | shouldFail: true, |
| 6876 | expectedError: ":BAD_SIGNATURE:", |
| 6877 | }) |
| 6878 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6879 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6880 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6881 | testCases = append(testCases, testCase{ |
| 6882 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 6883 | config: Config{ |
| 6884 | MaxVersion: ver.version, |
| 6885 | ClientAuth: RequireAnyClientCert, |
| 6886 | VerifySignatureAlgorithms: allAlgorithms, |
| 6887 | }, |
| 6888 | flags: []string{ |
| 6889 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6890 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6891 | "-enable-all-curves", |
| 6892 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6893 | }, |
| 6894 | expectedPeerSignatureAlgorithm: alg.id, |
| 6895 | }) |
| 6896 | |
| 6897 | testCases = append(testCases, testCase{ |
| 6898 | testType: serverTest, |
| 6899 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 6900 | config: Config{ |
| 6901 | MaxVersion: ver.version, |
| 6902 | CipherSuites: signingCiphers, |
| 6903 | VerifySignatureAlgorithms: allAlgorithms, |
| 6904 | }, |
| 6905 | flags: []string{ |
| 6906 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 6907 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 6908 | "-enable-all-curves", |
| 6909 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 6910 | }, |
| 6911 | expectedPeerSignatureAlgorithm: alg.id, |
| 6912 | }) |
| 6913 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6914 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6915 | } |
| 6916 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6917 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6918 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6919 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6920 | config: Config{ |
| 6921 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6922 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6923 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6924 | signatureECDSAWithP521AndSHA512, |
| 6925 | signatureRSAPKCS1WithSHA384, |
| 6926 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6927 | }, |
| 6928 | }, |
| 6929 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 6930 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6931 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6932 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6933 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6934 | }) |
| 6935 | |
| 6936 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6937 | name: "ClientAuth-SignatureType-TLS13", |
| 6938 | config: Config{ |
| 6939 | ClientAuth: RequireAnyClientCert, |
| 6940 | MaxVersion: VersionTLS13, |
| 6941 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6942 | signatureECDSAWithP521AndSHA512, |
| 6943 | signatureRSAPKCS1WithSHA384, |
| 6944 | signatureRSAPSSWithSHA384, |
| 6945 | signatureECDSAWithSHA1, |
| 6946 | }, |
| 6947 | }, |
| 6948 | flags: []string{ |
| 6949 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6950 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6951 | }, |
| 6952 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6953 | }) |
| 6954 | |
| 6955 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6956 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6957 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6958 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6959 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6960 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6961 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6962 | signatureECDSAWithP521AndSHA512, |
| 6963 | signatureRSAPKCS1WithSHA384, |
| 6964 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6965 | }, |
| 6966 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6967 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6968 | }) |
| 6969 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6970 | testCases = append(testCases, testCase{ |
| 6971 | testType: serverTest, |
| 6972 | name: "ServerAuth-SignatureType-TLS13", |
| 6973 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6974 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6975 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6976 | signatureECDSAWithP521AndSHA512, |
| 6977 | signatureRSAPKCS1WithSHA384, |
| 6978 | signatureRSAPSSWithSHA384, |
| 6979 | signatureECDSAWithSHA1, |
| 6980 | }, |
| 6981 | }, |
| 6982 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 6983 | }) |
| 6984 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6985 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6986 | testCases = append(testCases, testCase{ |
| 6987 | testType: serverTest, |
| 6988 | name: "Verify-ClientAuth-SignatureType", |
| 6989 | config: Config{ |
| 6990 | MaxVersion: VersionTLS12, |
| 6991 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6992 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 6993 | signatureRSAPKCS1WithSHA256, |
| 6994 | }, |
| 6995 | Bugs: ProtocolBugs{ |
| 6996 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 6997 | }, |
| 6998 | }, |
| 6999 | flags: []string{ |
| 7000 | "-require-any-client-certificate", |
| 7001 | }, |
| 7002 | shouldFail: true, |
| 7003 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7004 | }) |
| 7005 | |
| 7006 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7007 | testType: serverTest, |
| 7008 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7009 | config: Config{ |
| 7010 | MaxVersion: VersionTLS13, |
| 7011 | Certificates: []Certificate{rsaCertificate}, |
| 7012 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7013 | signatureRSAPSSWithSHA256, |
| 7014 | }, |
| 7015 | Bugs: ProtocolBugs{ |
| 7016 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7017 | }, |
| 7018 | }, |
| 7019 | flags: []string{ |
| 7020 | "-require-any-client-certificate", |
| 7021 | }, |
| 7022 | shouldFail: true, |
| 7023 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7024 | }) |
| 7025 | |
| 7026 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7027 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7028 | config: Config{ |
| 7029 | MaxVersion: VersionTLS12, |
| 7030 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7031 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7032 | signatureRSAPKCS1WithSHA256, |
| 7033 | }, |
| 7034 | Bugs: ProtocolBugs{ |
| 7035 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7036 | }, |
| 7037 | }, |
| 7038 | shouldFail: true, |
| 7039 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7040 | }) |
| 7041 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7042 | testCases = append(testCases, testCase{ |
| 7043 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7044 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7045 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7046 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7047 | signatureRSAPSSWithSHA256, |
| 7048 | }, |
| 7049 | Bugs: ProtocolBugs{ |
| 7050 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7051 | }, |
| 7052 | }, |
| 7053 | shouldFail: true, |
| 7054 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7055 | }) |
| 7056 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7057 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 7058 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7059 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7060 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7061 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7062 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7063 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7064 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7065 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7066 | }, |
| 7067 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7068 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7069 | }, |
| 7070 | }, |
| 7071 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7072 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7073 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7074 | }, |
| 7075 | }) |
| 7076 | |
| 7077 | testCases = append(testCases, testCase{ |
| 7078 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7079 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7080 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7081 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7082 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7083 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7084 | }, |
| 7085 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7086 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7087 | }, |
| 7088 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7089 | flags: []string{ |
| 7090 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7091 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7092 | }, |
| 7093 | }) |
| 7094 | |
| 7095 | testCases = append(testCases, testCase{ |
| 7096 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7097 | config: Config{ |
| 7098 | MaxVersion: VersionTLS12, |
| 7099 | ClientAuth: RequireAnyClientCert, |
| 7100 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7101 | signatureECDSAWithSHA1, |
| 7102 | }, |
| 7103 | Bugs: ProtocolBugs{ |
| 7104 | NoSignatureAlgorithms: true, |
| 7105 | }, |
| 7106 | }, |
| 7107 | flags: []string{ |
| 7108 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7109 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7110 | }, |
| 7111 | }) |
| 7112 | |
| 7113 | testCases = append(testCases, testCase{ |
| 7114 | testType: serverTest, |
| 7115 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 7116 | config: Config{ |
| 7117 | MaxVersion: VersionTLS12, |
| 7118 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7119 | signatureECDSAWithSHA1, |
| 7120 | }, |
| 7121 | Bugs: ProtocolBugs{ |
| 7122 | NoSignatureAlgorithms: true, |
| 7123 | }, |
| 7124 | }, |
| 7125 | flags: []string{ |
| 7126 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7127 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7128 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7129 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7130 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7131 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7132 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7133 | config: Config{ |
| 7134 | MaxVersion: VersionTLS13, |
| 7135 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7136 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7137 | signatureRSAPKCS1WithSHA1, |
| 7138 | }, |
| 7139 | Bugs: ProtocolBugs{ |
| 7140 | NoSignatureAlgorithms: true, |
| 7141 | }, |
| 7142 | }, |
| 7143 | flags: []string{ |
| 7144 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7145 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7146 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 7147 | shouldFail: true, |
| 7148 | // An empty CertificateRequest signature algorithm list is a |
| 7149 | // syntax error in TLS 1.3. |
| 7150 | expectedError: ":DECODE_ERROR:", |
| 7151 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7152 | }) |
| 7153 | |
| 7154 | testCases = append(testCases, testCase{ |
| 7155 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7156 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7157 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7158 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7159 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7160 | signatureRSAPKCS1WithSHA1, |
| 7161 | }, |
| 7162 | Bugs: ProtocolBugs{ |
| 7163 | NoSignatureAlgorithms: true, |
| 7164 | }, |
| 7165 | }, |
| 7166 | shouldFail: true, |
| 7167 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7168 | }) |
| 7169 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7170 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 7171 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7172 | testCases = append(testCases, testCase{ |
| 7173 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7174 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7175 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7176 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7177 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7178 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7179 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7180 | }, |
| 7181 | Bugs: ProtocolBugs{ |
| 7182 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7183 | }, |
| 7184 | }, |
| 7185 | flags: []string{"-require-any-client-certificate"}, |
| 7186 | shouldFail: true, |
| 7187 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7188 | }) |
| 7189 | |
| 7190 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7191 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7192 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7193 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7194 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7195 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7196 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7197 | }, |
| 7198 | Bugs: ProtocolBugs{ |
| 7199 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7200 | }, |
| 7201 | }, |
| 7202 | shouldFail: true, |
| 7203 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7204 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7205 | testCases = append(testCases, testCase{ |
| 7206 | testType: serverTest, |
| 7207 | name: "ClientAuth-Enforced-TLS13", |
| 7208 | config: Config{ |
| 7209 | MaxVersion: VersionTLS13, |
| 7210 | Certificates: []Certificate{rsaCertificate}, |
| 7211 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7212 | signatureRSAPKCS1WithMD5, |
| 7213 | }, |
| 7214 | Bugs: ProtocolBugs{ |
| 7215 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7216 | IgnoreSignatureVersionChecks: true, |
| 7217 | }, |
| 7218 | }, |
| 7219 | flags: []string{"-require-any-client-certificate"}, |
| 7220 | shouldFail: true, |
| 7221 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7222 | }) |
| 7223 | |
| 7224 | testCases = append(testCases, testCase{ |
| 7225 | name: "ServerAuth-Enforced-TLS13", |
| 7226 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7227 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7228 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7229 | signatureRSAPKCS1WithMD5, |
| 7230 | }, |
| 7231 | Bugs: ProtocolBugs{ |
| 7232 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7233 | IgnoreSignatureVersionChecks: true, |
| 7234 | }, |
| 7235 | }, |
| 7236 | shouldFail: true, |
| 7237 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7238 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7239 | |
| 7240 | // Test that the agreed upon digest respects the client preferences and |
| 7241 | // the server digests. |
| 7242 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7243 | name: "NoCommonAlgorithms-Digests", |
| 7244 | config: Config{ |
| 7245 | MaxVersion: VersionTLS12, |
| 7246 | ClientAuth: RequireAnyClientCert, |
| 7247 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7248 | signatureRSAPKCS1WithSHA512, |
| 7249 | signatureRSAPKCS1WithSHA1, |
| 7250 | }, |
| 7251 | }, |
| 7252 | flags: []string{ |
| 7253 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7254 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7255 | "-digest-prefs", "SHA256", |
| 7256 | }, |
| 7257 | shouldFail: true, |
| 7258 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7259 | }) |
| 7260 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7261 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7262 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7263 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7264 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7265 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7266 | signatureRSAPKCS1WithSHA512, |
| 7267 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7268 | }, |
| 7269 | }, |
| 7270 | flags: []string{ |
| 7271 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7272 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7273 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7274 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7275 | shouldFail: true, |
| 7276 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7277 | }) |
| 7278 | testCases = append(testCases, testCase{ |
| 7279 | name: "NoCommonAlgorithms-TLS13", |
| 7280 | config: Config{ |
| 7281 | MaxVersion: VersionTLS13, |
| 7282 | ClientAuth: RequireAnyClientCert, |
| 7283 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7284 | signatureRSAPSSWithSHA512, |
| 7285 | signatureRSAPSSWithSHA384, |
| 7286 | }, |
| 7287 | }, |
| 7288 | flags: []string{ |
| 7289 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7290 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7291 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7292 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7293 | shouldFail: true, |
| 7294 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7295 | }) |
| 7296 | testCases = append(testCases, testCase{ |
| 7297 | name: "Agree-Digest-SHA256", |
| 7298 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7299 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7300 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7301 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7302 | signatureRSAPKCS1WithSHA1, |
| 7303 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7304 | }, |
| 7305 | }, |
| 7306 | flags: []string{ |
| 7307 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7308 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7309 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7310 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7311 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7312 | }) |
| 7313 | testCases = append(testCases, testCase{ |
| 7314 | name: "Agree-Digest-SHA1", |
| 7315 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7316 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7317 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7318 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7319 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7320 | }, |
| 7321 | }, |
| 7322 | flags: []string{ |
| 7323 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7324 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7325 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7326 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7327 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7328 | }) |
| 7329 | testCases = append(testCases, testCase{ |
| 7330 | name: "Agree-Digest-Default", |
| 7331 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7332 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7333 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7334 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7335 | signatureRSAPKCS1WithSHA256, |
| 7336 | signatureECDSAWithP256AndSHA256, |
| 7337 | signatureRSAPKCS1WithSHA1, |
| 7338 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7339 | }, |
| 7340 | }, |
| 7341 | flags: []string{ |
| 7342 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7343 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7344 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7345 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7346 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7347 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7348 | // Test that the signing preference list may include extra algorithms |
| 7349 | // without negotiation problems. |
| 7350 | testCases = append(testCases, testCase{ |
| 7351 | testType: serverTest, |
| 7352 | name: "FilterExtraAlgorithms", |
| 7353 | config: Config{ |
| 7354 | MaxVersion: VersionTLS12, |
| 7355 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7356 | signatureRSAPKCS1WithSHA256, |
| 7357 | }, |
| 7358 | }, |
| 7359 | flags: []string{ |
| 7360 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7361 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7362 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7363 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7364 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7365 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7366 | }, |
| 7367 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7368 | }) |
| 7369 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7370 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7371 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7372 | testCases = append(testCases, testCase{ |
| 7373 | name: "CheckLeafCurve", |
| 7374 | config: Config{ |
| 7375 | MaxVersion: VersionTLS12, |
| 7376 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7377 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7378 | }, |
| 7379 | flags: []string{"-p384-only"}, |
| 7380 | shouldFail: true, |
| 7381 | expectedError: ":BAD_ECC_CERT:", |
| 7382 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7383 | |
| 7384 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7385 | testCases = append(testCases, testCase{ |
| 7386 | name: "CheckLeafCurve-TLS13", |
| 7387 | config: Config{ |
| 7388 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7389 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7390 | }, |
| 7391 | flags: []string{"-p384-only"}, |
| 7392 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7393 | |
| 7394 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7395 | testCases = append(testCases, testCase{ |
| 7396 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7397 | config: Config{ |
| 7398 | MaxVersion: VersionTLS12, |
| 7399 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7400 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7401 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7402 | signatureECDSAWithP384AndSHA384, |
| 7403 | }, |
| 7404 | }, |
| 7405 | }) |
| 7406 | |
| 7407 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7408 | testCases = append(testCases, testCase{ |
| 7409 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7410 | config: Config{ |
| 7411 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7412 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7413 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7414 | signatureECDSAWithP384AndSHA384, |
| 7415 | }, |
| 7416 | Bugs: ProtocolBugs{ |
| 7417 | SkipECDSACurveCheck: true, |
| 7418 | }, |
| 7419 | }, |
| 7420 | shouldFail: true, |
| 7421 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7422 | }) |
| 7423 | |
| 7424 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7425 | // account. |
| 7426 | testCases = append(testCases, testCase{ |
| 7427 | testType: serverTest, |
| 7428 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7429 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7430 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7431 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7432 | signatureECDSAWithP384AndSHA384, |
| 7433 | signatureECDSAWithP256AndSHA256, |
| 7434 | }, |
| 7435 | }, |
| 7436 | flags: []string{ |
| 7437 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7438 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7439 | }, |
| 7440 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7441 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7442 | |
| 7443 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7444 | // server does not attempt to sign in that case. |
| 7445 | testCases = append(testCases, testCase{ |
| 7446 | testType: serverTest, |
| 7447 | name: "RSA-PSS-Large", |
| 7448 | config: Config{ |
| 7449 | MaxVersion: VersionTLS13, |
| 7450 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7451 | signatureRSAPSSWithSHA512, |
| 7452 | }, |
| 7453 | }, |
| 7454 | flags: []string{ |
| 7455 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7456 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7457 | }, |
| 7458 | shouldFail: true, |
| 7459 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7460 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7461 | |
| 7462 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7463 | testCases = append(testCases, testCase{ |
| 7464 | testType: clientTest, |
| 7465 | name: "RSA-PSS-Default-Verify", |
| 7466 | config: Config{ |
| 7467 | MaxVersion: VersionTLS12, |
| 7468 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7469 | signatureRSAPSSWithSHA256, |
| 7470 | }, |
| 7471 | }, |
| 7472 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7473 | }) |
| 7474 | |
| 7475 | testCases = append(testCases, testCase{ |
| 7476 | testType: serverTest, |
| 7477 | name: "RSA-PSS-Default-Sign", |
| 7478 | config: Config{ |
| 7479 | MaxVersion: VersionTLS12, |
| 7480 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7481 | signatureRSAPSSWithSHA256, |
| 7482 | }, |
| 7483 | }, |
| 7484 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7485 | }) |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 7486 | |
| 7487 | // A server certificate with a P-224 key will only work up to TLS 1.2 |
| 7488 | // and we only test it with BoringSSL acting as a server because that's |
| 7489 | // all Alphabet requires with it. |
| 7490 | testCases = append(testCases, testCase{ |
| 7491 | testType: serverTest, |
| 7492 | name: "P224-Server", |
| 7493 | config: Config{ |
| 7494 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7495 | // TLS 1.2 does not require that the curve |
| 7496 | // match the hash, thus P-256 with SHA-256 is |
| 7497 | // the same signature algorithm value as P-224 |
| 7498 | // with SHA-256. |
| 7499 | signatureECDSAWithP256AndSHA256, |
| 7500 | }, |
| 7501 | // P-256 must be offered as well because ECDHE requires |
| 7502 | // it. |
| 7503 | CurvePreferences: []CurveID{CurveP224, CurveP256}, |
| 7504 | }, |
| 7505 | flags: []string{ |
| 7506 | "-max-version", strconv.Itoa(VersionTLS12), |
| 7507 | "-cert-file", path.Join(*resourceDir, ecdsaP224CertificateFile), |
| 7508 | "-key-file", path.Join(*resourceDir, ecdsaP224KeyFile), |
| 7509 | }, |
| 7510 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7511 | } |
| 7512 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7513 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7514 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7515 | var timeouts = []time.Duration{ |
| 7516 | 1 * time.Second, |
| 7517 | 2 * time.Second, |
| 7518 | 4 * time.Second, |
| 7519 | 8 * time.Second, |
| 7520 | 16 * time.Second, |
| 7521 | 32 * time.Second, |
| 7522 | 60 * time.Second, |
| 7523 | 60 * time.Second, |
| 7524 | 60 * time.Second, |
| 7525 | 60 * time.Second, |
| 7526 | 60 * time.Second, |
| 7527 | 60 * time.Second, |
| 7528 | 60 * time.Second, |
| 7529 | } |
| 7530 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7531 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7532 | // initial timeout duration was set to 250ms. |
| 7533 | var shortTimeouts = []time.Duration{ |
| 7534 | 250 * time.Millisecond, |
| 7535 | 500 * time.Millisecond, |
| 7536 | 1 * time.Second, |
| 7537 | 2 * time.Second, |
| 7538 | 4 * time.Second, |
| 7539 | 8 * time.Second, |
| 7540 | 16 * time.Second, |
| 7541 | 32 * time.Second, |
| 7542 | 60 * time.Second, |
| 7543 | 60 * time.Second, |
| 7544 | 60 * time.Second, |
| 7545 | 60 * time.Second, |
| 7546 | 60 * time.Second, |
| 7547 | } |
| 7548 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7549 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7550 | // These tests work by coordinating some behavior on both the shim and |
| 7551 | // the runner. |
| 7552 | // |
| 7553 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7554 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7555 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7556 | // timeout in the shim and acts as a synchronization point to help the |
| 7557 | // runner bracket each handshake flight. |
| 7558 | // |
| 7559 | // We assume the shim does not read from the channel eagerly. It must |
| 7560 | // first wait until it has sent flight N and is ready to receive |
| 7561 | // handshake flight N+1. At this point, it will process the timeout |
| 7562 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7563 | // as if the shim was idle for the specified amount of time. |
| 7564 | // |
| 7565 | // The runner then drops all packets received before the ACK and |
| 7566 | // continues waiting for flight N. This ordering results in one attempt |
| 7567 | // at sending flight N to be dropped. For the test to complete, the |
| 7568 | // shim must send flight N again, testing that the shim implements DTLS |
| 7569 | // retransmit on a timeout. |
| 7570 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7571 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7572 | // likely be more epochs to cross and the final message's retransmit may |
| 7573 | // be more complex. |
| 7574 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7575 | // Test that this is indeed the timeout schedule. Stress all |
| 7576 | // four patterns of handshake. |
| 7577 | for i := 1; i < len(timeouts); i++ { |
| 7578 | number := strconv.Itoa(i) |
| 7579 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7580 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7581 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7582 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7583 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7584 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7585 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7586 | }, |
| 7587 | }, |
| 7588 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7589 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7590 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7591 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7592 | protocol: dtls, |
| 7593 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7594 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7595 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7596 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7597 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7598 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7599 | }, |
| 7600 | }, |
| 7601 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7602 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7603 | }) |
| 7604 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7605 | |
| 7606 | // Test that exceeding the timeout schedule hits a read |
| 7607 | // timeout. |
| 7608 | testCases = append(testCases, testCase{ |
| 7609 | protocol: dtls, |
| 7610 | name: "DTLS-Retransmit-Timeout", |
| 7611 | config: Config{ |
| 7612 | MaxVersion: VersionTLS12, |
| 7613 | Bugs: ProtocolBugs{ |
| 7614 | TimeoutSchedule: timeouts, |
| 7615 | }, |
| 7616 | }, |
| 7617 | resumeSession: true, |
| 7618 | flags: []string{"-async"}, |
| 7619 | shouldFail: true, |
| 7620 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 7621 | }) |
| 7622 | |
| 7623 | // Test that timeout handling has a fudge factor, due to API |
| 7624 | // problems. |
| 7625 | testCases = append(testCases, testCase{ |
| 7626 | protocol: dtls, |
| 7627 | name: "DTLS-Retransmit-Fudge", |
| 7628 | config: Config{ |
| 7629 | MaxVersion: VersionTLS12, |
| 7630 | Bugs: ProtocolBugs{ |
| 7631 | TimeoutSchedule: []time.Duration{ |
| 7632 | timeouts[0] - 10*time.Millisecond, |
| 7633 | }, |
| 7634 | }, |
| 7635 | }, |
| 7636 | resumeSession: true, |
| 7637 | flags: []string{"-async"}, |
| 7638 | }) |
| 7639 | |
| 7640 | // Test that the final Finished retransmitting isn't |
| 7641 | // duplicated if the peer badly fragments everything. |
| 7642 | testCases = append(testCases, testCase{ |
| 7643 | testType: serverTest, |
| 7644 | protocol: dtls, |
| 7645 | name: "DTLS-Retransmit-Fragmented", |
| 7646 | config: Config{ |
| 7647 | MaxVersion: VersionTLS12, |
| 7648 | Bugs: ProtocolBugs{ |
| 7649 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 7650 | MaxHandshakeRecordLength: 2, |
| 7651 | }, |
| 7652 | }, |
| 7653 | flags: []string{"-async"}, |
| 7654 | }) |
| 7655 | |
| 7656 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 7657 | testCases = append(testCases, testCase{ |
| 7658 | protocol: dtls, |
| 7659 | name: "DTLS-Retransmit-Short-Client", |
| 7660 | config: Config{ |
| 7661 | MaxVersion: VersionTLS12, |
| 7662 | Bugs: ProtocolBugs{ |
| 7663 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7664 | }, |
| 7665 | }, |
| 7666 | resumeSession: true, |
| 7667 | flags: []string{ |
| 7668 | "-async", |
| 7669 | "-initial-timeout-duration-ms", "250", |
| 7670 | }, |
| 7671 | }) |
| 7672 | testCases = append(testCases, testCase{ |
| 7673 | protocol: dtls, |
| 7674 | testType: serverTest, |
| 7675 | name: "DTLS-Retransmit-Short-Server", |
| 7676 | config: Config{ |
| 7677 | MaxVersion: VersionTLS12, |
| 7678 | Bugs: ProtocolBugs{ |
| 7679 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 7680 | }, |
| 7681 | }, |
| 7682 | resumeSession: true, |
| 7683 | flags: []string{ |
| 7684 | "-async", |
| 7685 | "-initial-timeout-duration-ms", "250", |
| 7686 | }, |
| 7687 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7688 | } |
| 7689 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7690 | func addExportKeyingMaterialTests() { |
| 7691 | for _, vers := range tlsVersions { |
| 7692 | if vers.version == VersionSSL30 { |
| 7693 | continue |
| 7694 | } |
| 7695 | testCases = append(testCases, testCase{ |
| 7696 | name: "ExportKeyingMaterial-" + vers.name, |
| 7697 | config: Config{ |
| 7698 | MaxVersion: vers.version, |
| 7699 | }, |
| 7700 | exportKeyingMaterial: 1024, |
| 7701 | exportLabel: "label", |
| 7702 | exportContext: "context", |
| 7703 | useExportContext: true, |
| 7704 | }) |
| 7705 | testCases = append(testCases, testCase{ |
| 7706 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 7707 | config: Config{ |
| 7708 | MaxVersion: vers.version, |
| 7709 | }, |
| 7710 | exportKeyingMaterial: 1024, |
| 7711 | }) |
| 7712 | testCases = append(testCases, testCase{ |
| 7713 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 7714 | config: Config{ |
| 7715 | MaxVersion: vers.version, |
| 7716 | }, |
| 7717 | exportKeyingMaterial: 1024, |
| 7718 | useExportContext: true, |
| 7719 | }) |
| 7720 | testCases = append(testCases, testCase{ |
| 7721 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 7722 | config: Config{ |
| 7723 | MaxVersion: vers.version, |
| 7724 | }, |
| 7725 | exportKeyingMaterial: 1, |
| 7726 | exportLabel: "label", |
| 7727 | exportContext: "context", |
| 7728 | useExportContext: true, |
| 7729 | }) |
| 7730 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7731 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7732 | testCases = append(testCases, testCase{ |
| 7733 | name: "ExportKeyingMaterial-SSL3", |
| 7734 | config: Config{ |
| 7735 | MaxVersion: VersionSSL30, |
| 7736 | }, |
| 7737 | exportKeyingMaterial: 1024, |
| 7738 | exportLabel: "label", |
| 7739 | exportContext: "context", |
| 7740 | useExportContext: true, |
| 7741 | shouldFail: true, |
| 7742 | expectedError: "failed to export keying material", |
| 7743 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 7744 | |
| 7745 | // Exporters work during a False Start. |
| 7746 | testCases = append(testCases, testCase{ |
| 7747 | name: "ExportKeyingMaterial-FalseStart", |
| 7748 | config: Config{ |
| 7749 | MaxVersion: VersionTLS12, |
| 7750 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7751 | NextProtos: []string{"foo"}, |
| 7752 | Bugs: ProtocolBugs{ |
| 7753 | ExpectFalseStart: true, |
| 7754 | }, |
| 7755 | }, |
| 7756 | flags: []string{ |
| 7757 | "-false-start", |
| 7758 | "-advertise-alpn", "\x03foo", |
| 7759 | }, |
| 7760 | shimWritesFirst: true, |
| 7761 | exportKeyingMaterial: 1024, |
| 7762 | exportLabel: "label", |
| 7763 | exportContext: "context", |
| 7764 | useExportContext: true, |
| 7765 | }) |
| 7766 | |
| 7767 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 7768 | // triggering the exporter after every SSL_read call and configuring the |
| 7769 | // shim to run asynchronously. |
| 7770 | testCases = append(testCases, testCase{ |
| 7771 | name: "ExportKeyingMaterial-Renegotiate", |
| 7772 | config: Config{ |
| 7773 | MaxVersion: VersionTLS12, |
| 7774 | }, |
| 7775 | renegotiate: 1, |
| 7776 | flags: []string{ |
| 7777 | "-async", |
| 7778 | "-use-exporter-between-reads", |
| 7779 | "-renegotiate-freely", |
| 7780 | "-expect-total-renegotiations", "1", |
| 7781 | }, |
| 7782 | shouldFail: true, |
| 7783 | expectedError: "failed to export keying material", |
| 7784 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 7785 | } |
| 7786 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7787 | func addTLSUniqueTests() { |
| 7788 | for _, isClient := range []bool{false, true} { |
| 7789 | for _, isResumption := range []bool{false, true} { |
| 7790 | for _, hasEMS := range []bool{false, true} { |
| 7791 | var suffix string |
| 7792 | if isResumption { |
| 7793 | suffix = "Resume-" |
| 7794 | } else { |
| 7795 | suffix = "Full-" |
| 7796 | } |
| 7797 | |
| 7798 | if hasEMS { |
| 7799 | suffix += "EMS-" |
| 7800 | } else { |
| 7801 | suffix += "NoEMS-" |
| 7802 | } |
| 7803 | |
| 7804 | if isClient { |
| 7805 | suffix += "Client" |
| 7806 | } else { |
| 7807 | suffix += "Server" |
| 7808 | } |
| 7809 | |
| 7810 | test := testCase{ |
| 7811 | name: "TLSUnique-" + suffix, |
| 7812 | testTLSUnique: true, |
| 7813 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7814 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7815 | Bugs: ProtocolBugs{ |
| 7816 | NoExtendedMasterSecret: !hasEMS, |
| 7817 | }, |
| 7818 | }, |
| 7819 | } |
| 7820 | |
| 7821 | if isResumption { |
| 7822 | test.resumeSession = true |
| 7823 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7824 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 7825 | Bugs: ProtocolBugs{ |
| 7826 | NoExtendedMasterSecret: !hasEMS, |
| 7827 | }, |
| 7828 | } |
| 7829 | } |
| 7830 | |
| 7831 | if isResumption && !hasEMS { |
| 7832 | test.shouldFail = true |
| 7833 | test.expectedError = "failed to get tls-unique" |
| 7834 | } |
| 7835 | |
| 7836 | testCases = append(testCases, test) |
| 7837 | } |
| 7838 | } |
| 7839 | } |
| 7840 | } |
| 7841 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7842 | func addCustomExtensionTests() { |
| 7843 | expectedContents := "custom extension" |
| 7844 | emptyString := "" |
| 7845 | |
| 7846 | for _, isClient := range []bool{false, true} { |
| 7847 | suffix := "Server" |
| 7848 | flag := "-enable-server-custom-extension" |
| 7849 | testType := serverTest |
| 7850 | if isClient { |
| 7851 | suffix = "Client" |
| 7852 | flag = "-enable-client-custom-extension" |
| 7853 | testType = clientTest |
| 7854 | } |
| 7855 | |
| 7856 | testCases = append(testCases, testCase{ |
| 7857 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7858 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7859 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7860 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7861 | Bugs: ProtocolBugs{ |
| 7862 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7863 | ExpectedCustomExtension: &expectedContents, |
| 7864 | }, |
| 7865 | }, |
| 7866 | flags: []string{flag}, |
| 7867 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7868 | testCases = append(testCases, testCase{ |
| 7869 | testType: testType, |
| 7870 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 7871 | config: Config{ |
| 7872 | MaxVersion: VersionTLS13, |
| 7873 | Bugs: ProtocolBugs{ |
| 7874 | CustomExtension: expectedContents, |
| 7875 | ExpectedCustomExtension: &expectedContents, |
| 7876 | }, |
| 7877 | }, |
| 7878 | flags: []string{flag}, |
| 7879 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7880 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame^] | 7881 | // 0-RTT is not currently supported with Custom Extensions. |
| 7882 | testCases = append(testCases, testCase{ |
| 7883 | testType: testType, |
| 7884 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 7885 | config: Config{ |
| 7886 | MaxVersion: VersionTLS13, |
| 7887 | Bugs: ProtocolBugs{ |
| 7888 | CustomExtension: expectedContents, |
| 7889 | ExpectedCustomExtension: &expectedContents, |
| 7890 | }, |
| 7891 | }, |
| 7892 | shouldFail: true, |
| 7893 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7894 | flags: []string{flag, "-enable-early-data"}, |
| 7895 | }) |
| 7896 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7897 | // If the parse callback fails, the handshake should also fail. |
| 7898 | testCases = append(testCases, testCase{ |
| 7899 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7900 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7901 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7902 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7903 | Bugs: ProtocolBugs{ |
| 7904 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7905 | ExpectedCustomExtension: &expectedContents, |
| 7906 | }, |
| 7907 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7908 | flags: []string{flag}, |
| 7909 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7910 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7911 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7912 | testCases = append(testCases, testCase{ |
| 7913 | testType: testType, |
| 7914 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 7915 | config: Config{ |
| 7916 | MaxVersion: VersionTLS13, |
| 7917 | Bugs: ProtocolBugs{ |
| 7918 | CustomExtension: expectedContents + "foo", |
| 7919 | ExpectedCustomExtension: &expectedContents, |
| 7920 | }, |
| 7921 | }, |
| 7922 | flags: []string{flag}, |
| 7923 | shouldFail: true, |
| 7924 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7925 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7926 | |
| 7927 | // If the add callback fails, the handshake should also fail. |
| 7928 | testCases = append(testCases, testCase{ |
| 7929 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7930 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7931 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7932 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7933 | Bugs: ProtocolBugs{ |
| 7934 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7935 | ExpectedCustomExtension: &expectedContents, |
| 7936 | }, |
| 7937 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7938 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7939 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7940 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7941 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7942 | testCases = append(testCases, testCase{ |
| 7943 | testType: testType, |
| 7944 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 7945 | config: Config{ |
| 7946 | MaxVersion: VersionTLS13, |
| 7947 | Bugs: ProtocolBugs{ |
| 7948 | CustomExtension: expectedContents, |
| 7949 | ExpectedCustomExtension: &expectedContents, |
| 7950 | }, |
| 7951 | }, |
| 7952 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 7953 | shouldFail: true, |
| 7954 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 7955 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7956 | |
| 7957 | // If the add callback returns zero, no extension should be |
| 7958 | // added. |
| 7959 | skipCustomExtension := expectedContents |
| 7960 | if isClient { |
| 7961 | // For the case where the client skips sending the |
| 7962 | // custom extension, the server must not “echo” it. |
| 7963 | skipCustomExtension = "" |
| 7964 | } |
| 7965 | testCases = append(testCases, testCase{ |
| 7966 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7967 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7968 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7969 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7970 | Bugs: ProtocolBugs{ |
| 7971 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7972 | ExpectedCustomExtension: &emptyString, |
| 7973 | }, |
| 7974 | }, |
| 7975 | flags: []string{flag, "-custom-extension-skip"}, |
| 7976 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7977 | testCases = append(testCases, testCase{ |
| 7978 | testType: testType, |
| 7979 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 7980 | config: Config{ |
| 7981 | MaxVersion: VersionTLS13, |
| 7982 | Bugs: ProtocolBugs{ |
| 7983 | CustomExtension: skipCustomExtension, |
| 7984 | ExpectedCustomExtension: &emptyString, |
| 7985 | }, |
| 7986 | }, |
| 7987 | flags: []string{flag, "-custom-extension-skip"}, |
| 7988 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7989 | } |
| 7990 | |
| 7991 | // The custom extension add callback should not be called if the client |
| 7992 | // doesn't send the extension. |
| 7993 | testCases = append(testCases, testCase{ |
| 7994 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7995 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7996 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7997 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 7998 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 7999 | ExpectedCustomExtension: &emptyString, |
| 8000 | }, |
| 8001 | }, |
| 8002 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 8003 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8004 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8005 | testCases = append(testCases, testCase{ |
| 8006 | testType: serverTest, |
| 8007 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 8008 | config: Config{ |
| 8009 | MaxVersion: VersionTLS13, |
| 8010 | Bugs: ProtocolBugs{ |
| 8011 | ExpectedCustomExtension: &emptyString, |
| 8012 | }, |
| 8013 | }, |
| 8014 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 8015 | }) |
| 8016 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8017 | // Test an unknown extension from the server. |
| 8018 | testCases = append(testCases, testCase{ |
| 8019 | testType: clientTest, |
| 8020 | name: "UnknownExtension-Client", |
| 8021 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8022 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8023 | Bugs: ProtocolBugs{ |
| 8024 | CustomExtension: expectedContents, |
| 8025 | }, |
| 8026 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8027 | shouldFail: true, |
| 8028 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8029 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8030 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8031 | testCases = append(testCases, testCase{ |
| 8032 | testType: clientTest, |
| 8033 | name: "UnknownExtension-Client-TLS13", |
| 8034 | config: Config{ |
| 8035 | MaxVersion: VersionTLS13, |
| 8036 | Bugs: ProtocolBugs{ |
| 8037 | CustomExtension: expectedContents, |
| 8038 | }, |
| 8039 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8040 | shouldFail: true, |
| 8041 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8042 | expectedLocalError: "remote error: unsupported extension", |
| 8043 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 8044 | testCases = append(testCases, testCase{ |
| 8045 | testType: clientTest, |
| 8046 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 8047 | config: Config{ |
| 8048 | MaxVersion: VersionTLS13, |
| 8049 | Bugs: ProtocolBugs{ |
| 8050 | CustomUnencryptedExtension: expectedContents, |
| 8051 | }, |
| 8052 | }, |
| 8053 | shouldFail: true, |
| 8054 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8055 | // The shim must send an alert, but alerts at this point do not |
| 8056 | // get successfully decrypted by the runner. |
| 8057 | expectedLocalError: "local error: bad record MAC", |
| 8058 | }) |
| 8059 | testCases = append(testCases, testCase{ |
| 8060 | testType: clientTest, |
| 8061 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 8062 | config: Config{ |
| 8063 | MaxVersion: VersionTLS13, |
| 8064 | Bugs: ProtocolBugs{ |
| 8065 | SendUnencryptedALPN: "foo", |
| 8066 | }, |
| 8067 | }, |
| 8068 | flags: []string{ |
| 8069 | "-advertise-alpn", "\x03foo\x03bar", |
| 8070 | }, |
| 8071 | shouldFail: true, |
| 8072 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8073 | // The shim must send an alert, but alerts at this point do not |
| 8074 | // get successfully decrypted by the runner. |
| 8075 | expectedLocalError: "local error: bad record MAC", |
| 8076 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8077 | |
| 8078 | // Test a known but unoffered extension from the server. |
| 8079 | testCases = append(testCases, testCase{ |
| 8080 | testType: clientTest, |
| 8081 | name: "UnofferedExtension-Client", |
| 8082 | config: Config{ |
| 8083 | MaxVersion: VersionTLS12, |
| 8084 | Bugs: ProtocolBugs{ |
| 8085 | SendALPN: "alpn", |
| 8086 | }, |
| 8087 | }, |
| 8088 | shouldFail: true, |
| 8089 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8090 | expectedLocalError: "remote error: unsupported extension", |
| 8091 | }) |
| 8092 | testCases = append(testCases, testCase{ |
| 8093 | testType: clientTest, |
| 8094 | name: "UnofferedExtension-Client-TLS13", |
| 8095 | config: Config{ |
| 8096 | MaxVersion: VersionTLS13, |
| 8097 | Bugs: ProtocolBugs{ |
| 8098 | SendALPN: "alpn", |
| 8099 | }, |
| 8100 | }, |
| 8101 | shouldFail: true, |
| 8102 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8103 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8104 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8105 | } |
| 8106 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8107 | func addRSAClientKeyExchangeTests() { |
| 8108 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 8109 | testCases = append(testCases, testCase{ |
| 8110 | testType: serverTest, |
| 8111 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 8112 | config: Config{ |
| 8113 | // Ensure the ClientHello version and final |
| 8114 | // version are different, to detect if the |
| 8115 | // server uses the wrong one. |
| 8116 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 8117 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8118 | Bugs: ProtocolBugs{ |
| 8119 | BadRSAClientKeyExchange: bad, |
| 8120 | }, |
| 8121 | }, |
| 8122 | shouldFail: true, |
| 8123 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8124 | }) |
| 8125 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 8126 | |
| 8127 | // The server must compare whatever was in ClientHello.version for the |
| 8128 | // RSA premaster. |
| 8129 | testCases = append(testCases, testCase{ |
| 8130 | testType: serverTest, |
| 8131 | name: "SendClientVersion-RSA", |
| 8132 | config: Config{ |
| 8133 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 8134 | Bugs: ProtocolBugs{ |
| 8135 | SendClientVersion: 0x1234, |
| 8136 | }, |
| 8137 | }, |
| 8138 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8139 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8140 | } |
| 8141 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8142 | var testCurves = []struct { |
| 8143 | name string |
| 8144 | id CurveID |
| 8145 | }{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8146 | {"P-256", CurveP256}, |
| 8147 | {"P-384", CurveP384}, |
| 8148 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 8149 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8150 | } |
| 8151 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8152 | const bogusCurve = 0x1234 |
| 8153 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8154 | func addCurveTests() { |
| 8155 | for _, curve := range testCurves { |
| 8156 | testCases = append(testCases, testCase{ |
| 8157 | name: "CurveTest-Client-" + curve.name, |
| 8158 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8159 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8160 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8161 | CurvePreferences: []CurveID{curve.id}, |
| 8162 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8163 | flags: []string{ |
| 8164 | "-enable-all-curves", |
| 8165 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8166 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8167 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8168 | }) |
| 8169 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8170 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 8171 | config: Config{ |
| 8172 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8173 | CurvePreferences: []CurveID{curve.id}, |
| 8174 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8175 | flags: []string{ |
| 8176 | "-enable-all-curves", |
| 8177 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8178 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8179 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8180 | }) |
| 8181 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8182 | testType: serverTest, |
| 8183 | name: "CurveTest-Server-" + curve.name, |
| 8184 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8185 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8186 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8187 | CurvePreferences: []CurveID{curve.id}, |
| 8188 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8189 | flags: []string{ |
| 8190 | "-enable-all-curves", |
| 8191 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8192 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8193 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8194 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8195 | testCases = append(testCases, testCase{ |
| 8196 | testType: serverTest, |
| 8197 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 8198 | config: Config{ |
| 8199 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8200 | CurvePreferences: []CurveID{curve.id}, |
| 8201 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8202 | flags: []string{ |
| 8203 | "-enable-all-curves", |
| 8204 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8205 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8206 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8207 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8208 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8209 | |
| 8210 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8211 | testCases = append(testCases, testCase{ |
| 8212 | testType: serverTest, |
| 8213 | name: "UnknownCurve", |
| 8214 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8215 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8216 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8217 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8218 | }, |
| 8219 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8220 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8221 | // The server must be tolerant to bogus curves. |
| 8222 | testCases = append(testCases, testCase{ |
| 8223 | testType: serverTest, |
| 8224 | name: "UnknownCurve-TLS13", |
| 8225 | config: Config{ |
| 8226 | MaxVersion: VersionTLS13, |
| 8227 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8228 | }, |
| 8229 | }) |
| 8230 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8231 | // The server must not consider ECDHE ciphers when there are no |
| 8232 | // supported curves. |
| 8233 | testCases = append(testCases, testCase{ |
| 8234 | testType: serverTest, |
| 8235 | name: "NoSupportedCurves", |
| 8236 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8237 | MaxVersion: VersionTLS12, |
| 8238 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8239 | Bugs: ProtocolBugs{ |
| 8240 | NoSupportedCurves: true, |
| 8241 | }, |
| 8242 | }, |
| 8243 | shouldFail: true, |
| 8244 | expectedError: ":NO_SHARED_CIPHER:", |
| 8245 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8246 | testCases = append(testCases, testCase{ |
| 8247 | testType: serverTest, |
| 8248 | name: "NoSupportedCurves-TLS13", |
| 8249 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8250 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8251 | Bugs: ProtocolBugs{ |
| 8252 | NoSupportedCurves: true, |
| 8253 | }, |
| 8254 | }, |
| 8255 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8256 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8257 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8258 | |
| 8259 | // The server must fall back to another cipher when there are no |
| 8260 | // supported curves. |
| 8261 | testCases = append(testCases, testCase{ |
| 8262 | testType: serverTest, |
| 8263 | name: "NoCommonCurves", |
| 8264 | config: Config{ |
| 8265 | MaxVersion: VersionTLS12, |
| 8266 | CipherSuites: []uint16{ |
| 8267 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 8268 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8269 | }, |
| 8270 | CurvePreferences: []CurveID{CurveP224}, |
| 8271 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 8272 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8273 | }) |
| 8274 | |
| 8275 | // The client must reject bogus curves and disabled curves. |
| 8276 | testCases = append(testCases, testCase{ |
| 8277 | name: "BadECDHECurve", |
| 8278 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8279 | MaxVersion: VersionTLS12, |
| 8280 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8281 | Bugs: ProtocolBugs{ |
| 8282 | SendCurve: bogusCurve, |
| 8283 | }, |
| 8284 | }, |
| 8285 | shouldFail: true, |
| 8286 | expectedError: ":WRONG_CURVE:", |
| 8287 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8288 | testCases = append(testCases, testCase{ |
| 8289 | name: "BadECDHECurve-TLS13", |
| 8290 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8291 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8292 | Bugs: ProtocolBugs{ |
| 8293 | SendCurve: bogusCurve, |
| 8294 | }, |
| 8295 | }, |
| 8296 | shouldFail: true, |
| 8297 | expectedError: ":WRONG_CURVE:", |
| 8298 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8299 | |
| 8300 | testCases = append(testCases, testCase{ |
| 8301 | name: "UnsupportedCurve", |
| 8302 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8303 | MaxVersion: VersionTLS12, |
| 8304 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8305 | CurvePreferences: []CurveID{CurveP256}, |
| 8306 | Bugs: ProtocolBugs{ |
| 8307 | IgnorePeerCurvePreferences: true, |
| 8308 | }, |
| 8309 | }, |
| 8310 | flags: []string{"-p384-only"}, |
| 8311 | shouldFail: true, |
| 8312 | expectedError: ":WRONG_CURVE:", |
| 8313 | }) |
| 8314 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8315 | testCases = append(testCases, testCase{ |
| 8316 | // TODO(davidben): Add a TLS 1.3 version where |
| 8317 | // HelloRetryRequest requests an unsupported curve. |
| 8318 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8319 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8320 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8321 | CurvePreferences: []CurveID{CurveP384}, |
| 8322 | Bugs: ProtocolBugs{ |
| 8323 | SendCurve: CurveP256, |
| 8324 | }, |
| 8325 | }, |
| 8326 | flags: []string{"-p384-only"}, |
| 8327 | shouldFail: true, |
| 8328 | expectedError: ":WRONG_CURVE:", |
| 8329 | }) |
| 8330 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8331 | // Test invalid curve points. |
| 8332 | testCases = append(testCases, testCase{ |
| 8333 | name: "InvalidECDHPoint-Client", |
| 8334 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8335 | MaxVersion: VersionTLS12, |
| 8336 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8337 | CurvePreferences: []CurveID{CurveP256}, |
| 8338 | Bugs: ProtocolBugs{ |
| 8339 | InvalidECDHPoint: true, |
| 8340 | }, |
| 8341 | }, |
| 8342 | shouldFail: true, |
| 8343 | expectedError: ":INVALID_ENCODING:", |
| 8344 | }) |
| 8345 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8346 | name: "InvalidECDHPoint-Client-TLS13", |
| 8347 | config: Config{ |
| 8348 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8349 | CurvePreferences: []CurveID{CurveP256}, |
| 8350 | Bugs: ProtocolBugs{ |
| 8351 | InvalidECDHPoint: true, |
| 8352 | }, |
| 8353 | }, |
| 8354 | shouldFail: true, |
| 8355 | expectedError: ":INVALID_ENCODING:", |
| 8356 | }) |
| 8357 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8358 | testType: serverTest, |
| 8359 | name: "InvalidECDHPoint-Server", |
| 8360 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8361 | MaxVersion: VersionTLS12, |
| 8362 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8363 | CurvePreferences: []CurveID{CurveP256}, |
| 8364 | Bugs: ProtocolBugs{ |
| 8365 | InvalidECDHPoint: true, |
| 8366 | }, |
| 8367 | }, |
| 8368 | shouldFail: true, |
| 8369 | expectedError: ":INVALID_ENCODING:", |
| 8370 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8371 | testCases = append(testCases, testCase{ |
| 8372 | testType: serverTest, |
| 8373 | name: "InvalidECDHPoint-Server-TLS13", |
| 8374 | config: Config{ |
| 8375 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8376 | CurvePreferences: []CurveID{CurveP256}, |
| 8377 | Bugs: ProtocolBugs{ |
| 8378 | InvalidECDHPoint: true, |
| 8379 | }, |
| 8380 | }, |
| 8381 | shouldFail: true, |
| 8382 | expectedError: ":INVALID_ENCODING:", |
| 8383 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8384 | |
| 8385 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8386 | testCases = append(testCases, testCase{ |
| 8387 | name: "CurveID-Resume-Client", |
| 8388 | config: Config{ |
| 8389 | MaxVersion: VersionTLS12, |
| 8390 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8391 | CurvePreferences: []CurveID{CurveX25519}, |
| 8392 | }, |
| 8393 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8394 | resumeSession: true, |
| 8395 | }) |
| 8396 | testCases = append(testCases, testCase{ |
| 8397 | testType: serverTest, |
| 8398 | name: "CurveID-Resume-Server", |
| 8399 | config: Config{ |
| 8400 | MaxVersion: VersionTLS12, |
| 8401 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8402 | CurvePreferences: []CurveID{CurveX25519}, |
| 8403 | }, |
| 8404 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8405 | resumeSession: true, |
| 8406 | }) |
| 8407 | |
| 8408 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8409 | // one should be reported. |
| 8410 | testCases = append(testCases, testCase{ |
| 8411 | name: "CurveID-Resume-Client-TLS13", |
| 8412 | config: Config{ |
| 8413 | MaxVersion: VersionTLS13, |
| 8414 | CurvePreferences: []CurveID{CurveX25519}, |
| 8415 | }, |
| 8416 | resumeConfig: &Config{ |
| 8417 | MaxVersion: VersionTLS13, |
| 8418 | CurvePreferences: []CurveID{CurveP256}, |
| 8419 | }, |
| 8420 | flags: []string{ |
| 8421 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8422 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8423 | }, |
| 8424 | resumeSession: true, |
| 8425 | }) |
| 8426 | testCases = append(testCases, testCase{ |
| 8427 | testType: serverTest, |
| 8428 | name: "CurveID-Resume-Server-TLS13", |
| 8429 | config: Config{ |
| 8430 | MaxVersion: VersionTLS13, |
| 8431 | CurvePreferences: []CurveID{CurveX25519}, |
| 8432 | }, |
| 8433 | resumeConfig: &Config{ |
| 8434 | MaxVersion: VersionTLS13, |
| 8435 | CurvePreferences: []CurveID{CurveP256}, |
| 8436 | }, |
| 8437 | flags: []string{ |
| 8438 | "-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8439 | "-expect-resume-curve-id", strconv.Itoa(int(CurveP256)), |
| 8440 | }, |
| 8441 | resumeSession: true, |
| 8442 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 8443 | |
| 8444 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 8445 | testCases = append(testCases, testCase{ |
| 8446 | name: "PointFormat-ServerHello-TLS12", |
| 8447 | config: Config{ |
| 8448 | MaxVersion: VersionTLS12, |
| 8449 | Bugs: ProtocolBugs{ |
| 8450 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8451 | }, |
| 8452 | }, |
| 8453 | }) |
| 8454 | testCases = append(testCases, testCase{ |
| 8455 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 8456 | config: Config{ |
| 8457 | MaxVersion: VersionTLS13, |
| 8458 | Bugs: ProtocolBugs{ |
| 8459 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8460 | }, |
| 8461 | }, |
| 8462 | shouldFail: true, |
| 8463 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8464 | }) |
| 8465 | |
| 8466 | // Test that we tolerate unknown point formats, as long as |
| 8467 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 8468 | // check they are still functional. |
| 8469 | testCases = append(testCases, testCase{ |
| 8470 | name: "PointFormat-Client-Tolerance", |
| 8471 | config: Config{ |
| 8472 | MaxVersion: VersionTLS12, |
| 8473 | Bugs: ProtocolBugs{ |
| 8474 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8475 | }, |
| 8476 | }, |
| 8477 | }) |
| 8478 | testCases = append(testCases, testCase{ |
| 8479 | testType: serverTest, |
| 8480 | name: "PointFormat-Server-Tolerance", |
| 8481 | config: Config{ |
| 8482 | MaxVersion: VersionTLS12, |
| 8483 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8484 | Bugs: ProtocolBugs{ |
| 8485 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8486 | }, |
| 8487 | }, |
| 8488 | }) |
| 8489 | |
| 8490 | // Test TLS 1.2 does not require the point format extension to be |
| 8491 | // present. |
| 8492 | testCases = append(testCases, testCase{ |
| 8493 | name: "PointFormat-Client-Missing", |
| 8494 | config: Config{ |
| 8495 | MaxVersion: VersionTLS12, |
| 8496 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8497 | Bugs: ProtocolBugs{ |
| 8498 | SendSupportedPointFormats: []byte{}, |
| 8499 | }, |
| 8500 | }, |
| 8501 | }) |
| 8502 | testCases = append(testCases, testCase{ |
| 8503 | testType: serverTest, |
| 8504 | name: "PointFormat-Server-Missing", |
| 8505 | config: Config{ |
| 8506 | MaxVersion: VersionTLS12, |
| 8507 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8508 | Bugs: ProtocolBugs{ |
| 8509 | SendSupportedPointFormats: []byte{}, |
| 8510 | }, |
| 8511 | }, |
| 8512 | }) |
| 8513 | |
| 8514 | // If the point format extension is present, uncompressed points must be |
| 8515 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 8516 | testCases = append(testCases, testCase{ |
| 8517 | name: "PointFormat-Client-MissingUncompressed", |
| 8518 | config: Config{ |
| 8519 | MaxVersion: VersionTLS12, |
| 8520 | Bugs: ProtocolBugs{ |
| 8521 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8522 | }, |
| 8523 | }, |
| 8524 | shouldFail: true, |
| 8525 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8526 | }) |
| 8527 | testCases = append(testCases, testCase{ |
| 8528 | testType: serverTest, |
| 8529 | name: "PointFormat-Server-MissingUncompressed", |
| 8530 | config: Config{ |
| 8531 | MaxVersion: VersionTLS12, |
| 8532 | Bugs: ProtocolBugs{ |
| 8533 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8534 | }, |
| 8535 | }, |
| 8536 | shouldFail: true, |
| 8537 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8538 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8539 | } |
| 8540 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8541 | func addTLS13RecordTests() { |
| 8542 | testCases = append(testCases, testCase{ |
| 8543 | name: "TLS13-RecordPadding", |
| 8544 | config: Config{ |
| 8545 | MaxVersion: VersionTLS13, |
| 8546 | MinVersion: VersionTLS13, |
| 8547 | Bugs: ProtocolBugs{ |
| 8548 | RecordPadding: 10, |
| 8549 | }, |
| 8550 | }, |
| 8551 | }) |
| 8552 | |
| 8553 | testCases = append(testCases, testCase{ |
| 8554 | name: "TLS13-EmptyRecords", |
| 8555 | config: Config{ |
| 8556 | MaxVersion: VersionTLS13, |
| 8557 | MinVersion: VersionTLS13, |
| 8558 | Bugs: ProtocolBugs{ |
| 8559 | OmitRecordContents: true, |
| 8560 | }, |
| 8561 | }, |
| 8562 | shouldFail: true, |
| 8563 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8564 | }) |
| 8565 | |
| 8566 | testCases = append(testCases, testCase{ |
| 8567 | name: "TLS13-OnlyPadding", |
| 8568 | config: Config{ |
| 8569 | MaxVersion: VersionTLS13, |
| 8570 | MinVersion: VersionTLS13, |
| 8571 | Bugs: ProtocolBugs{ |
| 8572 | OmitRecordContents: true, |
| 8573 | RecordPadding: 10, |
| 8574 | }, |
| 8575 | }, |
| 8576 | shouldFail: true, |
| 8577 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8578 | }) |
| 8579 | |
| 8580 | testCases = append(testCases, testCase{ |
| 8581 | name: "TLS13-WrongOuterRecord", |
| 8582 | config: Config{ |
| 8583 | MaxVersion: VersionTLS13, |
| 8584 | MinVersion: VersionTLS13, |
| 8585 | Bugs: ProtocolBugs{ |
| 8586 | OuterRecordType: recordTypeHandshake, |
| 8587 | }, |
| 8588 | }, |
| 8589 | shouldFail: true, |
| 8590 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8591 | }) |
| 8592 | } |
| 8593 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8594 | func addSessionTicketTests() { |
| 8595 | testCases = append(testCases, testCase{ |
| 8596 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8597 | // mean the server changed its mind on sending a ticket. |
| 8598 | name: "SendEmptySessionTicket", |
| 8599 | config: Config{ |
| 8600 | MaxVersion: VersionTLS12, |
| 8601 | Bugs: ProtocolBugs{ |
| 8602 | SendEmptySessionTicket: true, |
| 8603 | }, |
| 8604 | }, |
| 8605 | flags: []string{"-expect-no-session"}, |
| 8606 | }) |
| 8607 | |
| 8608 | // Test that the server ignores unknown PSK modes. |
| 8609 | testCases = append(testCases, testCase{ |
| 8610 | testType: serverTest, |
| 8611 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 8612 | config: Config{ |
| 8613 | MaxVersion: VersionTLS13, |
| 8614 | Bugs: ProtocolBugs{ |
| 8615 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8616 | }, |
| 8617 | }, |
| 8618 | resumeSession: true, |
| 8619 | expectedResumeVersion: VersionTLS13, |
| 8620 | }) |
| 8621 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8622 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 8623 | testCases = append(testCases, testCase{ |
| 8624 | testType: serverTest, |
| 8625 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 8626 | config: Config{ |
| 8627 | MaxVersion: VersionTLS13, |
| 8628 | Bugs: ProtocolBugs{ |
| 8629 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8630 | ExpectNoNewSessionTicket: true, |
| 8631 | }, |
| 8632 | }, |
| 8633 | }) |
| 8634 | |
| 8635 | // Test that the server does not accept a session with no matching key exchange mode. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8636 | testCases = append(testCases, testCase{ |
| 8637 | testType: serverTest, |
| 8638 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 8639 | config: Config{ |
| 8640 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8641 | }, |
| 8642 | resumeConfig: &Config{ |
| 8643 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8644 | Bugs: ProtocolBugs{ |
| 8645 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 8646 | }, |
| 8647 | }, |
| 8648 | resumeSession: true, |
| 8649 | expectResumeRejected: true, |
| 8650 | }) |
| 8651 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8652 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8653 | testCases = append(testCases, testCase{ |
| 8654 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8655 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8656 | config: Config{ |
| 8657 | MaxVersion: VersionTLS13, |
| 8658 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8659 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8660 | }, |
| 8661 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8662 | resumeSession: true, |
| 8663 | flags: []string{ |
| 8664 | "-resumption-delay", "10", |
| 8665 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8666 | }) |
| 8667 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8668 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8669 | testCases = append(testCases, testCase{ |
| 8670 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8671 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8672 | config: Config{ |
| 8673 | MaxVersion: VersionTLS13, |
| 8674 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8675 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8676 | }, |
| 8677 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 8678 | resumeSession: true, |
| 8679 | shouldFail: true, |
| 8680 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8681 | }) |
| 8682 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 8683 | // Test that the server's ticket age skew reporting works. |
| 8684 | testCases = append(testCases, testCase{ |
| 8685 | testType: serverTest, |
| 8686 | name: "TLS13-TicketAgeSkew-Forward", |
| 8687 | config: Config{ |
| 8688 | MaxVersion: VersionTLS13, |
| 8689 | Bugs: ProtocolBugs{ |
| 8690 | SendTicketAge: 15 * time.Second, |
| 8691 | }, |
| 8692 | }, |
| 8693 | resumeSession: true, |
| 8694 | flags: []string{ |
| 8695 | "-resumption-delay", "10", |
| 8696 | "-expect-ticket-age-skew", "5", |
| 8697 | }, |
| 8698 | }) |
| 8699 | testCases = append(testCases, testCase{ |
| 8700 | testType: serverTest, |
| 8701 | name: "TLS13-TicketAgeSkew-Backward", |
| 8702 | config: Config{ |
| 8703 | MaxVersion: VersionTLS13, |
| 8704 | Bugs: ProtocolBugs{ |
| 8705 | SendTicketAge: 5 * time.Second, |
| 8706 | }, |
| 8707 | }, |
| 8708 | resumeSession: true, |
| 8709 | flags: []string{ |
| 8710 | "-resumption-delay", "10", |
| 8711 | "-expect-ticket-age-skew", "-5", |
| 8712 | }, |
| 8713 | }) |
| 8714 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8715 | testCases = append(testCases, testCase{ |
| 8716 | testType: clientTest, |
| 8717 | name: "TLS13-SendTicketEarlyDataInfo", |
| 8718 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8719 | MaxVersion: VersionTLS13, |
| 8720 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8721 | }, |
| 8722 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8723 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8724 | "-expect-early-data-info", |
| 8725 | }, |
| 8726 | }) |
| 8727 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8728 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 8729 | testCases = append(testCases, testCase{ |
| 8730 | testType: clientTest, |
| 8731 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 8732 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8733 | MaxVersion: VersionTLS13, |
| 8734 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 8735 | }, |
| 8736 | }) |
| 8737 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8738 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8739 | testType: clientTest, |
| 8740 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 8741 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 8742 | MaxVersion: VersionTLS13, |
| 8743 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8744 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 8745 | DuplicateTicketEarlyDataInfo: true, |
| 8746 | }, |
| 8747 | }, |
| 8748 | shouldFail: true, |
| 8749 | expectedError: ":DUPLICATE_EXTENSION:", |
| 8750 | expectedLocalError: "remote error: illegal parameter", |
| 8751 | }) |
| 8752 | |
| 8753 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 8754 | testType: serverTest, |
| 8755 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 8756 | config: Config{ |
| 8757 | MaxVersion: VersionTLS13, |
| 8758 | Bugs: ProtocolBugs{ |
| 8759 | ExpectTicketEarlyDataInfo: true, |
| 8760 | }, |
| 8761 | }, |
| 8762 | flags: []string{ |
| 8763 | "-enable-early-data", |
| 8764 | }, |
| 8765 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 8766 | |
| 8767 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 8768 | // is honored. |
| 8769 | testCases = append(testCases, testCase{ |
| 8770 | testType: clientTest, |
| 8771 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 8772 | config: Config{ |
| 8773 | MaxVersion: VersionTLS13, |
| 8774 | Bugs: ProtocolBugs{ |
| 8775 | SendTicketLifetime: 20 * time.Second, |
| 8776 | }, |
| 8777 | }, |
| 8778 | flags: []string{ |
| 8779 | "-resumption-delay", "19", |
| 8780 | }, |
| 8781 | resumeSession: true, |
| 8782 | }) |
| 8783 | testCases = append(testCases, testCase{ |
| 8784 | testType: clientTest, |
| 8785 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 8786 | config: Config{ |
| 8787 | MaxVersion: VersionTLS13, |
| 8788 | Bugs: ProtocolBugs{ |
| 8789 | SendTicketLifetime: 20 * time.Second, |
| 8790 | // The client should not offer the expired session. |
| 8791 | ExpectNoTLS13PSK: true, |
| 8792 | }, |
| 8793 | }, |
| 8794 | flags: []string{ |
| 8795 | "-resumption-delay", "21", |
| 8796 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 8797 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 8798 | expectResumeRejected: true, |
| 8799 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8800 | } |
| 8801 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8802 | func addChangeCipherSpecTests() { |
| 8803 | // Test missing ChangeCipherSpecs. |
| 8804 | testCases = append(testCases, testCase{ |
| 8805 | name: "SkipChangeCipherSpec-Client", |
| 8806 | config: Config{ |
| 8807 | MaxVersion: VersionTLS12, |
| 8808 | Bugs: ProtocolBugs{ |
| 8809 | SkipChangeCipherSpec: true, |
| 8810 | }, |
| 8811 | }, |
| 8812 | shouldFail: true, |
| 8813 | expectedError: ":UNEXPECTED_RECORD:", |
| 8814 | }) |
| 8815 | testCases = append(testCases, testCase{ |
| 8816 | testType: serverTest, |
| 8817 | name: "SkipChangeCipherSpec-Server", |
| 8818 | config: Config{ |
| 8819 | MaxVersion: VersionTLS12, |
| 8820 | Bugs: ProtocolBugs{ |
| 8821 | SkipChangeCipherSpec: true, |
| 8822 | }, |
| 8823 | }, |
| 8824 | shouldFail: true, |
| 8825 | expectedError: ":UNEXPECTED_RECORD:", |
| 8826 | }) |
| 8827 | testCases = append(testCases, testCase{ |
| 8828 | testType: serverTest, |
| 8829 | name: "SkipChangeCipherSpec-Server-NPN", |
| 8830 | config: Config{ |
| 8831 | MaxVersion: VersionTLS12, |
| 8832 | NextProtos: []string{"bar"}, |
| 8833 | Bugs: ProtocolBugs{ |
| 8834 | SkipChangeCipherSpec: true, |
| 8835 | }, |
| 8836 | }, |
| 8837 | flags: []string{ |
| 8838 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8839 | }, |
| 8840 | shouldFail: true, |
| 8841 | expectedError: ":UNEXPECTED_RECORD:", |
| 8842 | }) |
| 8843 | |
| 8844 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 8845 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 8846 | // rejected. Test both with and without handshake packing to handle both |
| 8847 | // when the partial post-CCS message is in its own record and when it is |
| 8848 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8849 | for _, packed := range []bool{false, true} { |
| 8850 | var suffix string |
| 8851 | if packed { |
| 8852 | suffix = "-Packed" |
| 8853 | } |
| 8854 | |
| 8855 | testCases = append(testCases, testCase{ |
| 8856 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 8857 | config: Config{ |
| 8858 | MaxVersion: VersionTLS12, |
| 8859 | Bugs: ProtocolBugs{ |
| 8860 | FragmentAcrossChangeCipherSpec: true, |
| 8861 | PackHandshakeFlight: packed, |
| 8862 | }, |
| 8863 | }, |
| 8864 | shouldFail: true, |
| 8865 | expectedError: ":UNEXPECTED_RECORD:", |
| 8866 | }) |
| 8867 | testCases = append(testCases, testCase{ |
| 8868 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 8869 | config: Config{ |
| 8870 | MaxVersion: VersionTLS12, |
| 8871 | }, |
| 8872 | resumeSession: true, |
| 8873 | resumeConfig: &Config{ |
| 8874 | MaxVersion: VersionTLS12, |
| 8875 | Bugs: ProtocolBugs{ |
| 8876 | FragmentAcrossChangeCipherSpec: true, |
| 8877 | PackHandshakeFlight: packed, |
| 8878 | }, |
| 8879 | }, |
| 8880 | shouldFail: true, |
| 8881 | expectedError: ":UNEXPECTED_RECORD:", |
| 8882 | }) |
| 8883 | testCases = append(testCases, testCase{ |
| 8884 | testType: serverTest, |
| 8885 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 8886 | config: Config{ |
| 8887 | MaxVersion: VersionTLS12, |
| 8888 | Bugs: ProtocolBugs{ |
| 8889 | FragmentAcrossChangeCipherSpec: true, |
| 8890 | PackHandshakeFlight: packed, |
| 8891 | }, |
| 8892 | }, |
| 8893 | shouldFail: true, |
| 8894 | expectedError: ":UNEXPECTED_RECORD:", |
| 8895 | }) |
| 8896 | testCases = append(testCases, testCase{ |
| 8897 | testType: serverTest, |
| 8898 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 8899 | config: Config{ |
| 8900 | MaxVersion: VersionTLS12, |
| 8901 | }, |
| 8902 | resumeSession: true, |
| 8903 | resumeConfig: &Config{ |
| 8904 | MaxVersion: VersionTLS12, |
| 8905 | Bugs: ProtocolBugs{ |
| 8906 | FragmentAcrossChangeCipherSpec: true, |
| 8907 | PackHandshakeFlight: packed, |
| 8908 | }, |
| 8909 | }, |
| 8910 | shouldFail: true, |
| 8911 | expectedError: ":UNEXPECTED_RECORD:", |
| 8912 | }) |
| 8913 | testCases = append(testCases, testCase{ |
| 8914 | testType: serverTest, |
| 8915 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 8916 | config: Config{ |
| 8917 | MaxVersion: VersionTLS12, |
| 8918 | NextProtos: []string{"bar"}, |
| 8919 | Bugs: ProtocolBugs{ |
| 8920 | FragmentAcrossChangeCipherSpec: true, |
| 8921 | PackHandshakeFlight: packed, |
| 8922 | }, |
| 8923 | }, |
| 8924 | flags: []string{ |
| 8925 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 8926 | }, |
| 8927 | shouldFail: true, |
| 8928 | expectedError: ":UNEXPECTED_RECORD:", |
| 8929 | }) |
| 8930 | } |
| 8931 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 8932 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 8933 | // messages in the handshake queue. Do this by testing the server |
| 8934 | // reading the client Finished, reversing the flight so Finished comes |
| 8935 | // first. |
| 8936 | testCases = append(testCases, testCase{ |
| 8937 | protocol: dtls, |
| 8938 | testType: serverTest, |
| 8939 | name: "SendUnencryptedFinished-DTLS", |
| 8940 | config: Config{ |
| 8941 | MaxVersion: VersionTLS12, |
| 8942 | Bugs: ProtocolBugs{ |
| 8943 | SendUnencryptedFinished: true, |
| 8944 | ReverseHandshakeFragments: true, |
| 8945 | }, |
| 8946 | }, |
| 8947 | shouldFail: true, |
| 8948 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8949 | }) |
| 8950 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8951 | // Test synchronization between encryption changes and the handshake in |
| 8952 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 8953 | testCases = append(testCases, testCase{ |
| 8954 | name: "PartialEncryptedExtensionsWithServerHello", |
| 8955 | config: Config{ |
| 8956 | MaxVersion: VersionTLS13, |
| 8957 | Bugs: ProtocolBugs{ |
| 8958 | PartialEncryptedExtensionsWithServerHello: true, |
| 8959 | }, |
| 8960 | }, |
| 8961 | shouldFail: true, |
| 8962 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8963 | }) |
| 8964 | testCases = append(testCases, testCase{ |
| 8965 | testType: serverTest, |
| 8966 | name: "PartialClientFinishedWithClientHello", |
| 8967 | config: Config{ |
| 8968 | MaxVersion: VersionTLS13, |
| 8969 | Bugs: ProtocolBugs{ |
| 8970 | PartialClientFinishedWithClientHello: true, |
| 8971 | }, |
| 8972 | }, |
| 8973 | shouldFail: true, |
| 8974 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 8975 | }) |
| 8976 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 8977 | // Test that early ChangeCipherSpecs are handled correctly. |
| 8978 | testCases = append(testCases, testCase{ |
| 8979 | testType: serverTest, |
| 8980 | name: "EarlyChangeCipherSpec-server-1", |
| 8981 | config: Config{ |
| 8982 | MaxVersion: VersionTLS12, |
| 8983 | Bugs: ProtocolBugs{ |
| 8984 | EarlyChangeCipherSpec: 1, |
| 8985 | }, |
| 8986 | }, |
| 8987 | shouldFail: true, |
| 8988 | expectedError: ":UNEXPECTED_RECORD:", |
| 8989 | }) |
| 8990 | testCases = append(testCases, testCase{ |
| 8991 | testType: serverTest, |
| 8992 | name: "EarlyChangeCipherSpec-server-2", |
| 8993 | config: Config{ |
| 8994 | MaxVersion: VersionTLS12, |
| 8995 | Bugs: ProtocolBugs{ |
| 8996 | EarlyChangeCipherSpec: 2, |
| 8997 | }, |
| 8998 | }, |
| 8999 | shouldFail: true, |
| 9000 | expectedError: ":UNEXPECTED_RECORD:", |
| 9001 | }) |
| 9002 | testCases = append(testCases, testCase{ |
| 9003 | protocol: dtls, |
| 9004 | name: "StrayChangeCipherSpec", |
| 9005 | config: Config{ |
| 9006 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 9007 | // that stray ChangeCipherSpec messages are |
| 9008 | // rejected. |
| 9009 | MaxVersion: VersionTLS12, |
| 9010 | Bugs: ProtocolBugs{ |
| 9011 | StrayChangeCipherSpec: true, |
| 9012 | }, |
| 9013 | }, |
| 9014 | }) |
| 9015 | |
| 9016 | // Test that the contents of ChangeCipherSpec are checked. |
| 9017 | testCases = append(testCases, testCase{ |
| 9018 | name: "BadChangeCipherSpec-1", |
| 9019 | config: Config{ |
| 9020 | MaxVersion: VersionTLS12, |
| 9021 | Bugs: ProtocolBugs{ |
| 9022 | BadChangeCipherSpec: []byte{2}, |
| 9023 | }, |
| 9024 | }, |
| 9025 | shouldFail: true, |
| 9026 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9027 | }) |
| 9028 | testCases = append(testCases, testCase{ |
| 9029 | name: "BadChangeCipherSpec-2", |
| 9030 | config: Config{ |
| 9031 | MaxVersion: VersionTLS12, |
| 9032 | Bugs: ProtocolBugs{ |
| 9033 | BadChangeCipherSpec: []byte{1, 1}, |
| 9034 | }, |
| 9035 | }, |
| 9036 | shouldFail: true, |
| 9037 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9038 | }) |
| 9039 | testCases = append(testCases, testCase{ |
| 9040 | protocol: dtls, |
| 9041 | name: "BadChangeCipherSpec-DTLS-1", |
| 9042 | config: Config{ |
| 9043 | MaxVersion: VersionTLS12, |
| 9044 | Bugs: ProtocolBugs{ |
| 9045 | BadChangeCipherSpec: []byte{2}, |
| 9046 | }, |
| 9047 | }, |
| 9048 | shouldFail: true, |
| 9049 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9050 | }) |
| 9051 | testCases = append(testCases, testCase{ |
| 9052 | protocol: dtls, |
| 9053 | name: "BadChangeCipherSpec-DTLS-2", |
| 9054 | config: Config{ |
| 9055 | MaxVersion: VersionTLS12, |
| 9056 | Bugs: ProtocolBugs{ |
| 9057 | BadChangeCipherSpec: []byte{1, 1}, |
| 9058 | }, |
| 9059 | }, |
| 9060 | shouldFail: true, |
| 9061 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9062 | }) |
| 9063 | } |
| 9064 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9065 | type perMessageTest struct { |
| 9066 | messageType uint8 |
| 9067 | test testCase |
| 9068 | } |
| 9069 | |
| 9070 | // makePerMessageTests returns a series of test templates which cover each |
| 9071 | // message in the TLS handshake. These may be used with bugs like |
| 9072 | // WrongMessageType to fully test a per-message bug. |
| 9073 | func makePerMessageTests() []perMessageTest { |
| 9074 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9075 | for _, protocol := range []protocol{tls, dtls} { |
| 9076 | var suffix string |
| 9077 | if protocol == dtls { |
| 9078 | suffix = "-DTLS" |
| 9079 | } |
| 9080 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9081 | ret = append(ret, perMessageTest{ |
| 9082 | messageType: typeClientHello, |
| 9083 | test: testCase{ |
| 9084 | protocol: protocol, |
| 9085 | testType: serverTest, |
| 9086 | name: "ClientHello" + suffix, |
| 9087 | config: Config{ |
| 9088 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9089 | }, |
| 9090 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9091 | }) |
| 9092 | |
| 9093 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9094 | ret = append(ret, perMessageTest{ |
| 9095 | messageType: typeHelloVerifyRequest, |
| 9096 | test: testCase{ |
| 9097 | protocol: protocol, |
| 9098 | name: "HelloVerifyRequest" + suffix, |
| 9099 | config: Config{ |
| 9100 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9101 | }, |
| 9102 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9103 | }) |
| 9104 | } |
| 9105 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9106 | ret = append(ret, perMessageTest{ |
| 9107 | messageType: typeServerHello, |
| 9108 | test: testCase{ |
| 9109 | protocol: protocol, |
| 9110 | name: "ServerHello" + suffix, |
| 9111 | config: Config{ |
| 9112 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9113 | }, |
| 9114 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9115 | }) |
| 9116 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9117 | ret = append(ret, perMessageTest{ |
| 9118 | messageType: typeCertificate, |
| 9119 | test: testCase{ |
| 9120 | protocol: protocol, |
| 9121 | name: "ServerCertificate" + suffix, |
| 9122 | config: Config{ |
| 9123 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9124 | }, |
| 9125 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9126 | }) |
| 9127 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9128 | ret = append(ret, perMessageTest{ |
| 9129 | messageType: typeCertificateStatus, |
| 9130 | test: testCase{ |
| 9131 | protocol: protocol, |
| 9132 | name: "CertificateStatus" + suffix, |
| 9133 | config: Config{ |
| 9134 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9135 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9136 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9137 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9138 | }) |
| 9139 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9140 | ret = append(ret, perMessageTest{ |
| 9141 | messageType: typeServerKeyExchange, |
| 9142 | test: testCase{ |
| 9143 | protocol: protocol, |
| 9144 | name: "ServerKeyExchange" + suffix, |
| 9145 | config: Config{ |
| 9146 | MaxVersion: VersionTLS12, |
| 9147 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9148 | }, |
| 9149 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9150 | }) |
| 9151 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9152 | ret = append(ret, perMessageTest{ |
| 9153 | messageType: typeCertificateRequest, |
| 9154 | test: testCase{ |
| 9155 | protocol: protocol, |
| 9156 | name: "CertificateRequest" + suffix, |
| 9157 | config: Config{ |
| 9158 | MaxVersion: VersionTLS12, |
| 9159 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9160 | }, |
| 9161 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9162 | }) |
| 9163 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9164 | ret = append(ret, perMessageTest{ |
| 9165 | messageType: typeServerHelloDone, |
| 9166 | test: testCase{ |
| 9167 | protocol: protocol, |
| 9168 | name: "ServerHelloDone" + suffix, |
| 9169 | config: Config{ |
| 9170 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9171 | }, |
| 9172 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9173 | }) |
| 9174 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9175 | ret = append(ret, perMessageTest{ |
| 9176 | messageType: typeCertificate, |
| 9177 | test: testCase{ |
| 9178 | testType: serverTest, |
| 9179 | protocol: protocol, |
| 9180 | name: "ClientCertificate" + suffix, |
| 9181 | config: Config{ |
| 9182 | Certificates: []Certificate{rsaCertificate}, |
| 9183 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9184 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9185 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9186 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9187 | }) |
| 9188 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9189 | ret = append(ret, perMessageTest{ |
| 9190 | messageType: typeCertificateVerify, |
| 9191 | test: testCase{ |
| 9192 | testType: serverTest, |
| 9193 | protocol: protocol, |
| 9194 | name: "CertificateVerify" + suffix, |
| 9195 | config: Config{ |
| 9196 | Certificates: []Certificate{rsaCertificate}, |
| 9197 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9198 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9199 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9200 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9201 | }) |
| 9202 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9203 | ret = append(ret, perMessageTest{ |
| 9204 | messageType: typeClientKeyExchange, |
| 9205 | test: testCase{ |
| 9206 | testType: serverTest, |
| 9207 | protocol: protocol, |
| 9208 | name: "ClientKeyExchange" + suffix, |
| 9209 | config: Config{ |
| 9210 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9211 | }, |
| 9212 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9213 | }) |
| 9214 | |
| 9215 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9216 | ret = append(ret, perMessageTest{ |
| 9217 | messageType: typeNextProtocol, |
| 9218 | test: testCase{ |
| 9219 | testType: serverTest, |
| 9220 | protocol: protocol, |
| 9221 | name: "NextProtocol" + suffix, |
| 9222 | config: Config{ |
| 9223 | MaxVersion: VersionTLS12, |
| 9224 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9225 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9226 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9227 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9228 | }) |
| 9229 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9230 | ret = append(ret, perMessageTest{ |
| 9231 | messageType: typeChannelID, |
| 9232 | test: testCase{ |
| 9233 | testType: serverTest, |
| 9234 | protocol: protocol, |
| 9235 | name: "ChannelID" + suffix, |
| 9236 | config: Config{ |
| 9237 | MaxVersion: VersionTLS12, |
| 9238 | ChannelID: channelIDKey, |
| 9239 | }, |
| 9240 | flags: []string{ |
| 9241 | "-expect-channel-id", |
| 9242 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9243 | }, |
| 9244 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9245 | }) |
| 9246 | } |
| 9247 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9248 | ret = append(ret, perMessageTest{ |
| 9249 | messageType: typeFinished, |
| 9250 | test: testCase{ |
| 9251 | testType: serverTest, |
| 9252 | protocol: protocol, |
| 9253 | name: "ClientFinished" + suffix, |
| 9254 | config: Config{ |
| 9255 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9256 | }, |
| 9257 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9258 | }) |
| 9259 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9260 | ret = append(ret, perMessageTest{ |
| 9261 | messageType: typeNewSessionTicket, |
| 9262 | test: testCase{ |
| 9263 | protocol: protocol, |
| 9264 | name: "NewSessionTicket" + suffix, |
| 9265 | config: Config{ |
| 9266 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9267 | }, |
| 9268 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9269 | }) |
| 9270 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9271 | ret = append(ret, perMessageTest{ |
| 9272 | messageType: typeFinished, |
| 9273 | test: testCase{ |
| 9274 | protocol: protocol, |
| 9275 | name: "ServerFinished" + suffix, |
| 9276 | config: Config{ |
| 9277 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9278 | }, |
| 9279 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9280 | }) |
| 9281 | |
| 9282 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9283 | |
| 9284 | ret = append(ret, perMessageTest{ |
| 9285 | messageType: typeClientHello, |
| 9286 | test: testCase{ |
| 9287 | testType: serverTest, |
| 9288 | name: "TLS13-ClientHello", |
| 9289 | config: Config{ |
| 9290 | MaxVersion: VersionTLS13, |
| 9291 | }, |
| 9292 | }, |
| 9293 | }) |
| 9294 | |
| 9295 | ret = append(ret, perMessageTest{ |
| 9296 | messageType: typeServerHello, |
| 9297 | test: testCase{ |
| 9298 | name: "TLS13-ServerHello", |
| 9299 | config: Config{ |
| 9300 | MaxVersion: VersionTLS13, |
| 9301 | }, |
| 9302 | }, |
| 9303 | }) |
| 9304 | |
| 9305 | ret = append(ret, perMessageTest{ |
| 9306 | messageType: typeEncryptedExtensions, |
| 9307 | test: testCase{ |
| 9308 | name: "TLS13-EncryptedExtensions", |
| 9309 | config: Config{ |
| 9310 | MaxVersion: VersionTLS13, |
| 9311 | }, |
| 9312 | }, |
| 9313 | }) |
| 9314 | |
| 9315 | ret = append(ret, perMessageTest{ |
| 9316 | messageType: typeCertificateRequest, |
| 9317 | test: testCase{ |
| 9318 | name: "TLS13-CertificateRequest", |
| 9319 | config: Config{ |
| 9320 | MaxVersion: VersionTLS13, |
| 9321 | ClientAuth: RequireAnyClientCert, |
| 9322 | }, |
| 9323 | }, |
| 9324 | }) |
| 9325 | |
| 9326 | ret = append(ret, perMessageTest{ |
| 9327 | messageType: typeCertificate, |
| 9328 | test: testCase{ |
| 9329 | name: "TLS13-ServerCertificate", |
| 9330 | config: Config{ |
| 9331 | MaxVersion: VersionTLS13, |
| 9332 | }, |
| 9333 | }, |
| 9334 | }) |
| 9335 | |
| 9336 | ret = append(ret, perMessageTest{ |
| 9337 | messageType: typeCertificateVerify, |
| 9338 | test: testCase{ |
| 9339 | name: "TLS13-ServerCertificateVerify", |
| 9340 | config: Config{ |
| 9341 | MaxVersion: VersionTLS13, |
| 9342 | }, |
| 9343 | }, |
| 9344 | }) |
| 9345 | |
| 9346 | ret = append(ret, perMessageTest{ |
| 9347 | messageType: typeFinished, |
| 9348 | test: testCase{ |
| 9349 | name: "TLS13-ServerFinished", |
| 9350 | config: Config{ |
| 9351 | MaxVersion: VersionTLS13, |
| 9352 | }, |
| 9353 | }, |
| 9354 | }) |
| 9355 | |
| 9356 | ret = append(ret, perMessageTest{ |
| 9357 | messageType: typeCertificate, |
| 9358 | test: testCase{ |
| 9359 | testType: serverTest, |
| 9360 | name: "TLS13-ClientCertificate", |
| 9361 | config: Config{ |
| 9362 | Certificates: []Certificate{rsaCertificate}, |
| 9363 | MaxVersion: VersionTLS13, |
| 9364 | }, |
| 9365 | flags: []string{"-require-any-client-certificate"}, |
| 9366 | }, |
| 9367 | }) |
| 9368 | |
| 9369 | ret = append(ret, perMessageTest{ |
| 9370 | messageType: typeCertificateVerify, |
| 9371 | test: testCase{ |
| 9372 | testType: serverTest, |
| 9373 | name: "TLS13-ClientCertificateVerify", |
| 9374 | config: Config{ |
| 9375 | Certificates: []Certificate{rsaCertificate}, |
| 9376 | MaxVersion: VersionTLS13, |
| 9377 | }, |
| 9378 | flags: []string{"-require-any-client-certificate"}, |
| 9379 | }, |
| 9380 | }) |
| 9381 | |
| 9382 | ret = append(ret, perMessageTest{ |
| 9383 | messageType: typeFinished, |
| 9384 | test: testCase{ |
| 9385 | testType: serverTest, |
| 9386 | name: "TLS13-ClientFinished", |
| 9387 | config: Config{ |
| 9388 | MaxVersion: VersionTLS13, |
| 9389 | }, |
| 9390 | }, |
| 9391 | }) |
| 9392 | |
| 9393 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9394 | } |
| 9395 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9396 | func addWrongMessageTypeTests() { |
| 9397 | for _, t := range makePerMessageTests() { |
| 9398 | t.test.name = "WrongMessageType-" + t.test.name |
| 9399 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 9400 | t.test.shouldFail = true |
| 9401 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 9402 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9403 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9404 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9405 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9406 | // an unencrypted alert while the server expects |
| 9407 | // encryption, so the alert is not readable by runner. |
| 9408 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9409 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9410 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9411 | testCases = append(testCases, t.test) |
| 9412 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9413 | } |
| 9414 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9415 | func addTrailingMessageDataTests() { |
| 9416 | for _, t := range makePerMessageTests() { |
| 9417 | t.test.name = "TrailingMessageData-" + t.test.name |
| 9418 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 9419 | t.test.shouldFail = true |
| 9420 | t.test.expectedError = ":DECODE_ERROR:" |
| 9421 | t.test.expectedLocalError = "remote error: error decoding message" |
| 9422 | |
| 9423 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9424 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9425 | // an unencrypted alert while the server expects |
| 9426 | // encryption, so the alert is not readable by runner. |
| 9427 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9428 | } |
| 9429 | |
| 9430 | if t.messageType == typeFinished { |
| 9431 | // Bad Finished messages read as the verify data having |
| 9432 | // the wrong length. |
| 9433 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 9434 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 9435 | } |
| 9436 | |
| 9437 | testCases = append(testCases, t.test) |
| 9438 | } |
| 9439 | } |
| 9440 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9441 | func addTLS13HandshakeTests() { |
| 9442 | testCases = append(testCases, testCase{ |
| 9443 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9444 | name: "NegotiatePSKResumption-TLS13", |
| 9445 | config: Config{ |
| 9446 | MaxVersion: VersionTLS13, |
| 9447 | Bugs: ProtocolBugs{ |
| 9448 | NegotiatePSKResumption: true, |
| 9449 | }, |
| 9450 | }, |
| 9451 | resumeSession: true, |
| 9452 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9453 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9454 | }) |
| 9455 | |
| 9456 | testCases = append(testCases, testCase{ |
| 9457 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9458 | name: "MissingKeyShare-Client", |
| 9459 | config: Config{ |
| 9460 | MaxVersion: VersionTLS13, |
| 9461 | Bugs: ProtocolBugs{ |
| 9462 | MissingKeyShare: true, |
| 9463 | }, |
| 9464 | }, |
| 9465 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9466 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9467 | }) |
| 9468 | |
| 9469 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9470 | testType: serverTest, |
| 9471 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9472 | config: Config{ |
| 9473 | MaxVersion: VersionTLS13, |
| 9474 | Bugs: ProtocolBugs{ |
| 9475 | MissingKeyShare: true, |
| 9476 | }, |
| 9477 | }, |
| 9478 | shouldFail: true, |
| 9479 | expectedError: ":MISSING_KEY_SHARE:", |
| 9480 | }) |
| 9481 | |
| 9482 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9483 | testType: serverTest, |
| 9484 | name: "DuplicateKeyShares", |
| 9485 | config: Config{ |
| 9486 | MaxVersion: VersionTLS13, |
| 9487 | Bugs: ProtocolBugs{ |
| 9488 | DuplicateKeyShares: true, |
| 9489 | }, |
| 9490 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9491 | shouldFail: true, |
| 9492 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9493 | }) |
| 9494 | |
| 9495 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9496 | testType: serverTest, |
| 9497 | name: "SkipEarlyData", |
| 9498 | config: Config{ |
| 9499 | MaxVersion: VersionTLS13, |
| 9500 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9501 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9502 | }, |
| 9503 | }, |
| 9504 | }) |
| 9505 | |
| 9506 | testCases = append(testCases, testCase{ |
| 9507 | testType: serverTest, |
| 9508 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9509 | config: Config{ |
| 9510 | MaxVersion: VersionTLS13, |
| 9511 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9512 | SendFakeEarlyDataLength: 4, |
| 9513 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9514 | }, |
| 9515 | }, |
| 9516 | shouldFail: true, |
| 9517 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9518 | }) |
| 9519 | |
| 9520 | testCases = append(testCases, testCase{ |
| 9521 | testType: serverTest, |
| 9522 | name: "SkipEarlyData-TooMuchData", |
| 9523 | config: Config{ |
| 9524 | MaxVersion: VersionTLS13, |
| 9525 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9526 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9527 | }, |
| 9528 | }, |
| 9529 | shouldFail: true, |
| 9530 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9531 | }) |
| 9532 | |
| 9533 | testCases = append(testCases, testCase{ |
| 9534 | testType: serverTest, |
| 9535 | name: "SkipEarlyData-Interleaved", |
| 9536 | config: Config{ |
| 9537 | MaxVersion: VersionTLS13, |
| 9538 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9539 | SendFakeEarlyDataLength: 4, |
| 9540 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9541 | }, |
| 9542 | }, |
| 9543 | shouldFail: true, |
| 9544 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9545 | }) |
| 9546 | |
| 9547 | testCases = append(testCases, testCase{ |
| 9548 | testType: serverTest, |
| 9549 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9550 | config: Config{ |
| 9551 | MaxVersion: VersionTLS13, |
| 9552 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9553 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9554 | }, |
| 9555 | }, |
| 9556 | shouldFail: true, |
| 9557 | expectedError: ":UNEXPECTED_RECORD:", |
| 9558 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9559 | }) |
| 9560 | |
| 9561 | testCases = append(testCases, testCase{ |
| 9562 | testType: serverTest, |
| 9563 | name: "SkipEarlyData-HRR", |
| 9564 | config: Config{ |
| 9565 | MaxVersion: VersionTLS13, |
| 9566 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9567 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9568 | }, |
| 9569 | DefaultCurves: []CurveID{}, |
| 9570 | }, |
| 9571 | }) |
| 9572 | |
| 9573 | testCases = append(testCases, testCase{ |
| 9574 | testType: serverTest, |
| 9575 | name: "SkipEarlyData-HRR-Interleaved", |
| 9576 | config: Config{ |
| 9577 | MaxVersion: VersionTLS13, |
| 9578 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9579 | SendFakeEarlyDataLength: 4, |
| 9580 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9581 | }, |
| 9582 | DefaultCurves: []CurveID{}, |
| 9583 | }, |
| 9584 | shouldFail: true, |
| 9585 | expectedError: ":UNEXPECTED_RECORD:", |
| 9586 | }) |
| 9587 | |
| 9588 | testCases = append(testCases, testCase{ |
| 9589 | testType: serverTest, |
| 9590 | name: "SkipEarlyData-HRR-TooMuchData", |
| 9591 | config: Config{ |
| 9592 | MaxVersion: VersionTLS13, |
| 9593 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9594 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9595 | }, |
| 9596 | DefaultCurves: []CurveID{}, |
| 9597 | }, |
| 9598 | shouldFail: true, |
| 9599 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9600 | }) |
| 9601 | |
| 9602 | // Test that skipping early data looking for cleartext correctly |
| 9603 | // processes an alert record. |
| 9604 | testCases = append(testCases, testCase{ |
| 9605 | testType: serverTest, |
| 9606 | name: "SkipEarlyData-HRR-FatalAlert", |
| 9607 | config: Config{ |
| 9608 | MaxVersion: VersionTLS13, |
| 9609 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9610 | SendEarlyAlert: true, |
| 9611 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9612 | }, |
| 9613 | DefaultCurves: []CurveID{}, |
| 9614 | }, |
| 9615 | shouldFail: true, |
| 9616 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 9617 | }) |
| 9618 | |
| 9619 | testCases = append(testCases, testCase{ |
| 9620 | testType: serverTest, |
| 9621 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 9622 | config: Config{ |
| 9623 | MaxVersion: VersionTLS13, |
| 9624 | Bugs: ProtocolBugs{ |
| 9625 | SendEarlyDataOnSecondClientHello: true, |
| 9626 | }, |
| 9627 | DefaultCurves: []CurveID{}, |
| 9628 | }, |
| 9629 | shouldFail: true, |
| 9630 | expectedLocalError: "remote error: bad record MAC", |
| 9631 | }) |
| 9632 | |
| 9633 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9634 | testType: clientTest, |
| 9635 | name: "EmptyEncryptedExtensions", |
| 9636 | config: Config{ |
| 9637 | MaxVersion: VersionTLS13, |
| 9638 | Bugs: ProtocolBugs{ |
| 9639 | EmptyEncryptedExtensions: true, |
| 9640 | }, |
| 9641 | }, |
| 9642 | shouldFail: true, |
| 9643 | expectedLocalError: "remote error: error decoding message", |
| 9644 | }) |
| 9645 | |
| 9646 | testCases = append(testCases, testCase{ |
| 9647 | testType: clientTest, |
| 9648 | name: "EncryptedExtensionsWithKeyShare", |
| 9649 | config: Config{ |
| 9650 | MaxVersion: VersionTLS13, |
| 9651 | Bugs: ProtocolBugs{ |
| 9652 | EncryptedExtensionsWithKeyShare: true, |
| 9653 | }, |
| 9654 | }, |
| 9655 | shouldFail: true, |
| 9656 | expectedLocalError: "remote error: unsupported extension", |
| 9657 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9658 | |
| 9659 | testCases = append(testCases, testCase{ |
| 9660 | testType: serverTest, |
| 9661 | name: "SendHelloRetryRequest", |
| 9662 | config: Config{ |
| 9663 | MaxVersion: VersionTLS13, |
| 9664 | // Require a HelloRetryRequest for every curve. |
| 9665 | DefaultCurves: []CurveID{}, |
| 9666 | }, |
| 9667 | expectedCurveID: CurveX25519, |
| 9668 | }) |
| 9669 | |
| 9670 | testCases = append(testCases, testCase{ |
| 9671 | testType: serverTest, |
| 9672 | name: "SendHelloRetryRequest-2", |
| 9673 | config: Config{ |
| 9674 | MaxVersion: VersionTLS13, |
| 9675 | DefaultCurves: []CurveID{CurveP384}, |
| 9676 | }, |
| 9677 | // Although the ClientHello did not predict our preferred curve, |
| 9678 | // we always select it whether it is predicted or not. |
| 9679 | expectedCurveID: CurveX25519, |
| 9680 | }) |
| 9681 | |
| 9682 | testCases = append(testCases, testCase{ |
| 9683 | name: "UnknownCurve-HelloRetryRequest", |
| 9684 | config: Config{ |
| 9685 | MaxVersion: VersionTLS13, |
| 9686 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9687 | CurvePreferences: []CurveID{CurveP384}, |
| 9688 | Bugs: ProtocolBugs{ |
| 9689 | SendHelloRetryRequestCurve: bogusCurve, |
| 9690 | }, |
| 9691 | }, |
| 9692 | shouldFail: true, |
| 9693 | expectedError: ":WRONG_CURVE:", |
| 9694 | }) |
| 9695 | |
| 9696 | testCases = append(testCases, testCase{ |
| 9697 | name: "DisabledCurve-HelloRetryRequest", |
| 9698 | config: Config{ |
| 9699 | MaxVersion: VersionTLS13, |
| 9700 | CurvePreferences: []CurveID{CurveP256}, |
| 9701 | Bugs: ProtocolBugs{ |
| 9702 | IgnorePeerCurvePreferences: true, |
| 9703 | }, |
| 9704 | }, |
| 9705 | flags: []string{"-p384-only"}, |
| 9706 | shouldFail: true, |
| 9707 | expectedError: ":WRONG_CURVE:", |
| 9708 | }) |
| 9709 | |
| 9710 | testCases = append(testCases, testCase{ |
| 9711 | name: "UnnecessaryHelloRetryRequest", |
| 9712 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9713 | MaxVersion: VersionTLS13, |
| 9714 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9715 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9716 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9717 | }, |
| 9718 | }, |
| 9719 | shouldFail: true, |
| 9720 | expectedError: ":WRONG_CURVE:", |
| 9721 | }) |
| 9722 | |
| 9723 | testCases = append(testCases, testCase{ |
| 9724 | name: "SecondHelloRetryRequest", |
| 9725 | config: Config{ |
| 9726 | MaxVersion: VersionTLS13, |
| 9727 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9728 | CurvePreferences: []CurveID{CurveP384}, |
| 9729 | Bugs: ProtocolBugs{ |
| 9730 | SecondHelloRetryRequest: true, |
| 9731 | }, |
| 9732 | }, |
| 9733 | shouldFail: true, |
| 9734 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9735 | }) |
| 9736 | |
| 9737 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 9738 | name: "HelloRetryRequest-Empty", |
| 9739 | config: Config{ |
| 9740 | MaxVersion: VersionTLS13, |
| 9741 | Bugs: ProtocolBugs{ |
| 9742 | AlwaysSendHelloRetryRequest: true, |
| 9743 | }, |
| 9744 | }, |
| 9745 | shouldFail: true, |
| 9746 | expectedError: ":DECODE_ERROR:", |
| 9747 | }) |
| 9748 | |
| 9749 | testCases = append(testCases, testCase{ |
| 9750 | name: "HelloRetryRequest-DuplicateCurve", |
| 9751 | config: Config{ |
| 9752 | MaxVersion: VersionTLS13, |
| 9753 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 9754 | // configuration. Assert this ExpectMissingKeyShare. |
| 9755 | CurvePreferences: []CurveID{CurveP384}, |
| 9756 | Bugs: ProtocolBugs{ |
| 9757 | ExpectMissingKeyShare: true, |
| 9758 | DuplicateHelloRetryRequestExtensions: true, |
| 9759 | }, |
| 9760 | }, |
| 9761 | shouldFail: true, |
| 9762 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9763 | expectedLocalError: "remote error: illegal parameter", |
| 9764 | }) |
| 9765 | |
| 9766 | testCases = append(testCases, testCase{ |
| 9767 | name: "HelloRetryRequest-Cookie", |
| 9768 | config: Config{ |
| 9769 | MaxVersion: VersionTLS13, |
| 9770 | Bugs: ProtocolBugs{ |
| 9771 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9772 | }, |
| 9773 | }, |
| 9774 | }) |
| 9775 | |
| 9776 | testCases = append(testCases, testCase{ |
| 9777 | name: "HelloRetryRequest-DuplicateCookie", |
| 9778 | config: Config{ |
| 9779 | MaxVersion: VersionTLS13, |
| 9780 | Bugs: ProtocolBugs{ |
| 9781 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9782 | DuplicateHelloRetryRequestExtensions: true, |
| 9783 | }, |
| 9784 | }, |
| 9785 | shouldFail: true, |
| 9786 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9787 | expectedLocalError: "remote error: illegal parameter", |
| 9788 | }) |
| 9789 | |
| 9790 | testCases = append(testCases, testCase{ |
| 9791 | name: "HelloRetryRequest-EmptyCookie", |
| 9792 | config: Config{ |
| 9793 | MaxVersion: VersionTLS13, |
| 9794 | Bugs: ProtocolBugs{ |
| 9795 | SendHelloRetryRequestCookie: []byte{}, |
| 9796 | }, |
| 9797 | }, |
| 9798 | shouldFail: true, |
| 9799 | expectedError: ":DECODE_ERROR:", |
| 9800 | }) |
| 9801 | |
| 9802 | testCases = append(testCases, testCase{ |
| 9803 | name: "HelloRetryRequest-Cookie-Curve", |
| 9804 | config: Config{ |
| 9805 | MaxVersion: VersionTLS13, |
| 9806 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9807 | CurvePreferences: []CurveID{CurveP384}, |
| 9808 | Bugs: ProtocolBugs{ |
| 9809 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 9810 | ExpectMissingKeyShare: true, |
| 9811 | }, |
| 9812 | }, |
| 9813 | }) |
| 9814 | |
| 9815 | testCases = append(testCases, testCase{ |
| 9816 | name: "HelloRetryRequest-Unknown", |
| 9817 | config: Config{ |
| 9818 | MaxVersion: VersionTLS13, |
| 9819 | Bugs: ProtocolBugs{ |
| 9820 | CustomHelloRetryRequestExtension: "extension", |
| 9821 | }, |
| 9822 | }, |
| 9823 | shouldFail: true, |
| 9824 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9825 | expectedLocalError: "remote error: unsupported extension", |
| 9826 | }) |
| 9827 | |
| 9828 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9829 | testType: serverTest, |
| 9830 | name: "SecondClientHelloMissingKeyShare", |
| 9831 | config: Config{ |
| 9832 | MaxVersion: VersionTLS13, |
| 9833 | DefaultCurves: []CurveID{}, |
| 9834 | Bugs: ProtocolBugs{ |
| 9835 | SecondClientHelloMissingKeyShare: true, |
| 9836 | }, |
| 9837 | }, |
| 9838 | shouldFail: true, |
| 9839 | expectedError: ":MISSING_KEY_SHARE:", |
| 9840 | }) |
| 9841 | |
| 9842 | testCases = append(testCases, testCase{ |
| 9843 | testType: serverTest, |
| 9844 | name: "SecondClientHelloWrongCurve", |
| 9845 | config: Config{ |
| 9846 | MaxVersion: VersionTLS13, |
| 9847 | DefaultCurves: []CurveID{}, |
| 9848 | Bugs: ProtocolBugs{ |
| 9849 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 9850 | }, |
| 9851 | }, |
| 9852 | shouldFail: true, |
| 9853 | expectedError: ":WRONG_CURVE:", |
| 9854 | }) |
| 9855 | |
| 9856 | testCases = append(testCases, testCase{ |
| 9857 | name: "HelloRetryRequestVersionMismatch", |
| 9858 | config: Config{ |
| 9859 | MaxVersion: VersionTLS13, |
| 9860 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9861 | CurvePreferences: []CurveID{CurveP384}, |
| 9862 | Bugs: ProtocolBugs{ |
| 9863 | SendServerHelloVersion: 0x0305, |
| 9864 | }, |
| 9865 | }, |
| 9866 | shouldFail: true, |
| 9867 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 9868 | }) |
| 9869 | |
| 9870 | testCases = append(testCases, testCase{ |
| 9871 | name: "HelloRetryRequestCurveMismatch", |
| 9872 | config: Config{ |
| 9873 | MaxVersion: VersionTLS13, |
| 9874 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9875 | CurvePreferences: []CurveID{CurveP384}, |
| 9876 | Bugs: ProtocolBugs{ |
| 9877 | // Send P-384 (correct) in the HelloRetryRequest. |
| 9878 | SendHelloRetryRequestCurve: CurveP384, |
| 9879 | // But send P-256 in the ServerHello. |
| 9880 | SendCurve: CurveP256, |
| 9881 | }, |
| 9882 | }, |
| 9883 | shouldFail: true, |
| 9884 | expectedError: ":WRONG_CURVE:", |
| 9885 | }) |
| 9886 | |
| 9887 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 9888 | // without sending it. |
| 9889 | testCases = append(testCases, testCase{ |
| 9890 | name: "SkipHelloRetryRequest", |
| 9891 | config: Config{ |
| 9892 | MaxVersion: VersionTLS13, |
| 9893 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 9894 | CurvePreferences: []CurveID{CurveP384}, |
| 9895 | Bugs: ProtocolBugs{ |
| 9896 | SkipHelloRetryRequest: true, |
| 9897 | }, |
| 9898 | }, |
| 9899 | shouldFail: true, |
| 9900 | expectedError: ":WRONG_CURVE:", |
| 9901 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 9902 | |
| 9903 | testCases = append(testCases, testCase{ |
| 9904 | name: "TLS13-RequestContextInHandshake", |
| 9905 | config: Config{ |
| 9906 | MaxVersion: VersionTLS13, |
| 9907 | MinVersion: VersionTLS13, |
| 9908 | ClientAuth: RequireAnyClientCert, |
| 9909 | Bugs: ProtocolBugs{ |
| 9910 | SendRequestContext: []byte("request context"), |
| 9911 | }, |
| 9912 | }, |
| 9913 | flags: []string{ |
| 9914 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 9915 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 9916 | }, |
| 9917 | shouldFail: true, |
| 9918 | expectedError: ":DECODE_ERROR:", |
| 9919 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9920 | |
| 9921 | testCases = append(testCases, testCase{ |
| 9922 | testType: serverTest, |
| 9923 | name: "TLS13-TrailingKeyShareData", |
| 9924 | config: Config{ |
| 9925 | MaxVersion: VersionTLS13, |
| 9926 | Bugs: ProtocolBugs{ |
| 9927 | TrailingKeyShareData: true, |
| 9928 | }, |
| 9929 | }, |
| 9930 | shouldFail: true, |
| 9931 | expectedError: ":DECODE_ERROR:", |
| 9932 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 9933 | |
| 9934 | testCases = append(testCases, testCase{ |
| 9935 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 9936 | config: Config{ |
| 9937 | MaxVersion: VersionTLS13, |
| 9938 | Bugs: ProtocolBugs{ |
| 9939 | AlwaysSelectPSKIdentity: true, |
| 9940 | }, |
| 9941 | }, |
| 9942 | shouldFail: true, |
| 9943 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9944 | }) |
| 9945 | |
| 9946 | testCases = append(testCases, testCase{ |
| 9947 | name: "TLS13-InvalidPSKIdentity", |
| 9948 | config: Config{ |
| 9949 | MaxVersion: VersionTLS13, |
| 9950 | Bugs: ProtocolBugs{ |
| 9951 | SelectPSKIdentityOnResume: 1, |
| 9952 | }, |
| 9953 | }, |
| 9954 | resumeSession: true, |
| 9955 | shouldFail: true, |
| 9956 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 9957 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9958 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9959 | testCases = append(testCases, testCase{ |
| 9960 | testType: serverTest, |
| 9961 | name: "TLS13-ExtraPSKIdentity", |
| 9962 | config: Config{ |
| 9963 | MaxVersion: VersionTLS13, |
| 9964 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 9965 | ExtraPSKIdentity: true, |
| 9966 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 9967 | }, |
| 9968 | }, |
| 9969 | resumeSession: true, |
| 9970 | }) |
| 9971 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 9972 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 9973 | testCases = append(testCases, testCase{ |
| 9974 | name: "TLS13-CustomTicketExtension", |
| 9975 | config: Config{ |
| 9976 | MaxVersion: VersionTLS13, |
| 9977 | Bugs: ProtocolBugs{ |
| 9978 | CustomTicketExtension: "1234", |
| 9979 | }, |
| 9980 | }, |
| 9981 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 9982 | |
| 9983 | // Test that we accept data-less early data. |
| 9984 | testCases = append(testCases, testCase{ |
| 9985 | testType: serverTest, |
| 9986 | name: "TLS13-DataLessEarlyData-Server", |
| 9987 | config: Config{ |
| 9988 | MaxVersion: VersionTLS13, |
| 9989 | Bugs: ProtocolBugs{ |
| 9990 | SendEarlyData: [][]byte{}, |
| 9991 | ExpectEarlyDataAccepted: true, |
| 9992 | }, |
| 9993 | }, |
| 9994 | resumeSession: true, |
| 9995 | flags: []string{ |
| 9996 | "-enable-early-data", |
| 9997 | "-expect-accept-early-data", |
| 9998 | }, |
| 9999 | }) |
| 10000 | |
| 10001 | testCases = append(testCases, testCase{ |
| 10002 | testType: clientTest, |
| 10003 | name: "TLS13-DataLessEarlyData-Client", |
| 10004 | config: Config{ |
| 10005 | MaxVersion: VersionTLS13, |
| 10006 | MaxEarlyDataSize: 16384, |
| 10007 | }, |
| 10008 | resumeSession: true, |
| 10009 | flags: []string{ |
| 10010 | "-enable-early-data", |
| 10011 | "-expect-early-data-info", |
| 10012 | "-expect-accept-early-data", |
| 10013 | }, |
| 10014 | }) |
| 10015 | |
| 10016 | testCases = append(testCases, testCase{ |
| 10017 | testType: clientTest, |
| 10018 | name: "TLS13-DataLessEarlyData-Reject-Client", |
| 10019 | config: Config{ |
| 10020 | MaxVersion: VersionTLS13, |
| 10021 | MaxEarlyDataSize: 16384, |
| 10022 | }, |
| 10023 | resumeConfig: &Config{ |
| 10024 | MaxVersion: VersionTLS13, |
| 10025 | MaxEarlyDataSize: 16384, |
| 10026 | Bugs: ProtocolBugs{ |
| 10027 | AlwaysRejectEarlyData: true, |
| 10028 | }, |
| 10029 | }, |
| 10030 | resumeSession: true, |
| 10031 | flags: []string{ |
| 10032 | "-enable-early-data", |
| 10033 | "-expect-early-data-info", |
| 10034 | "-expect-reject-early-data", |
| 10035 | }, |
| 10036 | }) |
| 10037 | |
| 10038 | testCases = append(testCases, testCase{ |
| 10039 | testType: clientTest, |
| 10040 | name: "TLS13-DataLessEarlyData-HRR-Client", |
| 10041 | config: Config{ |
| 10042 | MaxVersion: VersionTLS13, |
| 10043 | MaxEarlyDataSize: 16384, |
| 10044 | }, |
| 10045 | resumeConfig: &Config{ |
| 10046 | MaxVersion: VersionTLS13, |
| 10047 | MaxEarlyDataSize: 16384, |
| 10048 | Bugs: ProtocolBugs{ |
| 10049 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 10050 | }, |
| 10051 | }, |
| 10052 | resumeSession: true, |
| 10053 | flags: []string{ |
| 10054 | "-enable-early-data", |
| 10055 | "-expect-early-data-info", |
| 10056 | "-expect-reject-early-data", |
| 10057 | }, |
| 10058 | }) |
| 10059 | |
| 10060 | // The client must check the server does not send the early_data |
| 10061 | // extension while rejecting the session. |
| 10062 | testCases = append(testCases, testCase{ |
| 10063 | testType: clientTest, |
| 10064 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 10065 | config: Config{ |
| 10066 | MaxVersion: VersionTLS13, |
| 10067 | MaxEarlyDataSize: 16384, |
| 10068 | }, |
| 10069 | resumeConfig: &Config{ |
| 10070 | MaxVersion: VersionTLS13, |
| 10071 | SessionTicketsDisabled: true, |
| 10072 | Bugs: ProtocolBugs{ |
| 10073 | SendEarlyDataExtension: true, |
| 10074 | }, |
| 10075 | }, |
| 10076 | resumeSession: true, |
| 10077 | flags: []string{ |
| 10078 | "-enable-early-data", |
| 10079 | "-expect-early-data-info", |
| 10080 | }, |
| 10081 | shouldFail: true, |
| 10082 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10083 | }) |
| 10084 | |
| 10085 | // The client must fail with a dedicated error code if the server |
| 10086 | // responds with TLS 1.2 when offering 0-RTT. |
| 10087 | testCases = append(testCases, testCase{ |
| 10088 | testType: clientTest, |
| 10089 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 10090 | config: Config{ |
| 10091 | MaxVersion: VersionTLS13, |
| 10092 | MaxEarlyDataSize: 16384, |
| 10093 | }, |
| 10094 | resumeConfig: &Config{ |
| 10095 | MaxVersion: VersionTLS12, |
| 10096 | }, |
| 10097 | resumeSession: true, |
| 10098 | flags: []string{ |
| 10099 | "-enable-early-data", |
| 10100 | "-expect-early-data-info", |
| 10101 | }, |
| 10102 | shouldFail: true, |
| 10103 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 10104 | }) |
| 10105 | |
| 10106 | // Test that the client rejects an (unsolicited) early_data extension if |
| 10107 | // the server sent an HRR. |
| 10108 | testCases = append(testCases, testCase{ |
| 10109 | testType: clientTest, |
| 10110 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 10111 | config: Config{ |
| 10112 | MaxVersion: VersionTLS13, |
| 10113 | MaxEarlyDataSize: 16384, |
| 10114 | }, |
| 10115 | resumeConfig: &Config{ |
| 10116 | MaxVersion: VersionTLS13, |
| 10117 | MaxEarlyDataSize: 16384, |
| 10118 | Bugs: ProtocolBugs{ |
| 10119 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 10120 | SendEarlyDataExtension: true, |
| 10121 | }, |
| 10122 | }, |
| 10123 | resumeSession: true, |
| 10124 | flags: []string{ |
| 10125 | "-enable-early-data", |
| 10126 | "-expect-early-data-info", |
| 10127 | }, |
| 10128 | shouldFail: true, |
| 10129 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10130 | }) |
| 10131 | |
| 10132 | fooString := "foo" |
| 10133 | barString := "bar" |
| 10134 | |
| 10135 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 10136 | // that changed it. |
| 10137 | testCases = append(testCases, testCase{ |
| 10138 | testType: clientTest, |
| 10139 | name: "TLS13-DataLessEarlyData-ALPNMismatch-Client", |
| 10140 | config: Config{ |
| 10141 | MaxVersion: VersionTLS13, |
| 10142 | MaxEarlyDataSize: 16384, |
| 10143 | Bugs: ProtocolBugs{ |
| 10144 | ALPNProtocol: &fooString, |
| 10145 | }, |
| 10146 | }, |
| 10147 | resumeConfig: &Config{ |
| 10148 | MaxVersion: VersionTLS13, |
| 10149 | MaxEarlyDataSize: 16384, |
| 10150 | Bugs: ProtocolBugs{ |
| 10151 | ALPNProtocol: &barString, |
| 10152 | }, |
| 10153 | }, |
| 10154 | resumeSession: true, |
| 10155 | flags: []string{ |
| 10156 | "-advertise-alpn", "\x03foo\x03bar", |
| 10157 | "-enable-early-data", |
| 10158 | "-expect-early-data-info", |
| 10159 | "-expect-reject-early-data", |
| 10160 | "-expect-alpn", "foo", |
| 10161 | "-expect-resume-alpn", "bar", |
| 10162 | }, |
| 10163 | }) |
| 10164 | |
| 10165 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 10166 | // ALPN was omitted from the first connection. |
| 10167 | testCases = append(testCases, testCase{ |
| 10168 | testType: clientTest, |
| 10169 | name: "TLS13-DataLessEarlyData-ALPNOmitted1-Client", |
| 10170 | config: Config{ |
| 10171 | MaxVersion: VersionTLS13, |
| 10172 | MaxEarlyDataSize: 16384, |
| 10173 | }, |
| 10174 | resumeConfig: &Config{ |
| 10175 | MaxVersion: VersionTLS13, |
| 10176 | MaxEarlyDataSize: 16384, |
| 10177 | NextProtos: []string{"foo"}, |
| 10178 | }, |
| 10179 | resumeSession: true, |
| 10180 | flags: []string{ |
| 10181 | "-advertise-alpn", "\x03foo\x03bar", |
| 10182 | "-enable-early-data", |
| 10183 | "-expect-early-data-info", |
| 10184 | "-expect-reject-early-data", |
| 10185 | "-expect-no-alpn", |
| 10186 | "-expect-resume-alpn", "foo", |
| 10187 | }, |
| 10188 | }) |
| 10189 | |
| 10190 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 10191 | // ALPN was omitted from the second connection. |
| 10192 | testCases = append(testCases, testCase{ |
| 10193 | testType: clientTest, |
| 10194 | name: "TLS13-DataLessEarlyData-ALPNOmitted2-Client", |
| 10195 | config: Config{ |
| 10196 | MaxVersion: VersionTLS13, |
| 10197 | MaxEarlyDataSize: 16384, |
| 10198 | NextProtos: []string{"foo"}, |
| 10199 | }, |
| 10200 | resumeConfig: &Config{ |
| 10201 | MaxVersion: VersionTLS13, |
| 10202 | MaxEarlyDataSize: 16384, |
| 10203 | }, |
| 10204 | resumeSession: true, |
| 10205 | flags: []string{ |
| 10206 | "-advertise-alpn", "\x03foo\x03bar", |
| 10207 | "-enable-early-data", |
| 10208 | "-expect-early-data-info", |
| 10209 | "-expect-reject-early-data", |
| 10210 | "-expect-alpn", "foo", |
| 10211 | "-expect-no-resume-alpn", |
| 10212 | }, |
| 10213 | }) |
| 10214 | |
| 10215 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 10216 | testCases = append(testCases, testCase{ |
| 10217 | testType: clientTest, |
| 10218 | name: "TLS13-DataLessEarlyData-BadALPNMismatch-Client", |
| 10219 | config: Config{ |
| 10220 | MaxVersion: VersionTLS13, |
| 10221 | MaxEarlyDataSize: 16384, |
| 10222 | Bugs: ProtocolBugs{ |
| 10223 | ALPNProtocol: &fooString, |
| 10224 | }, |
| 10225 | }, |
| 10226 | resumeConfig: &Config{ |
| 10227 | MaxVersion: VersionTLS13, |
| 10228 | MaxEarlyDataSize: 16384, |
| 10229 | Bugs: ProtocolBugs{ |
| 10230 | AlwaysAcceptEarlyData: true, |
| 10231 | ALPNProtocol: &barString, |
| 10232 | }, |
| 10233 | }, |
| 10234 | resumeSession: true, |
| 10235 | flags: []string{ |
| 10236 | "-advertise-alpn", "\x03foo\x03bar", |
| 10237 | "-enable-early-data", |
| 10238 | "-expect-early-data-info", |
| 10239 | }, |
| 10240 | shouldFail: true, |
| 10241 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 10242 | }) |
| 10243 | |
| 10244 | // Test that the server correctly rejects 0-RTT when the previous |
| 10245 | // session did not allow early data on resumption. |
| 10246 | testCases = append(testCases, testCase{ |
| 10247 | testType: serverTest, |
| 10248 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 10249 | config: Config{ |
| 10250 | MaxVersion: VersionTLS13, |
| 10251 | }, |
| 10252 | resumeConfig: &Config{ |
| 10253 | MaxVersion: VersionTLS13, |
| 10254 | Bugs: ProtocolBugs{ |
| 10255 | SendEarlyData: [][]byte{{}}, |
| 10256 | ExpectEarlyDataAccepted: false, |
| 10257 | }, |
| 10258 | }, |
| 10259 | resumeSession: true, |
| 10260 | flags: []string{ |
| 10261 | "-enable-resume-early-data", |
| 10262 | "-expect-reject-early-data", |
| 10263 | }, |
| 10264 | }) |
| 10265 | |
| 10266 | // Test that we reject early data where ALPN is omitted from the first |
| 10267 | // connection. |
| 10268 | testCases = append(testCases, testCase{ |
| 10269 | testType: serverTest, |
| 10270 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 10271 | config: Config{ |
| 10272 | MaxVersion: VersionTLS13, |
| 10273 | NextProtos: []string{}, |
| 10274 | }, |
| 10275 | resumeConfig: &Config{ |
| 10276 | MaxVersion: VersionTLS13, |
| 10277 | NextProtos: []string{"foo"}, |
| 10278 | Bugs: ProtocolBugs{ |
| 10279 | SendEarlyData: [][]byte{{}}, |
| 10280 | ExpectEarlyDataAccepted: false, |
| 10281 | }, |
| 10282 | }, |
| 10283 | resumeSession: true, |
| 10284 | flags: []string{ |
| 10285 | "-enable-early-data", |
| 10286 | "-select-alpn", "", |
| 10287 | "-select-resume-alpn", "foo", |
| 10288 | }, |
| 10289 | }) |
| 10290 | |
| 10291 | // Test that we reject early data where ALPN is omitted from the second |
| 10292 | // connection. |
| 10293 | testCases = append(testCases, testCase{ |
| 10294 | testType: serverTest, |
| 10295 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 10296 | config: Config{ |
| 10297 | MaxVersion: VersionTLS13, |
| 10298 | NextProtos: []string{"foo"}, |
| 10299 | }, |
| 10300 | resumeConfig: &Config{ |
| 10301 | MaxVersion: VersionTLS13, |
| 10302 | NextProtos: []string{}, |
| 10303 | Bugs: ProtocolBugs{ |
| 10304 | SendEarlyData: [][]byte{{}}, |
| 10305 | ExpectEarlyDataAccepted: false, |
| 10306 | }, |
| 10307 | }, |
| 10308 | resumeSession: true, |
| 10309 | flags: []string{ |
| 10310 | "-enable-early-data", |
| 10311 | "-select-alpn", "foo", |
| 10312 | "-select-resume-alpn", "", |
| 10313 | }, |
| 10314 | }) |
| 10315 | |
| 10316 | // Test that we reject early data with mismatched ALPN. |
| 10317 | testCases = append(testCases, testCase{ |
| 10318 | testType: serverTest, |
| 10319 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 10320 | config: Config{ |
| 10321 | MaxVersion: VersionTLS13, |
| 10322 | NextProtos: []string{"foo"}, |
| 10323 | }, |
| 10324 | resumeConfig: &Config{ |
| 10325 | MaxVersion: VersionTLS13, |
| 10326 | NextProtos: []string{"bar"}, |
| 10327 | Bugs: ProtocolBugs{ |
| 10328 | SendEarlyData: [][]byte{{}}, |
| 10329 | ExpectEarlyDataAccepted: false, |
| 10330 | }, |
| 10331 | }, |
| 10332 | resumeSession: true, |
| 10333 | flags: []string{ |
| 10334 | "-enable-early-data", |
| 10335 | "-select-alpn", "foo", |
| 10336 | "-select-resume-alpn", "bar", |
| 10337 | }, |
| 10338 | }) |
| 10339 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame^] | 10340 | // Test that we fail on early data with Channel ID. |
| 10341 | testCases = append(testCases, testCase{ |
| 10342 | testType: clientTest, |
| 10343 | name: "TLS13-EarlyData-ChannelID-Client", |
| 10344 | config: Config{ |
| 10345 | MaxVersion: VersionTLS13, |
| 10346 | MaxEarlyDataSize: 16384, |
| 10347 | RequestChannelID: true, |
| 10348 | }, |
| 10349 | resumeSession: true, |
| 10350 | expectChannelID: true, |
| 10351 | shouldFail: true, |
| 10352 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 10353 | flags: []string{ |
| 10354 | "-enable-early-data", |
| 10355 | "-expect-early-data-info", |
| 10356 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 10357 | }, |
| 10358 | }) |
| 10359 | |
| 10360 | testCases = append(testCases, testCase{ |
| 10361 | testType: serverTest, |
| 10362 | name: "TLS13-EarlyData-ChannelID-Server", |
| 10363 | config: Config{ |
| 10364 | MaxVersion: VersionTLS13, |
| 10365 | ChannelID: channelIDKey, |
| 10366 | Bugs: ProtocolBugs{ |
| 10367 | SendEarlyData: [][]byte{{}}, |
| 10368 | ExpectEarlyDataAccepted: false, |
| 10369 | }, |
| 10370 | }, |
| 10371 | resumeSession: true, |
| 10372 | expectChannelID: true, |
| 10373 | flags: []string{ |
| 10374 | "-enable-early-data", |
| 10375 | "-expect-reject-early-data", |
| 10376 | "-expect-channel-id", |
| 10377 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 10378 | }, |
| 10379 | }) |
| 10380 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10381 | } |
| 10382 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 10383 | func addTLS13CipherPreferenceTests() { |
| 10384 | // Test that client preference is honored if the shim has AES hardware |
| 10385 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 10386 | testCases = append(testCases, testCase{ |
| 10387 | testType: serverTest, |
| 10388 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 10389 | config: Config{ |
| 10390 | MaxVersion: VersionTLS13, |
| 10391 | CipherSuites: []uint16{ |
| 10392 | TLS_CHACHA20_POLY1305_SHA256, |
| 10393 | TLS_AES_128_GCM_SHA256, |
| 10394 | }, |
| 10395 | }, |
| 10396 | flags: []string{ |
| 10397 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10398 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10399 | }, |
| 10400 | }) |
| 10401 | |
| 10402 | testCases = append(testCases, testCase{ |
| 10403 | testType: serverTest, |
| 10404 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 10405 | config: Config{ |
| 10406 | MaxVersion: VersionTLS13, |
| 10407 | CipherSuites: []uint16{ |
| 10408 | TLS_AES_128_GCM_SHA256, |
| 10409 | TLS_CHACHA20_POLY1305_SHA256, |
| 10410 | }, |
| 10411 | }, |
| 10412 | flags: []string{ |
| 10413 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 10414 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10415 | }, |
| 10416 | }) |
| 10417 | |
| 10418 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 10419 | // whether it has AES hardware. |
| 10420 | testCases = append(testCases, testCase{ |
| 10421 | name: "TLS13-CipherPreference-Client", |
| 10422 | config: Config{ |
| 10423 | MaxVersion: VersionTLS13, |
| 10424 | // Use the client cipher order. (This is the default but |
| 10425 | // is listed to be explicit.) |
| 10426 | PreferServerCipherSuites: false, |
| 10427 | }, |
| 10428 | flags: []string{ |
| 10429 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 10430 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10431 | }, |
| 10432 | }) |
| 10433 | } |
| 10434 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10435 | func addPeekTests() { |
| 10436 | // Test SSL_peek works, including on empty records. |
| 10437 | testCases = append(testCases, testCase{ |
| 10438 | name: "Peek-Basic", |
| 10439 | sendEmptyRecords: 1, |
| 10440 | flags: []string{"-peek-then-read"}, |
| 10441 | }) |
| 10442 | |
| 10443 | // Test SSL_peek can drive the initial handshake. |
| 10444 | testCases = append(testCases, testCase{ |
| 10445 | name: "Peek-ImplicitHandshake", |
| 10446 | flags: []string{ |
| 10447 | "-peek-then-read", |
| 10448 | "-implicit-handshake", |
| 10449 | }, |
| 10450 | }) |
| 10451 | |
| 10452 | // Test SSL_peek can discover and drive a renegotiation. |
| 10453 | testCases = append(testCases, testCase{ |
| 10454 | name: "Peek-Renegotiate", |
| 10455 | config: Config{ |
| 10456 | MaxVersion: VersionTLS12, |
| 10457 | }, |
| 10458 | renegotiate: 1, |
| 10459 | flags: []string{ |
| 10460 | "-peek-then-read", |
| 10461 | "-renegotiate-freely", |
| 10462 | "-expect-total-renegotiations", "1", |
| 10463 | }, |
| 10464 | }) |
| 10465 | |
| 10466 | // Test SSL_peek can discover a close_notify. |
| 10467 | testCases = append(testCases, testCase{ |
| 10468 | name: "Peek-Shutdown", |
| 10469 | config: Config{ |
| 10470 | Bugs: ProtocolBugs{ |
| 10471 | ExpectCloseNotify: true, |
| 10472 | }, |
| 10473 | }, |
| 10474 | flags: []string{ |
| 10475 | "-peek-then-read", |
| 10476 | "-check-close-notify", |
| 10477 | }, |
| 10478 | }) |
| 10479 | |
| 10480 | // Test SSL_peek can discover an alert. |
| 10481 | testCases = append(testCases, testCase{ |
| 10482 | name: "Peek-Alert", |
| 10483 | config: Config{ |
| 10484 | Bugs: ProtocolBugs{ |
| 10485 | SendSpuriousAlert: alertRecordOverflow, |
| 10486 | }, |
| 10487 | }, |
| 10488 | flags: []string{"-peek-then-read"}, |
| 10489 | shouldFail: true, |
| 10490 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 10491 | }) |
| 10492 | |
| 10493 | // Test SSL_peek can handle KeyUpdate. |
| 10494 | testCases = append(testCases, testCase{ |
| 10495 | name: "Peek-KeyUpdate", |
| 10496 | config: Config{ |
| 10497 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10498 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 10499 | sendKeyUpdates: 1, |
| 10500 | keyUpdateRequest: keyUpdateNotRequested, |
| 10501 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10502 | }) |
| 10503 | } |
| 10504 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 10505 | func addRecordVersionTests() { |
| 10506 | for _, ver := range tlsVersions { |
| 10507 | // Test that the record version is enforced. |
| 10508 | testCases = append(testCases, testCase{ |
| 10509 | name: "CheckRecordVersion-" + ver.name, |
| 10510 | config: Config{ |
| 10511 | MinVersion: ver.version, |
| 10512 | MaxVersion: ver.version, |
| 10513 | Bugs: ProtocolBugs{ |
| 10514 | SendRecordVersion: 0x03ff, |
| 10515 | }, |
| 10516 | }, |
| 10517 | shouldFail: true, |
| 10518 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10519 | }) |
| 10520 | |
| 10521 | // Test that the ClientHello may use any record version, for |
| 10522 | // compatibility reasons. |
| 10523 | testCases = append(testCases, testCase{ |
| 10524 | testType: serverTest, |
| 10525 | name: "LooseInitialRecordVersion-" + ver.name, |
| 10526 | config: Config{ |
| 10527 | MinVersion: ver.version, |
| 10528 | MaxVersion: ver.version, |
| 10529 | Bugs: ProtocolBugs{ |
| 10530 | SendInitialRecordVersion: 0x03ff, |
| 10531 | }, |
| 10532 | }, |
| 10533 | }) |
| 10534 | |
| 10535 | // Test that garbage ClientHello record versions are rejected. |
| 10536 | testCases = append(testCases, testCase{ |
| 10537 | testType: serverTest, |
| 10538 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 10539 | config: Config{ |
| 10540 | MinVersion: ver.version, |
| 10541 | MaxVersion: ver.version, |
| 10542 | Bugs: ProtocolBugs{ |
| 10543 | SendInitialRecordVersion: 0xffff, |
| 10544 | }, |
| 10545 | }, |
| 10546 | shouldFail: true, |
| 10547 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10548 | }) |
| 10549 | } |
| 10550 | } |
| 10551 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10552 | func addCertificateTests() { |
| 10553 | // Test that a certificate chain with intermediate may be sent and |
| 10554 | // received as both client and server. |
| 10555 | for _, ver := range tlsVersions { |
| 10556 | testCases = append(testCases, testCase{ |
| 10557 | testType: clientTest, |
| 10558 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 10559 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 10560 | MinVersion: ver.version, |
| 10561 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10562 | Certificates: []Certificate{rsaChainCertificate}, |
| 10563 | ClientAuth: RequireAnyClientCert, |
| 10564 | }, |
| 10565 | expectPeerCertificate: &rsaChainCertificate, |
| 10566 | flags: []string{ |
| 10567 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10568 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 10569 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10570 | }, |
| 10571 | }) |
| 10572 | |
| 10573 | testCases = append(testCases, testCase{ |
| 10574 | testType: serverTest, |
| 10575 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 10576 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 10577 | MinVersion: ver.version, |
| 10578 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10579 | Certificates: []Certificate{rsaChainCertificate}, |
| 10580 | }, |
| 10581 | expectPeerCertificate: &rsaChainCertificate, |
| 10582 | flags: []string{ |
| 10583 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10584 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 10585 | "-require-any-client-certificate", |
| 10586 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 10587 | }, |
| 10588 | }) |
| 10589 | } |
| 10590 | } |
| 10591 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 10592 | func addRetainOnlySHA256ClientCertTests() { |
| 10593 | for _, ver := range tlsVersions { |
| 10594 | // Test that enabling |
| 10595 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 10596 | // actually requesting a client certificate is a no-op. |
| 10597 | testCases = append(testCases, testCase{ |
| 10598 | testType: serverTest, |
| 10599 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 10600 | config: Config{ |
| 10601 | MinVersion: ver.version, |
| 10602 | MaxVersion: ver.version, |
| 10603 | }, |
| 10604 | flags: []string{ |
| 10605 | "-retain-only-sha256-client-cert-initial", |
| 10606 | "-retain-only-sha256-client-cert-resume", |
| 10607 | }, |
| 10608 | resumeSession: true, |
| 10609 | }) |
| 10610 | |
| 10611 | // Test that when retaining only a SHA-256 certificate is |
| 10612 | // enabled, the hash appears as expected. |
| 10613 | testCases = append(testCases, testCase{ |
| 10614 | testType: serverTest, |
| 10615 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 10616 | config: Config{ |
| 10617 | MinVersion: ver.version, |
| 10618 | MaxVersion: ver.version, |
| 10619 | Certificates: []Certificate{rsaCertificate}, |
| 10620 | }, |
| 10621 | flags: []string{ |
| 10622 | "-verify-peer", |
| 10623 | "-retain-only-sha256-client-cert-initial", |
| 10624 | "-retain-only-sha256-client-cert-resume", |
| 10625 | "-expect-sha256-client-cert-initial", |
| 10626 | "-expect-sha256-client-cert-resume", |
| 10627 | }, |
| 10628 | resumeSession: true, |
| 10629 | }) |
| 10630 | |
| 10631 | // Test that when the config changes from on to off, a |
| 10632 | // resumption is rejected because the server now wants the full |
| 10633 | // certificate chain. |
| 10634 | testCases = append(testCases, testCase{ |
| 10635 | testType: serverTest, |
| 10636 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 10637 | config: Config{ |
| 10638 | MinVersion: ver.version, |
| 10639 | MaxVersion: ver.version, |
| 10640 | Certificates: []Certificate{rsaCertificate}, |
| 10641 | }, |
| 10642 | flags: []string{ |
| 10643 | "-verify-peer", |
| 10644 | "-retain-only-sha256-client-cert-initial", |
| 10645 | "-expect-sha256-client-cert-initial", |
| 10646 | }, |
| 10647 | resumeSession: true, |
| 10648 | expectResumeRejected: true, |
| 10649 | }) |
| 10650 | |
| 10651 | // Test that when the config changes from off to on, a |
| 10652 | // resumption is rejected because the server now wants just the |
| 10653 | // hash. |
| 10654 | testCases = append(testCases, testCase{ |
| 10655 | testType: serverTest, |
| 10656 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 10657 | config: Config{ |
| 10658 | MinVersion: ver.version, |
| 10659 | MaxVersion: ver.version, |
| 10660 | Certificates: []Certificate{rsaCertificate}, |
| 10661 | }, |
| 10662 | flags: []string{ |
| 10663 | "-verify-peer", |
| 10664 | "-retain-only-sha256-client-cert-resume", |
| 10665 | "-expect-sha256-client-cert-resume", |
| 10666 | }, |
| 10667 | resumeSession: true, |
| 10668 | expectResumeRejected: true, |
| 10669 | }) |
| 10670 | } |
| 10671 | } |
| 10672 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 10673 | func addECDSAKeyUsageTests() { |
| 10674 | p256 := elliptic.P256() |
| 10675 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 10676 | if err != nil { |
| 10677 | panic(err) |
| 10678 | } |
| 10679 | |
| 10680 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 10681 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 10682 | if err != nil { |
| 10683 | panic(err) |
| 10684 | } |
| 10685 | |
| 10686 | template := x509.Certificate{ |
| 10687 | SerialNumber: serialNumber, |
| 10688 | Subject: pkix.Name{ |
| 10689 | Organization: []string{"Acme Co"}, |
| 10690 | }, |
| 10691 | NotBefore: time.Now(), |
| 10692 | NotAfter: time.Now(), |
| 10693 | |
| 10694 | // An ECC certificate with only the keyAgreement key usgae may |
| 10695 | // be used with ECDH, but not ECDSA. |
| 10696 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 10697 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 10698 | BasicConstraintsValid: true, |
| 10699 | } |
| 10700 | |
| 10701 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 10702 | if err != nil { |
| 10703 | panic(err) |
| 10704 | } |
| 10705 | |
| 10706 | cert := Certificate{ |
| 10707 | Certificate: [][]byte{derBytes}, |
| 10708 | PrivateKey: priv, |
| 10709 | } |
| 10710 | |
| 10711 | for _, ver := range tlsVersions { |
| 10712 | if ver.version < VersionTLS12 { |
| 10713 | continue |
| 10714 | } |
| 10715 | |
| 10716 | testCases = append(testCases, testCase{ |
| 10717 | testType: clientTest, |
| 10718 | name: "ECDSAKeyUsage-" + ver.name, |
| 10719 | config: Config{ |
| 10720 | MinVersion: ver.version, |
| 10721 | MaxVersion: ver.version, |
| 10722 | Certificates: []Certificate{cert}, |
| 10723 | }, |
| 10724 | shouldFail: true, |
| 10725 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 10726 | }) |
| 10727 | } |
| 10728 | } |
| 10729 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10730 | 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] | 10731 | defer wg.Done() |
| 10732 | |
| 10733 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10734 | var err error |
| 10735 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10736 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10737 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 10738 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10739 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10740 | if err != nil { |
| 10741 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 10742 | } |
| 10743 | break |
| 10744 | } |
| 10745 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10746 | } else if *repeatUntilFailure { |
| 10747 | for err == nil { |
| 10748 | statusChan <- statusMsg{test: test, started: true} |
| 10749 | err = runTest(test, shimPath, -1) |
| 10750 | } |
| 10751 | } else { |
| 10752 | statusChan <- statusMsg{test: test, started: true} |
| 10753 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 10754 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10755 | statusChan <- statusMsg{test: test, err: err} |
| 10756 | } |
| 10757 | } |
| 10758 | |
| 10759 | type statusMsg struct { |
| 10760 | test *testCase |
| 10761 | started bool |
| 10762 | err error |
| 10763 | } |
| 10764 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10765 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10766 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10767 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10768 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10769 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10770 | if !*pipe { |
| 10771 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 10772 | var erase string |
| 10773 | for i := 0; i < lineLen; i++ { |
| 10774 | erase += "\b \b" |
| 10775 | } |
| 10776 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10777 | } |
| 10778 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10779 | if msg.started { |
| 10780 | started++ |
| 10781 | } else { |
| 10782 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10783 | |
| 10784 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10785 | if msg.err == errUnimplemented { |
| 10786 | if *pipe { |
| 10787 | // Print each test instead of a status line. |
| 10788 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 10789 | } |
| 10790 | unimplemented++ |
| 10791 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 10792 | } else { |
| 10793 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 10794 | failed++ |
| 10795 | testOutput.addResult(msg.test.name, "FAIL") |
| 10796 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10797 | } else { |
| 10798 | if *pipe { |
| 10799 | // Print each test instead of a status line. |
| 10800 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 10801 | } |
| 10802 | testOutput.addResult(msg.test.name, "PASS") |
| 10803 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10804 | } |
| 10805 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10806 | if !*pipe { |
| 10807 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10808 | 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] | 10809 | lineLen = len(line) |
| 10810 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10811 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10812 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10813 | |
| 10814 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10815 | } |
| 10816 | |
| 10817 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10818 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10819 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 10820 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10821 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10822 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10823 | addCipherSuiteTests() |
| 10824 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10825 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 10826 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 10827 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 10828 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 10829 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 10830 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 10831 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 10832 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 10833 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 10834 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 10835 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 10836 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 10837 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 10838 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 10839 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 10840 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 10841 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 10842 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 10843 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 10844 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 10845 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10846 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10847 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10848 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10849 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 10850 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10851 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 10852 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 10853 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 10854 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 10855 | addECDSAKeyUsageTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10856 | |
| 10857 | var wg sync.WaitGroup |
| 10858 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10859 | statusChan := make(chan statusMsg, *numWorkers) |
| 10860 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10861 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10862 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10863 | if len(*shimConfigFile) != 0 { |
| 10864 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 10865 | if err != nil { |
| 10866 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 10867 | os.Exit(1) |
| 10868 | } |
| 10869 | |
| 10870 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 10871 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 10872 | os.Exit(1) |
| 10873 | } |
| 10874 | } |
| 10875 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10876 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10877 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10878 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10879 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 10880 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10881 | } |
| 10882 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10883 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10884 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10885 | matched := true |
| 10886 | if len(*testToRun) != 0 { |
| 10887 | var err error |
| 10888 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 10889 | if err != nil { |
| 10890 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 10891 | os.Exit(1) |
| 10892 | } |
| 10893 | } |
| 10894 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10895 | if !*includeDisabled { |
| 10896 | for pattern := range shimConfig.DisabledTests { |
| 10897 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 10898 | if err != nil { |
| 10899 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 10900 | os.Exit(1) |
| 10901 | } |
| 10902 | |
| 10903 | if isDisabled { |
| 10904 | matched = false |
| 10905 | break |
| 10906 | } |
| 10907 | } |
| 10908 | } |
| 10909 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10910 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10911 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 10912 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 10913 | |
| 10914 | // Only run one test if repeating until failure. |
| 10915 | if *repeatUntilFailure { |
| 10916 | break |
| 10917 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10918 | } |
| 10919 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 10920 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10921 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 10922 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 10923 | os.Exit(1) |
| 10924 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10925 | |
| 10926 | close(testChan) |
| 10927 | wg.Wait() |
| 10928 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10929 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10930 | |
| 10931 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 10932 | |
| 10933 | if *jsonOutput != "" { |
| 10934 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 10935 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 10936 | } |
| 10937 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10938 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 10939 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 10940 | os.Exit(1) |
| 10941 | } |
| 10942 | |
| 10943 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 10944 | os.Exit(1) |
| 10945 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 10946 | } |