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.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 68 | 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] | 69 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 70 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 71 | // ShimConfigurations is used with the “json” package and represents a shim |
| 72 | // config file. |
| 73 | type ShimConfiguration struct { |
| 74 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 75 | // The glob pattern is used to exclude tests from being run and the |
| 76 | // freeform string is unparsed but expected to explain why the test is |
| 77 | // disabled. |
| 78 | DisabledTests map[string]string |
| 79 | |
| 80 | // ErrorMap maps from expected error strings to the correct error |
| 81 | // string for the shim in question. For example, it might map |
| 82 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 83 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 84 | ErrorMap map[string]string |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 85 | |
| 86 | // HalfRTTTickets is the number of half-RTT tickets the client should |
| 87 | // expect before half-RTT data when testing 0-RTT. |
| 88 | HalfRTTTickets int |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 89 | } |
| 90 | |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 91 | // Setup shimConfig defaults aligning with BoringSSL. |
| 92 | var shimConfig ShimConfiguration = ShimConfiguration{ |
| 93 | HalfRTTTickets: 2, |
| 94 | } |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 95 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 96 | type testCert int |
| 97 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 98 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 99 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 100 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 101 | testCertRSAChain |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 102 | testCertECDSAP224 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 103 | testCertECDSAP256 |
| 104 | testCertECDSAP384 |
| 105 | testCertECDSAP521 |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 106 | testCertEd25519 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 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 | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 117 | ed25519CertificateFile = "ed25519_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 118 | ) |
| 119 | |
| 120 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 121 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 122 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 123 | rsaChainKeyFile = "rsa_chain_key.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 124 | ecdsaP224KeyFile = "ecdsa_p224_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 125 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 126 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 127 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 128 | ed25519KeyFile = "ed25519_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 129 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 130 | ) |
| 131 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 132 | var ( |
| 133 | rsaCertificate Certificate |
| 134 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 135 | rsaChainCertificate Certificate |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 136 | ecdsaP224Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | ecdsaP256Certificate Certificate |
| 138 | ecdsaP384Certificate Certificate |
| 139 | ecdsaP521Certificate Certificate |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 140 | ed25519Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 141 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 142 | |
| 143 | var testCerts = []struct { |
| 144 | id testCert |
| 145 | certFile, keyFile string |
| 146 | cert *Certificate |
| 147 | }{ |
| 148 | { |
| 149 | id: testCertRSA, |
| 150 | certFile: rsaCertificateFile, |
| 151 | keyFile: rsaKeyFile, |
| 152 | cert: &rsaCertificate, |
| 153 | }, |
| 154 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 155 | id: testCertRSA1024, |
| 156 | certFile: rsa1024CertificateFile, |
| 157 | keyFile: rsa1024KeyFile, |
| 158 | cert: &rsa1024Certificate, |
| 159 | }, |
| 160 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 161 | id: testCertRSAChain, |
| 162 | certFile: rsaChainCertificateFile, |
| 163 | keyFile: rsaChainKeyFile, |
| 164 | cert: &rsaChainCertificate, |
| 165 | }, |
| 166 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 167 | id: testCertECDSAP224, |
| 168 | certFile: ecdsaP224CertificateFile, |
| 169 | keyFile: ecdsaP224KeyFile, |
| 170 | cert: &ecdsaP224Certificate, |
| 171 | }, |
| 172 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 173 | id: testCertECDSAP256, |
| 174 | certFile: ecdsaP256CertificateFile, |
| 175 | keyFile: ecdsaP256KeyFile, |
| 176 | cert: &ecdsaP256Certificate, |
| 177 | }, |
| 178 | { |
| 179 | id: testCertECDSAP384, |
| 180 | certFile: ecdsaP384CertificateFile, |
| 181 | keyFile: ecdsaP384KeyFile, |
| 182 | cert: &ecdsaP384Certificate, |
| 183 | }, |
| 184 | { |
| 185 | id: testCertECDSAP521, |
| 186 | certFile: ecdsaP521CertificateFile, |
| 187 | keyFile: ecdsaP521KeyFile, |
| 188 | cert: &ecdsaP521Certificate, |
| 189 | }, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 190 | { |
| 191 | id: testCertEd25519, |
| 192 | certFile: ed25519CertificateFile, |
| 193 | keyFile: ed25519KeyFile, |
| 194 | cert: &ed25519Certificate, |
| 195 | }, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 196 | } |
| 197 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 198 | var channelIDKey *ecdsa.PrivateKey |
| 199 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 200 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 201 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 202 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 203 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 204 | 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] | 205 | 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] | 206 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 208 | for i := range testCerts { |
| 209 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 210 | if err != nil { |
| 211 | panic(err) |
| 212 | } |
| 213 | cert.OCSPStaple = testOCSPResponse |
| 214 | cert.SignedCertificateTimestampList = testSCTList |
| 215 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 217 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 218 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 219 | if err != nil { |
| 220 | panic(err) |
| 221 | } |
| 222 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 223 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 224 | panic("bad key type") |
| 225 | } |
| 226 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 227 | if err != nil { |
| 228 | panic(err) |
| 229 | } |
| 230 | if channelIDKey.Curve != elliptic.P256() { |
| 231 | panic("bad curve") |
| 232 | } |
| 233 | |
| 234 | channelIDBytes = make([]byte, 64) |
| 235 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 236 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
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 getRunnerCertificate(t testCert) Certificate { |
| 240 | for _, cert := range testCerts { |
| 241 | if cert.id == t { |
| 242 | return *cert.cert |
| 243 | } |
| 244 | } |
| 245 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 246 | } |
| 247 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 248 | func getShimCertificate(t testCert) string { |
| 249 | for _, cert := range testCerts { |
| 250 | if cert.id == t { |
| 251 | return cert.certFile |
| 252 | } |
| 253 | } |
| 254 | panic("Unknown test certificate") |
| 255 | } |
| 256 | |
| 257 | func getShimKey(t testCert) string { |
| 258 | for _, cert := range testCerts { |
| 259 | if cert.id == t { |
| 260 | return cert.keyFile |
| 261 | } |
| 262 | } |
| 263 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 266 | // recordVersionToWire maps a record-layer protocol version to its wire |
| 267 | // representation. |
| 268 | func recordVersionToWire(vers uint16, protocol protocol) uint16 { |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 269 | if protocol == dtls { |
| 270 | switch vers { |
| 271 | case VersionTLS12: |
| 272 | return VersionDTLS12 |
| 273 | case VersionTLS10: |
| 274 | return VersionDTLS10 |
| 275 | } |
| 276 | } else { |
| 277 | switch vers { |
| 278 | case VersionSSL30, VersionTLS10, VersionTLS11, VersionTLS12: |
| 279 | return vers |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
| 283 | panic("unknown version") |
| 284 | } |
| 285 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 286 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 287 | func encodeDERValues(values [][]byte) string { |
| 288 | var ret string |
| 289 | for i, v := range values { |
| 290 | if i > 0 { |
| 291 | ret += "," |
| 292 | } |
| 293 | ret += hex.EncodeToString(v) |
| 294 | } |
| 295 | |
| 296 | return ret |
| 297 | } |
| 298 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 299 | type testType int |
| 300 | |
| 301 | const ( |
| 302 | clientTest testType = iota |
| 303 | serverTest |
| 304 | ) |
| 305 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 306 | type protocol int |
| 307 | |
| 308 | const ( |
| 309 | tls protocol = iota |
| 310 | dtls |
| 311 | ) |
| 312 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 313 | const ( |
| 314 | alpn = 1 |
| 315 | npn = 2 |
| 316 | ) |
| 317 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 318 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 319 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 320 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 321 | name string |
| 322 | config Config |
| 323 | shouldFail bool |
| 324 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 325 | // expectedLocalError, if not empty, contains a substring that must be |
| 326 | // found in the local error. |
| 327 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 328 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 329 | // negotiated. |
| 330 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 331 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 332 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 333 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 334 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 335 | // should be negotiated. |
| 336 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 337 | // expectChannelID controls whether the connection should have |
| 338 | // negotiated a Channel ID with channelIDKey. |
| 339 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 340 | // expectedNextProto controls whether the connection should |
| 341 | // negotiate a next protocol via NPN or ALPN. |
| 342 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 343 | // expectNoNextProto, if true, means that no next protocol should be |
| 344 | // negotiated. |
| 345 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 346 | // expectedNextProtoType, if non-zero, is the expected next |
| 347 | // protocol negotiation mechanism. |
| 348 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 349 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 350 | // should be negotiated. If zero, none should be negotiated. |
| 351 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 352 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 353 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 354 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 355 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 356 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 357 | // algorithm that the peer should have used in the handshake. |
| 358 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 359 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 360 | // have used. |
| 361 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 362 | // messageLen is the length, in bytes, of the test message that will be |
| 363 | // sent. |
| 364 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 365 | // messageCount is the number of test messages that will be sent. |
| 366 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 367 | // certFile is the path to the certificate to use for the server. |
| 368 | certFile string |
| 369 | // keyFile is the path to the private key to use for the server. |
| 370 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 371 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 372 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 373 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 374 | // resumeRenewedSession controls whether a third connection should be |
| 375 | // tested which attempts to resume the second connection's session. |
| 376 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 377 | // expectResumeRejected, if true, specifies that the attempted |
| 378 | // resumption must be rejected by the client. This is only valid for a |
| 379 | // serverTest. |
| 380 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 381 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 382 | // resumption. Unless newSessionsOnResume is set, |
| 383 | // SessionTicketKey, ServerSessionCache, and |
| 384 | // ClientSessionCache are copied from the initial connection's |
| 385 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 386 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 387 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 388 | // use a different session resumption context. |
| 389 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 390 | // noSessionCache, if true, will cause the server to run without a |
| 391 | // session cache. |
| 392 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 393 | // sendPrefix sends a prefix on the socket before actually performing a |
| 394 | // handshake. |
| 395 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 396 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 397 | // message before doing a roundtrip with the runner. |
| 398 | shimWritesFirst bool |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 399 | // readWithUnfinishedWrite behaves like shimWritesFirst, but the shim |
| 400 | // does not complete the write until responding to the first runner |
| 401 | // message. |
| 402 | readWithUnfinishedWrite bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 403 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 404 | // connection immediately after the handshake rather than echoing |
| 405 | // messages from the runner. |
| 406 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 407 | // renegotiate indicates the number of times the connection should be |
| 408 | // renegotiated during the exchange. |
| 409 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 410 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 411 | // HelloRequest when the handshake completes. |
| 412 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 413 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 414 | // switched in just before renegotiation. |
| 415 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 416 | // replayWrites, if true, configures the underlying transport |
| 417 | // to replay every write it makes in DTLS tests. |
| 418 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 419 | // damageFirstWrite, if true, configures the underlying transport to |
| 420 | // damage the final byte of the first application data write. |
| 421 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 422 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 423 | // keying material and verify they match. |
| 424 | exportKeyingMaterial int |
| 425 | exportLabel string |
| 426 | exportContext string |
| 427 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 428 | // flags, if not empty, contains a list of command-line flags that will |
| 429 | // be passed to the shim program. |
| 430 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 431 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 432 | // which will be compared against the expected value. |
| 433 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 434 | // sendEmptyRecords is the number of consecutive empty records to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 435 | // before each test message. |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 436 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 437 | // sendWarningAlerts is the number of consecutive warning alerts to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 438 | // before each test message. |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 439 | sendWarningAlerts int |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 440 | // sendBogusAlertType, if true, causes a bogus alert of invalid type to |
| 441 | // be sent before each test message. |
| 442 | sendBogusAlertType bool |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 443 | // sendKeyUpdates is the number of consecutive key updates to send |
| 444 | // before and after the test message. |
| 445 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 446 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 447 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 448 | // expectMessageDropped, if true, means the test message is expected to |
| 449 | // be dropped by the client rather than echoed back. |
| 450 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 451 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 452 | // is expected to send. |
| 453 | expectPeerCertificate *Certificate |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 454 | // shimPrefix is the prefix that the shim will send to the server. |
| 455 | shimPrefix string |
| 456 | // resumeShimPrefix is the prefix that the shim will send to the server on a |
| 457 | // resumption. |
| 458 | resumeShimPrefix string |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 459 | // tls13Variant, if non-zero, causes both runner and shim to be |
| 460 | // configured with the specified TLS 1.3 variant. This is a convenience |
| 461 | // option for configuring both concurrently. |
| 462 | tls13Variant int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 465 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 466 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 467 | func writeTranscript(test *testCase, path string, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 468 | if len(data) == 0 { |
| 469 | return |
| 470 | } |
| 471 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 472 | settings, err := ioutil.ReadFile(path) |
| 473 | if err != nil { |
| 474 | fmt.Fprintf(os.Stderr, "Error reading %s: %s.\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 475 | return |
| 476 | } |
| 477 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 478 | settings = append(settings, data...) |
| 479 | if err := ioutil.WriteFile(path, settings, 0644); err != nil { |
| 480 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 484 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 485 | type timeoutConn struct { |
| 486 | net.Conn |
| 487 | timeout time.Duration |
| 488 | } |
| 489 | |
| 490 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 491 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 492 | return 0, err |
| 493 | } |
| 494 | return t.Conn.Read(b) |
| 495 | } |
| 496 | |
| 497 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 498 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 499 | return 0, err |
| 500 | } |
| 501 | return t.Conn.Write(b) |
| 502 | } |
| 503 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 504 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, transcriptPrefix string, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 505 | if !test.noSessionCache { |
| 506 | if config.ClientSessionCache == nil { |
| 507 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 508 | } |
| 509 | if config.ServerSessionCache == nil { |
| 510 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 511 | } |
| 512 | } |
| 513 | if test.testType == clientTest { |
| 514 | if len(config.Certificates) == 0 { |
| 515 | config.Certificates = []Certificate{rsaCertificate} |
| 516 | } |
| 517 | } else { |
| 518 | // Supply a ServerName to ensure a constant session cache key, |
| 519 | // rather than falling back to net.Conn.RemoteAddr. |
| 520 | if len(config.ServerName) == 0 { |
| 521 | config.ServerName = "test" |
| 522 | } |
| 523 | } |
| 524 | if *fuzzer { |
| 525 | config.Bugs.NullAllCiphers = true |
| 526 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 527 | if *deterministic { |
| 528 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 529 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 530 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 531 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 532 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 533 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 534 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 535 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 536 | } |
| 537 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 538 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 539 | local, peer := "client", "server" |
| 540 | if test.testType == clientTest { |
| 541 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 542 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 543 | connDebug := &recordingConn{ |
| 544 | Conn: conn, |
| 545 | isDatagram: test.protocol == dtls, |
| 546 | local: local, |
| 547 | peer: peer, |
| 548 | } |
| 549 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 550 | if *flagDebug { |
| 551 | defer connDebug.WriteTo(os.Stdout) |
| 552 | } |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 553 | if len(transcriptPrefix) != 0 { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 554 | defer func() { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 555 | path := transcriptPrefix + strconv.Itoa(num) |
| 556 | writeTranscript(test, path, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 557 | }() |
| 558 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 559 | |
| 560 | if config.Bugs.PacketAdaptor != nil { |
| 561 | config.Bugs.PacketAdaptor.debug = connDebug |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | if test.replayWrites { |
| 566 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 567 | } |
| 568 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 569 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 570 | if test.damageFirstWrite { |
| 571 | connDamage = newDamageAdaptor(conn) |
| 572 | conn = connDamage |
| 573 | } |
| 574 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 575 | if test.sendPrefix != "" { |
| 576 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 577 | return err |
| 578 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 579 | } |
| 580 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 581 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 582 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 583 | if test.protocol == dtls { |
| 584 | tlsConn = DTLSServer(conn, config) |
| 585 | } else { |
| 586 | tlsConn = Server(conn, config) |
| 587 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 588 | } else { |
| 589 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 590 | if test.protocol == dtls { |
| 591 | tlsConn = DTLSClient(conn, config) |
| 592 | } else { |
| 593 | tlsConn = Client(conn, config) |
| 594 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 595 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 596 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 597 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 598 | if err := tlsConn.Handshake(); err != nil { |
| 599 | return err |
| 600 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 601 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 602 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 603 | // expectations struct that can be specified separately for the two |
| 604 | // legs. |
| 605 | expectedVersion := test.expectedVersion |
| 606 | if isResume && test.expectedResumeVersion != 0 { |
| 607 | expectedVersion = test.expectedResumeVersion |
| 608 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 609 | connState := tlsConn.ConnectionState() |
| 610 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 611 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 612 | } |
| 613 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 614 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 615 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 616 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 617 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 618 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 619 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 620 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 621 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 622 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 623 | if channelID == nil { |
| 624 | return fmt.Errorf("no channel ID negotiated") |
| 625 | } |
| 626 | if channelID.Curve != channelIDKey.Curve || |
| 627 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 628 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 629 | return fmt.Errorf("incorrect channel ID") |
| 630 | } |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 631 | } else if connState.ChannelID != nil { |
| 632 | return fmt.Errorf("channel ID unexpectedly negotiated") |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 633 | } |
| 634 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 635 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 636 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 637 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 638 | } |
| 639 | } |
| 640 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 641 | if test.expectNoNextProto { |
| 642 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 643 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 644 | } |
| 645 | } |
| 646 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 647 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 648 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 649 | return fmt.Errorf("next proto type mismatch") |
| 650 | } |
| 651 | } |
| 652 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 653 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 654 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 655 | } |
| 656 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 657 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 658 | 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] | 659 | } |
| 660 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 661 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 662 | return fmt.Errorf("SCT list mismatch") |
| 663 | } |
| 664 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 665 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 666 | 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] | 667 | } |
| 668 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 669 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 670 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 671 | } |
| 672 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 673 | if test.expectPeerCertificate != nil { |
| 674 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 675 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 676 | } |
| 677 | for i, cert := range connState.PeerCertificates { |
| 678 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 679 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 684 | if test.exportKeyingMaterial > 0 { |
| 685 | actual := make([]byte, test.exportKeyingMaterial) |
| 686 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 687 | return err |
| 688 | } |
| 689 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 690 | if err != nil { |
| 691 | return err |
| 692 | } |
| 693 | if !bytes.Equal(actual, expected) { |
| 694 | return fmt.Errorf("keying material mismatch") |
| 695 | } |
| 696 | } |
| 697 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 698 | if test.testTLSUnique { |
| 699 | var peersValue [12]byte |
| 700 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 701 | return err |
| 702 | } |
| 703 | expected := tlsConn.ConnectionState().TLSUnique |
| 704 | if !bytes.Equal(peersValue[:], expected) { |
| 705 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 706 | } |
| 707 | } |
| 708 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 709 | if test.sendHalfHelloRequest { |
| 710 | tlsConn.SendHalfHelloRequest() |
| 711 | } |
| 712 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 713 | shimPrefix := test.shimPrefix |
| 714 | if isResume { |
| 715 | shimPrefix = test.resumeShimPrefix |
| 716 | } |
| 717 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 718 | shimPrefix = "hello" |
| 719 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 720 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 721 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 722 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 723 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 724 | var buf = make([]byte, len(shimPrefix)) |
| 725 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 726 | if err != nil { |
| 727 | return err |
| 728 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 729 | if string(buf) != shimPrefix { |
| 730 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 731 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 732 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 733 | } |
| 734 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 735 | if test.renegotiateCiphers != nil { |
| 736 | config.CipherSuites = test.renegotiateCiphers |
| 737 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 738 | for i := 0; i < test.renegotiate; i++ { |
| 739 | if err := tlsConn.Renegotiate(); err != nil { |
| 740 | return err |
| 741 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 742 | } |
| 743 | } else if test.renegotiateCiphers != nil { |
| 744 | panic("renegotiateCiphers without renegotiate") |
| 745 | } |
| 746 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 747 | if test.damageFirstWrite { |
| 748 | connDamage.setDamage(true) |
| 749 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 750 | connDamage.setDamage(false) |
| 751 | } |
| 752 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 753 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 754 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 755 | if test.protocol == dtls { |
| 756 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 757 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 758 | // Read until EOF. |
| 759 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 760 | return err |
| 761 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 762 | if messageLen == 0 { |
| 763 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 764 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 765 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 766 | messageCount := test.messageCount |
| 767 | if messageCount == 0 { |
| 768 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 769 | } |
| 770 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 771 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 772 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 773 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 774 | } |
| 775 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 776 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 777 | tlsConn.Write(nil) |
| 778 | } |
| 779 | |
| 780 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 781 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 782 | } |
| 783 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 784 | if test.sendBogusAlertType { |
| 785 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 786 | } |
| 787 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 788 | testMessage := make([]byte, messageLen) |
| 789 | for i := range testMessage { |
| 790 | testMessage[i] = 0x42 ^ byte(j) |
| 791 | } |
| 792 | tlsConn.Write(testMessage) |
| 793 | |
| 794 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 795 | if shimPrefix != "" { |
| 796 | var buf = make([]byte, len(shimPrefix)) |
| 797 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 798 | if err != nil { |
| 799 | return err |
| 800 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 801 | if string(buf) != shimPrefix { |
| 802 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 803 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 804 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 805 | } |
| 806 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 807 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 808 | // The shim will not respond. |
| 809 | continue |
| 810 | } |
| 811 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 812 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 813 | // sends, the shim should respond only once. |
| 814 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 815 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 816 | return err |
| 817 | } |
| 818 | } |
| 819 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 820 | buf := make([]byte, len(testMessage)) |
| 821 | if test.protocol == dtls { |
| 822 | bufTmp := make([]byte, len(buf)+1) |
| 823 | n, err := tlsConn.Read(bufTmp) |
| 824 | if err != nil { |
| 825 | return err |
| 826 | } |
| 827 | if n != len(buf) { |
| 828 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 829 | } |
| 830 | copy(buf, bufTmp) |
| 831 | } else { |
| 832 | _, err := io.ReadFull(tlsConn, buf) |
| 833 | if err != nil { |
| 834 | return err |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | for i, v := range buf { |
| 839 | if v != testMessage[i]^0xff { |
| 840 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 841 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 842 | } |
| 843 | } |
| 844 | |
| 845 | return nil |
| 846 | } |
| 847 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 848 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 849 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 850 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 851 | 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] | 852 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 853 | valgrindArgs = append(valgrindArgs, path) |
| 854 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 855 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 856 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 857 | } |
| 858 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 859 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 860 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 861 | xtermArgs = append(xtermArgs, path) |
| 862 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 863 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 864 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 865 | } |
| 866 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 867 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 868 | xtermArgs := []string{"-e", "lldb", "--"} |
| 869 | xtermArgs = append(xtermArgs, path) |
| 870 | xtermArgs = append(xtermArgs, args...) |
| 871 | |
| 872 | return exec.Command("xterm", xtermArgs...) |
| 873 | } |
| 874 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 875 | var ( |
| 876 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 877 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 878 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 879 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 880 | // accept accepts a connection from listener, unless waitChan signals a process |
| 881 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 882 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 883 | type connOrError struct { |
| 884 | conn net.Conn |
| 885 | err error |
| 886 | } |
| 887 | connChan := make(chan connOrError, 1) |
| 888 | go func() { |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 889 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 890 | conn, err := listener.Accept() |
| 891 | connChan <- connOrError{conn, err} |
| 892 | close(connChan) |
| 893 | }() |
| 894 | select { |
| 895 | case result := <-connChan: |
| 896 | return result.conn, result.err |
| 897 | case childErr := <-waitChan: |
| 898 | waitChan <- childErr |
| 899 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 900 | } |
| 901 | } |
| 902 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 903 | func translateExpectedError(errorStr string) string { |
| 904 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 905 | return translated |
| 906 | } |
| 907 | |
| 908 | if *looseErrors { |
| 909 | return "" |
| 910 | } |
| 911 | |
| 912 | return errorStr |
| 913 | } |
| 914 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 915 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 916 | // Help debugging panics on the Go side. |
| 917 | defer func() { |
| 918 | if r := recover(); r != nil { |
| 919 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 920 | panic(r) |
| 921 | } |
| 922 | }() |
| 923 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 924 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 925 | panic("Error expected without shouldFail in " + test.name) |
| 926 | } |
| 927 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 928 | if test.expectResumeRejected && !test.resumeSession { |
| 929 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 930 | } |
| 931 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 932 | for _, ver := range tlsVersions { |
| 933 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 934 | continue |
| 935 | } |
| 936 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 937 | if test.config.MaxVersion == 0 && test.config.MinVersion == 0 && test.expectedVersion == 0 { |
| 938 | 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)) |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 939 | } |
| 940 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 941 | if ver.tls13Variant != 0 { |
| 942 | var foundFlag bool |
| 943 | for _, flag := range test.flags { |
| 944 | if flag == "-tls13-variant" { |
| 945 | foundFlag = true |
| 946 | break |
| 947 | } |
| 948 | } |
| 949 | if !foundFlag && test.config.TLS13Variant != ver.tls13Variant && test.tls13Variant != ver.tls13Variant { |
| 950 | panic(fmt.Sprintf("The name of test %q suggests that uses an experimental TLS 1.3 variant, but neither the shim nor the runner configures it", test.name)) |
| 951 | } |
| 952 | } |
| 953 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 954 | } |
| 955 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 956 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 957 | if err != nil { |
| 958 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 959 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 960 | if err != nil { |
| 961 | panic(err) |
| 962 | } |
| 963 | defer func() { |
| 964 | if listener != nil { |
| 965 | listener.Close() |
| 966 | } |
| 967 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 968 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 969 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 970 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 971 | flags = append(flags, "-server") |
| 972 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 973 | flags = append(flags, "-key-file") |
| 974 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 975 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 976 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 977 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | flags = append(flags, "-cert-file") |
| 981 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 982 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 983 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 984 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 985 | } |
| 986 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 987 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 988 | if test.protocol == dtls { |
| 989 | flags = append(flags, "-dtls") |
| 990 | } |
| 991 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 992 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 993 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 994 | resumeCount++ |
| 995 | if test.resumeRenewedSession { |
| 996 | resumeCount++ |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | if resumeCount > 0 { |
| 1001 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1002 | } |
| 1003 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 1004 | if test.shimWritesFirst { |
| 1005 | flags = append(flags, "-shim-writes-first") |
| 1006 | } |
| 1007 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 1008 | if test.readWithUnfinishedWrite { |
| 1009 | flags = append(flags, "-read-with-unfinished-write") |
| 1010 | } |
| 1011 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1012 | if test.shimShutsDown { |
| 1013 | flags = append(flags, "-shim-shuts-down") |
| 1014 | } |
| 1015 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1016 | if test.exportKeyingMaterial > 0 { |
| 1017 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 1018 | flags = append(flags, "-export-label", test.exportLabel) |
| 1019 | flags = append(flags, "-export-context", test.exportContext) |
| 1020 | if test.useExportContext { |
| 1021 | flags = append(flags, "-use-export-context") |
| 1022 | } |
| 1023 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 1024 | if test.expectResumeRejected { |
| 1025 | flags = append(flags, "-expect-session-miss") |
| 1026 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1027 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 1028 | if test.testTLSUnique { |
| 1029 | flags = append(flags, "-tls-unique") |
| 1030 | } |
| 1031 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1032 | if test.tls13Variant != 0 { |
| 1033 | test.config.TLS13Variant = test.tls13Variant |
| 1034 | flags = append(flags, "-tls13-variant", strconv.Itoa(test.tls13Variant)) |
| 1035 | } |
| 1036 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1037 | var transcriptPrefix string |
| 1038 | if len(*transcriptDir) != 0 { |
| 1039 | protocol := "tls" |
| 1040 | if test.protocol == dtls { |
| 1041 | protocol = "dtls" |
| 1042 | } |
| 1043 | |
| 1044 | side := "client" |
| 1045 | if test.testType == serverTest { |
| 1046 | side = "server" |
| 1047 | } |
| 1048 | |
| 1049 | dir := filepath.Join(*transcriptDir, protocol, side) |
| 1050 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 1051 | return err |
| 1052 | } |
| 1053 | transcriptPrefix = filepath.Join(dir, test.name+"-") |
| 1054 | flags = append(flags, "-write-settings", transcriptPrefix) |
| 1055 | } |
| 1056 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1057 | flags = append(flags, test.flags...) |
| 1058 | |
| 1059 | var shim *exec.Cmd |
| 1060 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1061 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1062 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1063 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1064 | } else if *useLLDB { |
| 1065 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1066 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1067 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1068 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1069 | shim.Stdin = os.Stdin |
| 1070 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1071 | shim.Stdout = &stdoutBuf |
| 1072 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1073 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1074 | shim.Env = os.Environ() |
| 1075 | 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] | 1076 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1077 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1078 | } |
| 1079 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1080 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1081 | |
| 1082 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1083 | panic(err) |
| 1084 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1085 | waitChan := make(chan error, 1) |
| 1086 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1087 | |
| 1088 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1089 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1090 | if *deterministic { |
| 1091 | config.Rand = &deterministicRand{} |
| 1092 | } |
| 1093 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1094 | conn, err := acceptOrWait(listener, waitChan) |
| 1095 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1096 | err = doExchange(test, &config, conn, false /* not a resumption */, transcriptPrefix, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1097 | conn.Close() |
| 1098 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1099 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1100 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1101 | var resumeConfig Config |
| 1102 | if test.resumeConfig != nil { |
| 1103 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1104 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1105 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1106 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1107 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1108 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1109 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1110 | } else { |
| 1111 | resumeConfig = config |
| 1112 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1113 | var connResume net.Conn |
| 1114 | connResume, err = acceptOrWait(listener, waitChan) |
| 1115 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1116 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, transcriptPrefix, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1117 | connResume.Close() |
| 1118 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1119 | } |
| 1120 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1121 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1122 | // open more connections than expected. |
| 1123 | listener.Close() |
| 1124 | listener = nil |
| 1125 | |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1126 | var shimKilledLock sync.Mutex |
| 1127 | var shimKilled bool |
| 1128 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1129 | shimKilledLock.Lock() |
| 1130 | shimKilled = true |
| 1131 | shimKilledLock.Unlock() |
| 1132 | shim.Process.Kill() |
| 1133 | }) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1134 | childErr := <-waitChan |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1135 | waitTimeout.Stop() |
| 1136 | shimKilledLock.Lock() |
| 1137 | if shimKilled && err == nil { |
| 1138 | err = errors.New("timeout waiting for the shim to exit.") |
| 1139 | } |
| 1140 | shimKilledLock.Unlock() |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1141 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1142 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1143 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1144 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1145 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1146 | case 89: |
| 1147 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1148 | case 99: |
| 1149 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1150 | } |
| 1151 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1152 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1153 | // Account for Windows line endings. |
| 1154 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1155 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1156 | |
| 1157 | // Separate the errors from the shim and those from tools like |
| 1158 | // AddressSanitizer. |
| 1159 | var extraStderr string |
| 1160 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1161 | stderr = stderrParts[0] |
| 1162 | extraStderr = stderrParts[1] |
| 1163 | } |
| 1164 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1165 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1166 | expectedError := translateExpectedError(test.expectedError) |
| 1167 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1168 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1169 | localError := "none" |
| 1170 | if err != nil { |
| 1171 | localError = err.Error() |
| 1172 | } |
| 1173 | if len(test.expectedLocalError) != 0 { |
| 1174 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1175 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1176 | |
| 1177 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1178 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1179 | if childErr != nil { |
| 1180 | childError = childErr.Error() |
| 1181 | } |
| 1182 | |
| 1183 | var msg string |
| 1184 | switch { |
| 1185 | case failed && !test.shouldFail: |
| 1186 | msg = "unexpected failure" |
| 1187 | case !failed && test.shouldFail: |
| 1188 | msg = "unexpected success" |
| 1189 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1190 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1191 | default: |
| 1192 | panic("internal error") |
| 1193 | } |
| 1194 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1195 | 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] | 1196 | } |
| 1197 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1198 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1199 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1200 | } |
| 1201 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1202 | if *useValgrind && isValgrindError { |
| 1203 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1204 | } |
| 1205 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1206 | return nil |
| 1207 | } |
| 1208 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1209 | type tlsVersion struct { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1210 | name string |
| 1211 | // version is the protocol version. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1212 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1213 | // excludeFlag is the legacy shim flag to disable the version. |
| 1214 | excludeFlag string |
| 1215 | hasDTLS bool |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1216 | // versionDTLS, if non-zero, is the DTLS-specific representation of the version. |
| 1217 | versionDTLS uint16 |
| 1218 | // versionWire, if non-zero, is the wire representation of the |
| 1219 | // version. Otherwise the wire version is the protocol version or |
| 1220 | // versionDTLS. |
| 1221 | versionWire uint16 |
| 1222 | tls13Variant int |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1226 | // The shim uses the protocol version in its public API, but uses the |
| 1227 | // DTLS-specific version if it exists. |
| 1228 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1229 | return strconv.Itoa(int(vers.versionDTLS)) |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1230 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1231 | return strconv.Itoa(int(vers.version)) |
| 1232 | } |
| 1233 | |
| 1234 | func (vers tlsVersion) wire(protocol protocol) uint16 { |
| 1235 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1236 | return vers.versionDTLS |
| 1237 | } |
| 1238 | if vers.versionWire != 0 { |
| 1239 | return vers.versionWire |
| 1240 | } |
| 1241 | return vers.version |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | var tlsVersions = []tlsVersion{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1245 | { |
| 1246 | name: "SSL3", |
| 1247 | version: VersionSSL30, |
| 1248 | excludeFlag: "-no-ssl3", |
| 1249 | }, |
| 1250 | { |
| 1251 | name: "TLS1", |
| 1252 | version: VersionTLS10, |
| 1253 | excludeFlag: "-no-tls1", |
| 1254 | hasDTLS: true, |
| 1255 | versionDTLS: VersionDTLS10, |
| 1256 | }, |
| 1257 | { |
| 1258 | name: "TLS11", |
| 1259 | version: VersionTLS11, |
| 1260 | excludeFlag: "-no-tls11", |
| 1261 | }, |
| 1262 | { |
| 1263 | name: "TLS12", |
| 1264 | version: VersionTLS12, |
| 1265 | excludeFlag: "-no-tls12", |
| 1266 | hasDTLS: true, |
| 1267 | versionDTLS: VersionDTLS12, |
| 1268 | }, |
| 1269 | { |
| 1270 | name: "TLS13", |
| 1271 | version: VersionTLS13, |
| 1272 | excludeFlag: "-no-tls13", |
| 1273 | versionWire: tls13DraftVersion, |
| 1274 | tls13Variant: TLS13Default, |
| 1275 | }, |
| 1276 | { |
| 1277 | name: "TLS13Experiment", |
| 1278 | version: VersionTLS13, |
| 1279 | excludeFlag: "-no-tls13", |
| 1280 | versionWire: tls13ExperimentVersion, |
| 1281 | tls13Variant: TLS13Experiment, |
| 1282 | }, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 1283 | { |
| 1284 | name: "TLS13RecordTypeExperiment", |
| 1285 | version: VersionTLS13, |
| 1286 | excludeFlag: "-no-tls13", |
| 1287 | versionWire: tls13RecordTypeExperimentVersion, |
| 1288 | tls13Variant: TLS13RecordTypeExperiment, |
| 1289 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | func allVersions(protocol protocol) []tlsVersion { |
| 1293 | if protocol == tls { |
| 1294 | return tlsVersions |
| 1295 | } |
| 1296 | |
| 1297 | var ret []tlsVersion |
| 1298 | for _, vers := range tlsVersions { |
| 1299 | if vers.hasDTLS { |
| 1300 | ret = append(ret, vers) |
| 1301 | } |
| 1302 | } |
| 1303 | return ret |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1304 | } |
| 1305 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1306 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1307 | name string |
| 1308 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1312 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1313 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1314 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1315 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1316 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1317 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1318 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1319 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1320 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1321 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1322 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1323 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1324 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1325 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1326 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1327 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1328 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1329 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1330 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1331 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1332 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1333 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1334 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1335 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1336 | {"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] | 1337 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1338 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1339 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1340 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1341 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1344 | func hasComponent(suiteName, component string) bool { |
| 1345 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1346 | } |
| 1347 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1348 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1349 | return hasComponent(suiteName, "GCM") || |
| 1350 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1351 | hasComponent(suiteName, "SHA384") || |
| 1352 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1353 | } |
| 1354 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1355 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1356 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1359 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1360 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1361 | } |
| 1362 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1363 | func bigFromHex(hex string) *big.Int { |
| 1364 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1365 | if !ok { |
| 1366 | panic("failed to parse hex number 0x" + hex) |
| 1367 | } |
| 1368 | return ret |
| 1369 | } |
| 1370 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1371 | func addBasicTests() { |
| 1372 | basicTests := []testCase{ |
| 1373 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1374 | name: "NoFallbackSCSV", |
| 1375 | config: Config{ |
| 1376 | Bugs: ProtocolBugs{ |
| 1377 | FailIfNotFallbackSCSV: true, |
| 1378 | }, |
| 1379 | }, |
| 1380 | shouldFail: true, |
| 1381 | expectedLocalError: "no fallback SCSV found", |
| 1382 | }, |
| 1383 | { |
| 1384 | name: "SendFallbackSCSV", |
| 1385 | config: Config{ |
| 1386 | Bugs: ProtocolBugs{ |
| 1387 | FailIfNotFallbackSCSV: true, |
| 1388 | }, |
| 1389 | }, |
| 1390 | flags: []string{"-fallback-scsv"}, |
| 1391 | }, |
| 1392 | { |
| 1393 | name: "ClientCertificateTypes", |
| 1394 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1395 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1396 | ClientAuth: RequestClientCert, |
| 1397 | ClientCertificateTypes: []byte{ |
| 1398 | CertTypeDSSSign, |
| 1399 | CertTypeRSASign, |
| 1400 | CertTypeECDSASign, |
| 1401 | }, |
| 1402 | }, |
| 1403 | flags: []string{ |
| 1404 | "-expect-certificate-types", |
| 1405 | base64.StdEncoding.EncodeToString([]byte{ |
| 1406 | CertTypeDSSSign, |
| 1407 | CertTypeRSASign, |
| 1408 | CertTypeECDSASign, |
| 1409 | }), |
| 1410 | }, |
| 1411 | }, |
| 1412 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1413 | name: "UnauthenticatedECDH", |
| 1414 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1415 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1416 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1417 | Bugs: ProtocolBugs{ |
| 1418 | UnauthenticatedECDH: true, |
| 1419 | }, |
| 1420 | }, |
| 1421 | shouldFail: true, |
| 1422 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1423 | }, |
| 1424 | { |
| 1425 | name: "SkipCertificateStatus", |
| 1426 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1427 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1428 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1429 | Bugs: ProtocolBugs{ |
| 1430 | SkipCertificateStatus: true, |
| 1431 | }, |
| 1432 | }, |
| 1433 | flags: []string{ |
| 1434 | "-enable-ocsp-stapling", |
| 1435 | }, |
| 1436 | }, |
| 1437 | { |
| 1438 | name: "SkipServerKeyExchange", |
| 1439 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1440 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1441 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1442 | Bugs: ProtocolBugs{ |
| 1443 | SkipServerKeyExchange: true, |
| 1444 | }, |
| 1445 | }, |
| 1446 | shouldFail: true, |
| 1447 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1448 | }, |
| 1449 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1450 | testType: serverTest, |
| 1451 | name: "Alert", |
| 1452 | config: Config{ |
| 1453 | Bugs: ProtocolBugs{ |
| 1454 | SendSpuriousAlert: alertRecordOverflow, |
| 1455 | }, |
| 1456 | }, |
| 1457 | shouldFail: true, |
| 1458 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1459 | }, |
| 1460 | { |
| 1461 | protocol: dtls, |
| 1462 | testType: serverTest, |
| 1463 | name: "Alert-DTLS", |
| 1464 | config: Config{ |
| 1465 | Bugs: ProtocolBugs{ |
| 1466 | SendSpuriousAlert: alertRecordOverflow, |
| 1467 | }, |
| 1468 | }, |
| 1469 | shouldFail: true, |
| 1470 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1471 | }, |
| 1472 | { |
| 1473 | testType: serverTest, |
| 1474 | name: "FragmentAlert", |
| 1475 | config: Config{ |
| 1476 | Bugs: ProtocolBugs{ |
| 1477 | FragmentAlert: true, |
| 1478 | SendSpuriousAlert: alertRecordOverflow, |
| 1479 | }, |
| 1480 | }, |
| 1481 | shouldFail: true, |
| 1482 | expectedError: ":BAD_ALERT:", |
| 1483 | }, |
| 1484 | { |
| 1485 | protocol: dtls, |
| 1486 | testType: serverTest, |
| 1487 | name: "FragmentAlert-DTLS", |
| 1488 | config: Config{ |
| 1489 | Bugs: ProtocolBugs{ |
| 1490 | FragmentAlert: true, |
| 1491 | SendSpuriousAlert: alertRecordOverflow, |
| 1492 | }, |
| 1493 | }, |
| 1494 | shouldFail: true, |
| 1495 | expectedError: ":BAD_ALERT:", |
| 1496 | }, |
| 1497 | { |
| 1498 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1499 | name: "DoubleAlert", |
| 1500 | config: Config{ |
| 1501 | Bugs: ProtocolBugs{ |
| 1502 | DoubleAlert: true, |
| 1503 | SendSpuriousAlert: alertRecordOverflow, |
| 1504 | }, |
| 1505 | }, |
| 1506 | shouldFail: true, |
| 1507 | expectedError: ":BAD_ALERT:", |
| 1508 | }, |
| 1509 | { |
| 1510 | protocol: dtls, |
| 1511 | testType: serverTest, |
| 1512 | name: "DoubleAlert-DTLS", |
| 1513 | config: Config{ |
| 1514 | Bugs: ProtocolBugs{ |
| 1515 | DoubleAlert: true, |
| 1516 | SendSpuriousAlert: alertRecordOverflow, |
| 1517 | }, |
| 1518 | }, |
| 1519 | shouldFail: true, |
| 1520 | expectedError: ":BAD_ALERT:", |
| 1521 | }, |
| 1522 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1523 | name: "SkipNewSessionTicket", |
| 1524 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1525 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1526 | Bugs: ProtocolBugs{ |
| 1527 | SkipNewSessionTicket: true, |
| 1528 | }, |
| 1529 | }, |
| 1530 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1531 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1532 | }, |
| 1533 | { |
| 1534 | testType: serverTest, |
| 1535 | name: "FallbackSCSV", |
| 1536 | config: Config{ |
| 1537 | MaxVersion: VersionTLS11, |
| 1538 | Bugs: ProtocolBugs{ |
| 1539 | SendFallbackSCSV: true, |
| 1540 | }, |
| 1541 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1542 | shouldFail: true, |
| 1543 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1544 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1545 | }, |
| 1546 | { |
| 1547 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1548 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1549 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1550 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1551 | Bugs: ProtocolBugs{ |
| 1552 | SendFallbackSCSV: true, |
| 1553 | }, |
| 1554 | }, |
| 1555 | }, |
| 1556 | { |
| 1557 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1558 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1559 | config: Config{ |
| 1560 | MaxVersion: VersionTLS12, |
| 1561 | Bugs: ProtocolBugs{ |
| 1562 | SendFallbackSCSV: true, |
| 1563 | }, |
| 1564 | }, |
| 1565 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1566 | }, |
| 1567 | { |
| 1568 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1569 | name: "FragmentedClientVersion", |
| 1570 | config: Config{ |
| 1571 | Bugs: ProtocolBugs{ |
| 1572 | MaxHandshakeRecordLength: 1, |
| 1573 | FragmentClientVersion: true, |
| 1574 | }, |
| 1575 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1576 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1577 | }, |
| 1578 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1579 | testType: serverTest, |
| 1580 | name: "HttpGET", |
| 1581 | sendPrefix: "GET / HTTP/1.0\n", |
| 1582 | shouldFail: true, |
| 1583 | expectedError: ":HTTP_REQUEST:", |
| 1584 | }, |
| 1585 | { |
| 1586 | testType: serverTest, |
| 1587 | name: "HttpPOST", |
| 1588 | sendPrefix: "POST / HTTP/1.0\n", |
| 1589 | shouldFail: true, |
| 1590 | expectedError: ":HTTP_REQUEST:", |
| 1591 | }, |
| 1592 | { |
| 1593 | testType: serverTest, |
| 1594 | name: "HttpHEAD", |
| 1595 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1596 | shouldFail: true, |
| 1597 | expectedError: ":HTTP_REQUEST:", |
| 1598 | }, |
| 1599 | { |
| 1600 | testType: serverTest, |
| 1601 | name: "HttpPUT", |
| 1602 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1603 | shouldFail: true, |
| 1604 | expectedError: ":HTTP_REQUEST:", |
| 1605 | }, |
| 1606 | { |
| 1607 | testType: serverTest, |
| 1608 | name: "HttpCONNECT", |
| 1609 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1610 | shouldFail: true, |
| 1611 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1612 | }, |
| 1613 | { |
| 1614 | testType: serverTest, |
| 1615 | name: "Garbage", |
| 1616 | sendPrefix: "blah", |
| 1617 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1618 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1619 | }, |
| 1620 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1621 | name: "RSAEphemeralKey", |
| 1622 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1623 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1624 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1625 | Bugs: ProtocolBugs{ |
| 1626 | RSAEphemeralKey: true, |
| 1627 | }, |
| 1628 | }, |
| 1629 | shouldFail: true, |
| 1630 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1631 | }, |
| 1632 | { |
| 1633 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1634 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1635 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1636 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1637 | }, |
| 1638 | { |
| 1639 | protocol: dtls, |
| 1640 | name: "DisableEverything-DTLS", |
| 1641 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1642 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1643 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1644 | }, |
| 1645 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1646 | protocol: dtls, |
| 1647 | testType: serverTest, |
| 1648 | name: "MTU", |
| 1649 | config: Config{ |
| 1650 | Bugs: ProtocolBugs{ |
| 1651 | MaxPacketLength: 256, |
| 1652 | }, |
| 1653 | }, |
| 1654 | flags: []string{"-mtu", "256"}, |
| 1655 | }, |
| 1656 | { |
| 1657 | protocol: dtls, |
| 1658 | testType: serverTest, |
| 1659 | name: "MTUExceeded", |
| 1660 | config: Config{ |
| 1661 | Bugs: ProtocolBugs{ |
| 1662 | MaxPacketLength: 255, |
| 1663 | }, |
| 1664 | }, |
| 1665 | flags: []string{"-mtu", "256"}, |
| 1666 | shouldFail: true, |
| 1667 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1668 | }, |
| 1669 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1670 | name: "EmptyCertificateList", |
| 1671 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1672 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1673 | Bugs: ProtocolBugs{ |
| 1674 | EmptyCertificateList: true, |
| 1675 | }, |
| 1676 | }, |
| 1677 | shouldFail: true, |
| 1678 | expectedError: ":DECODE_ERROR:", |
| 1679 | }, |
| 1680 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1681 | name: "EmptyCertificateList-TLS13", |
| 1682 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1683 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1684 | Bugs: ProtocolBugs{ |
| 1685 | EmptyCertificateList: true, |
| 1686 | }, |
| 1687 | }, |
| 1688 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1689 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1690 | }, |
| 1691 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1692 | name: "TLSFatalBadPackets", |
| 1693 | damageFirstWrite: true, |
| 1694 | shouldFail: true, |
| 1695 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1696 | }, |
| 1697 | { |
| 1698 | protocol: dtls, |
| 1699 | name: "DTLSIgnoreBadPackets", |
| 1700 | damageFirstWrite: true, |
| 1701 | }, |
| 1702 | { |
| 1703 | protocol: dtls, |
| 1704 | name: "DTLSIgnoreBadPackets-Async", |
| 1705 | damageFirstWrite: true, |
| 1706 | flags: []string{"-async"}, |
| 1707 | }, |
| 1708 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1709 | name: "AppDataBeforeHandshake", |
| 1710 | config: Config{ |
| 1711 | Bugs: ProtocolBugs{ |
| 1712 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1713 | }, |
| 1714 | }, |
| 1715 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1716 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1717 | }, |
| 1718 | { |
| 1719 | name: "AppDataBeforeHandshake-Empty", |
| 1720 | config: Config{ |
| 1721 | Bugs: ProtocolBugs{ |
| 1722 | AppDataBeforeHandshake: []byte{}, |
| 1723 | }, |
| 1724 | }, |
| 1725 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1726 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1727 | }, |
| 1728 | { |
| 1729 | protocol: dtls, |
| 1730 | name: "AppDataBeforeHandshake-DTLS", |
| 1731 | config: Config{ |
| 1732 | Bugs: ProtocolBugs{ |
| 1733 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1734 | }, |
| 1735 | }, |
| 1736 | shouldFail: true, |
| 1737 | expectedError: ":UNEXPECTED_RECORD:", |
| 1738 | }, |
| 1739 | { |
| 1740 | protocol: dtls, |
| 1741 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1742 | config: Config{ |
| 1743 | Bugs: ProtocolBugs{ |
| 1744 | AppDataBeforeHandshake: []byte{}, |
| 1745 | }, |
| 1746 | }, |
| 1747 | shouldFail: true, |
| 1748 | expectedError: ":UNEXPECTED_RECORD:", |
| 1749 | }, |
| 1750 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1751 | name: "AppDataAfterChangeCipherSpec", |
| 1752 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1753 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1754 | Bugs: ProtocolBugs{ |
| 1755 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1756 | }, |
| 1757 | }, |
| 1758 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1759 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1760 | }, |
| 1761 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1762 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1763 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1764 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1765 | Bugs: ProtocolBugs{ |
| 1766 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1767 | }, |
| 1768 | }, |
| 1769 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1770 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1771 | }, |
| 1772 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1773 | protocol: dtls, |
| 1774 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1775 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1776 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1777 | Bugs: ProtocolBugs{ |
| 1778 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1779 | }, |
| 1780 | }, |
| 1781 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1782 | // application data. |
| 1783 | }, |
| 1784 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1785 | protocol: dtls, |
| 1786 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1787 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1788 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1789 | Bugs: ProtocolBugs{ |
| 1790 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1791 | }, |
| 1792 | }, |
| 1793 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1794 | // application data. |
| 1795 | }, |
| 1796 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1797 | name: "AlertAfterChangeCipherSpec", |
| 1798 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1799 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1800 | Bugs: ProtocolBugs{ |
| 1801 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1802 | }, |
| 1803 | }, |
| 1804 | shouldFail: true, |
| 1805 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1806 | }, |
| 1807 | { |
| 1808 | protocol: dtls, |
| 1809 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1810 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1811 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1812 | Bugs: ProtocolBugs{ |
| 1813 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1814 | }, |
| 1815 | }, |
| 1816 | shouldFail: true, |
| 1817 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1818 | }, |
| 1819 | { |
| 1820 | protocol: dtls, |
| 1821 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1822 | config: Config{ |
| 1823 | Bugs: ProtocolBugs{ |
| 1824 | ReorderHandshakeFragments: true, |
| 1825 | // Small enough that every handshake message is |
| 1826 | // fragmented. |
| 1827 | MaxHandshakeRecordLength: 2, |
| 1828 | }, |
| 1829 | }, |
| 1830 | }, |
| 1831 | { |
| 1832 | protocol: dtls, |
| 1833 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1834 | config: Config{ |
| 1835 | Bugs: ProtocolBugs{ |
| 1836 | ReorderHandshakeFragments: true, |
| 1837 | // Large enough that no handshake message is |
| 1838 | // fragmented. |
| 1839 | MaxHandshakeRecordLength: 2048, |
| 1840 | }, |
| 1841 | }, |
| 1842 | }, |
| 1843 | { |
| 1844 | protocol: dtls, |
| 1845 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1846 | config: Config{ |
| 1847 | Bugs: ProtocolBugs{ |
| 1848 | ReorderHandshakeFragments: true, |
| 1849 | MixCompleteMessageWithFragments: true, |
| 1850 | MaxHandshakeRecordLength: 2, |
| 1851 | }, |
| 1852 | }, |
| 1853 | }, |
| 1854 | { |
| 1855 | name: "SendInvalidRecordType", |
| 1856 | config: Config{ |
| 1857 | Bugs: ProtocolBugs{ |
| 1858 | SendInvalidRecordType: true, |
| 1859 | }, |
| 1860 | }, |
| 1861 | shouldFail: true, |
| 1862 | expectedError: ":UNEXPECTED_RECORD:", |
| 1863 | }, |
| 1864 | { |
| 1865 | protocol: dtls, |
| 1866 | name: "SendInvalidRecordType-DTLS", |
| 1867 | config: Config{ |
| 1868 | Bugs: ProtocolBugs{ |
| 1869 | SendInvalidRecordType: true, |
| 1870 | }, |
| 1871 | }, |
| 1872 | shouldFail: true, |
| 1873 | expectedError: ":UNEXPECTED_RECORD:", |
| 1874 | }, |
| 1875 | { |
| 1876 | name: "FalseStart-SkipServerSecondLeg", |
| 1877 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1878 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1879 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1880 | NextProtos: []string{"foo"}, |
| 1881 | Bugs: ProtocolBugs{ |
| 1882 | SkipNewSessionTicket: true, |
| 1883 | SkipChangeCipherSpec: true, |
| 1884 | SkipFinished: true, |
| 1885 | ExpectFalseStart: true, |
| 1886 | }, |
| 1887 | }, |
| 1888 | flags: []string{ |
| 1889 | "-false-start", |
| 1890 | "-handshake-never-done", |
| 1891 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1892 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1893 | }, |
| 1894 | shimWritesFirst: true, |
| 1895 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1896 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1897 | }, |
| 1898 | { |
| 1899 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1900 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1901 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1902 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1903 | NextProtos: []string{"foo"}, |
| 1904 | Bugs: ProtocolBugs{ |
| 1905 | SkipNewSessionTicket: true, |
| 1906 | SkipChangeCipherSpec: true, |
| 1907 | SkipFinished: true, |
| 1908 | }, |
| 1909 | }, |
| 1910 | flags: []string{ |
| 1911 | "-implicit-handshake", |
| 1912 | "-false-start", |
| 1913 | "-handshake-never-done", |
| 1914 | "-advertise-alpn", "\x03foo", |
| 1915 | }, |
| 1916 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1917 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1918 | }, |
| 1919 | { |
| 1920 | testType: serverTest, |
| 1921 | name: "FailEarlyCallback", |
| 1922 | flags: []string{"-fail-early-callback"}, |
| 1923 | shouldFail: true, |
| 1924 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1925 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1926 | }, |
| 1927 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1928 | name: "FailCertCallback-Client-TLS12", |
| 1929 | config: Config{ |
| 1930 | MaxVersion: VersionTLS12, |
| 1931 | ClientAuth: RequestClientCert, |
| 1932 | }, |
| 1933 | flags: []string{"-fail-cert-callback"}, |
| 1934 | shouldFail: true, |
| 1935 | expectedError: ":CERT_CB_ERROR:", |
| 1936 | expectedLocalError: "remote error: internal error", |
| 1937 | }, |
| 1938 | { |
| 1939 | testType: serverTest, |
| 1940 | name: "FailCertCallback-Server-TLS12", |
| 1941 | config: Config{ |
| 1942 | MaxVersion: VersionTLS12, |
| 1943 | }, |
| 1944 | flags: []string{"-fail-cert-callback"}, |
| 1945 | shouldFail: true, |
| 1946 | expectedError: ":CERT_CB_ERROR:", |
| 1947 | expectedLocalError: "remote error: internal error", |
| 1948 | }, |
| 1949 | { |
| 1950 | name: "FailCertCallback-Client-TLS13", |
| 1951 | config: Config{ |
| 1952 | MaxVersion: VersionTLS13, |
| 1953 | ClientAuth: RequestClientCert, |
| 1954 | }, |
| 1955 | flags: []string{"-fail-cert-callback"}, |
| 1956 | shouldFail: true, |
| 1957 | expectedError: ":CERT_CB_ERROR:", |
| 1958 | expectedLocalError: "remote error: internal error", |
| 1959 | }, |
| 1960 | { |
| 1961 | testType: serverTest, |
| 1962 | name: "FailCertCallback-Server-TLS13", |
| 1963 | config: Config{ |
| 1964 | MaxVersion: VersionTLS13, |
| 1965 | }, |
| 1966 | flags: []string{"-fail-cert-callback"}, |
| 1967 | shouldFail: true, |
| 1968 | expectedError: ":CERT_CB_ERROR:", |
| 1969 | expectedLocalError: "remote error: internal error", |
| 1970 | }, |
| 1971 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1972 | protocol: dtls, |
| 1973 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1974 | config: Config{ |
| 1975 | Bugs: ProtocolBugs{ |
| 1976 | MaxHandshakeRecordLength: 2, |
| 1977 | FragmentMessageTypeMismatch: true, |
| 1978 | }, |
| 1979 | }, |
| 1980 | shouldFail: true, |
| 1981 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1982 | }, |
| 1983 | { |
| 1984 | protocol: dtls, |
| 1985 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1986 | config: Config{ |
| 1987 | Bugs: ProtocolBugs{ |
| 1988 | MaxHandshakeRecordLength: 2, |
| 1989 | FragmentMessageLengthMismatch: true, |
| 1990 | }, |
| 1991 | }, |
| 1992 | shouldFail: true, |
| 1993 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1994 | }, |
| 1995 | { |
| 1996 | protocol: dtls, |
| 1997 | name: "SplitFragments-Header-DTLS", |
| 1998 | config: Config{ |
| 1999 | Bugs: ProtocolBugs{ |
| 2000 | SplitFragments: 2, |
| 2001 | }, |
| 2002 | }, |
| 2003 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2004 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2005 | }, |
| 2006 | { |
| 2007 | protocol: dtls, |
| 2008 | name: "SplitFragments-Boundary-DTLS", |
| 2009 | config: Config{ |
| 2010 | Bugs: ProtocolBugs{ |
| 2011 | SplitFragments: dtlsRecordHeaderLen, |
| 2012 | }, |
| 2013 | }, |
| 2014 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2015 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2016 | }, |
| 2017 | { |
| 2018 | protocol: dtls, |
| 2019 | name: "SplitFragments-Body-DTLS", |
| 2020 | config: Config{ |
| 2021 | Bugs: ProtocolBugs{ |
| 2022 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 2023 | }, |
| 2024 | }, |
| 2025 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2026 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2027 | }, |
| 2028 | { |
| 2029 | protocol: dtls, |
| 2030 | name: "SendEmptyFragments-DTLS", |
| 2031 | config: Config{ |
| 2032 | Bugs: ProtocolBugs{ |
| 2033 | SendEmptyFragments: true, |
| 2034 | }, |
| 2035 | }, |
| 2036 | }, |
| 2037 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2038 | name: "BadFinished-Client", |
| 2039 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2040 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2041 | Bugs: ProtocolBugs{ |
| 2042 | BadFinished: true, |
| 2043 | }, |
| 2044 | }, |
| 2045 | shouldFail: true, |
| 2046 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2047 | }, |
| 2048 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2049 | name: "BadFinished-Client-TLS13", |
| 2050 | config: Config{ |
| 2051 | MaxVersion: VersionTLS13, |
| 2052 | Bugs: ProtocolBugs{ |
| 2053 | BadFinished: true, |
| 2054 | }, |
| 2055 | }, |
| 2056 | shouldFail: true, |
| 2057 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2058 | }, |
| 2059 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2060 | testType: serverTest, |
| 2061 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2062 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2063 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2064 | Bugs: ProtocolBugs{ |
| 2065 | BadFinished: true, |
| 2066 | }, |
| 2067 | }, |
| 2068 | shouldFail: true, |
| 2069 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2070 | }, |
| 2071 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2072 | testType: serverTest, |
| 2073 | name: "BadFinished-Server-TLS13", |
| 2074 | config: Config{ |
| 2075 | MaxVersion: VersionTLS13, |
| 2076 | Bugs: ProtocolBugs{ |
| 2077 | BadFinished: true, |
| 2078 | }, |
| 2079 | }, |
| 2080 | shouldFail: true, |
| 2081 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2082 | }, |
| 2083 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2084 | name: "FalseStart-BadFinished", |
| 2085 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2086 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2087 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2088 | NextProtos: []string{"foo"}, |
| 2089 | Bugs: ProtocolBugs{ |
| 2090 | BadFinished: true, |
| 2091 | ExpectFalseStart: true, |
| 2092 | }, |
| 2093 | }, |
| 2094 | flags: []string{ |
| 2095 | "-false-start", |
| 2096 | "-handshake-never-done", |
| 2097 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 2098 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2099 | }, |
| 2100 | shimWritesFirst: true, |
| 2101 | shouldFail: true, |
| 2102 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2103 | }, |
| 2104 | { |
| 2105 | name: "NoFalseStart-NoALPN", |
| 2106 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2107 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2108 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2109 | Bugs: ProtocolBugs{ |
| 2110 | ExpectFalseStart: true, |
| 2111 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2112 | }, |
| 2113 | }, |
| 2114 | flags: []string{ |
| 2115 | "-false-start", |
| 2116 | }, |
| 2117 | shimWritesFirst: true, |
| 2118 | shouldFail: true, |
| 2119 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2120 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2121 | }, |
| 2122 | { |
| 2123 | name: "NoFalseStart-NoAEAD", |
| 2124 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2125 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2126 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2127 | NextProtos: []string{"foo"}, |
| 2128 | Bugs: ProtocolBugs{ |
| 2129 | ExpectFalseStart: true, |
| 2130 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2131 | }, |
| 2132 | }, |
| 2133 | flags: []string{ |
| 2134 | "-false-start", |
| 2135 | "-advertise-alpn", "\x03foo", |
| 2136 | }, |
| 2137 | shimWritesFirst: true, |
| 2138 | shouldFail: true, |
| 2139 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2140 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2141 | }, |
| 2142 | { |
| 2143 | name: "NoFalseStart-RSA", |
| 2144 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2145 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2146 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2147 | NextProtos: []string{"foo"}, |
| 2148 | Bugs: ProtocolBugs{ |
| 2149 | ExpectFalseStart: true, |
| 2150 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2151 | }, |
| 2152 | }, |
| 2153 | flags: []string{ |
| 2154 | "-false-start", |
| 2155 | "-advertise-alpn", "\x03foo", |
| 2156 | }, |
| 2157 | shimWritesFirst: true, |
| 2158 | shouldFail: true, |
| 2159 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2160 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2161 | }, |
| 2162 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2163 | protocol: dtls, |
| 2164 | name: "SendSplitAlert-Sync", |
| 2165 | config: Config{ |
| 2166 | Bugs: ProtocolBugs{ |
| 2167 | SendSplitAlert: true, |
| 2168 | }, |
| 2169 | }, |
| 2170 | }, |
| 2171 | { |
| 2172 | protocol: dtls, |
| 2173 | name: "SendSplitAlert-Async", |
| 2174 | config: Config{ |
| 2175 | Bugs: ProtocolBugs{ |
| 2176 | SendSplitAlert: true, |
| 2177 | }, |
| 2178 | }, |
| 2179 | flags: []string{"-async"}, |
| 2180 | }, |
| 2181 | { |
| 2182 | protocol: dtls, |
| 2183 | name: "PackDTLSHandshake", |
| 2184 | config: Config{ |
| 2185 | Bugs: ProtocolBugs{ |
| 2186 | MaxHandshakeRecordLength: 2, |
| 2187 | PackHandshakeFragments: 20, |
| 2188 | PackHandshakeRecords: 200, |
| 2189 | }, |
| 2190 | }, |
| 2191 | }, |
| 2192 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2193 | name: "SendEmptyRecords-Pass", |
| 2194 | sendEmptyRecords: 32, |
| 2195 | }, |
| 2196 | { |
| 2197 | name: "SendEmptyRecords", |
| 2198 | sendEmptyRecords: 33, |
| 2199 | shouldFail: true, |
| 2200 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2201 | }, |
| 2202 | { |
| 2203 | name: "SendEmptyRecords-Async", |
| 2204 | sendEmptyRecords: 33, |
| 2205 | flags: []string{"-async"}, |
| 2206 | shouldFail: true, |
| 2207 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2208 | }, |
| 2209 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2210 | name: "SendWarningAlerts-Pass", |
| 2211 | config: Config{ |
| 2212 | MaxVersion: VersionTLS12, |
| 2213 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2214 | sendWarningAlerts: 4, |
| 2215 | }, |
| 2216 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2217 | protocol: dtls, |
| 2218 | name: "SendWarningAlerts-DTLS-Pass", |
| 2219 | config: Config{ |
| 2220 | MaxVersion: VersionTLS12, |
| 2221 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2222 | sendWarningAlerts: 4, |
| 2223 | }, |
| 2224 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2225 | name: "SendWarningAlerts-TLS13", |
| 2226 | config: Config{ |
| 2227 | MaxVersion: VersionTLS13, |
| 2228 | }, |
| 2229 | sendWarningAlerts: 4, |
| 2230 | shouldFail: true, |
| 2231 | expectedError: ":BAD_ALERT:", |
| 2232 | expectedLocalError: "remote error: error decoding message", |
| 2233 | }, |
| 2234 | { |
| 2235 | name: "SendWarningAlerts", |
| 2236 | config: Config{ |
| 2237 | MaxVersion: VersionTLS12, |
| 2238 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2239 | sendWarningAlerts: 5, |
| 2240 | shouldFail: true, |
| 2241 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2242 | }, |
| 2243 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2244 | name: "SendWarningAlerts-Async", |
| 2245 | config: Config{ |
| 2246 | MaxVersion: VersionTLS12, |
| 2247 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2248 | sendWarningAlerts: 5, |
| 2249 | flags: []string{"-async"}, |
| 2250 | shouldFail: true, |
| 2251 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2252 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2253 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2254 | name: "SendBogusAlertType", |
| 2255 | sendBogusAlertType: true, |
| 2256 | shouldFail: true, |
| 2257 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2258 | expectedLocalError: "remote error: illegal parameter", |
| 2259 | }, |
| 2260 | { |
| 2261 | protocol: dtls, |
| 2262 | name: "SendBogusAlertType-DTLS", |
| 2263 | sendBogusAlertType: true, |
| 2264 | shouldFail: true, |
| 2265 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2266 | expectedLocalError: "remote error: illegal parameter", |
| 2267 | }, |
| 2268 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2269 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2270 | config: Config{ |
| 2271 | MaxVersion: VersionTLS13, |
| 2272 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2273 | sendKeyUpdates: 33, |
| 2274 | keyUpdateRequest: keyUpdateNotRequested, |
| 2275 | shouldFail: true, |
| 2276 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2277 | }, |
| 2278 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2279 | name: "EmptySessionID", |
| 2280 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2281 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2282 | SessionTicketsDisabled: true, |
| 2283 | }, |
| 2284 | noSessionCache: true, |
| 2285 | flags: []string{"-expect-no-session"}, |
| 2286 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2287 | { |
| 2288 | name: "Unclean-Shutdown", |
| 2289 | config: Config{ |
| 2290 | Bugs: ProtocolBugs{ |
| 2291 | NoCloseNotify: true, |
| 2292 | ExpectCloseNotify: true, |
| 2293 | }, |
| 2294 | }, |
| 2295 | shimShutsDown: true, |
| 2296 | flags: []string{"-check-close-notify"}, |
| 2297 | shouldFail: true, |
| 2298 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2299 | }, |
| 2300 | { |
| 2301 | name: "Unclean-Shutdown-Ignored", |
| 2302 | config: Config{ |
| 2303 | Bugs: ProtocolBugs{ |
| 2304 | NoCloseNotify: true, |
| 2305 | }, |
| 2306 | }, |
| 2307 | shimShutsDown: true, |
| 2308 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2309 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2310 | name: "Unclean-Shutdown-Alert", |
| 2311 | config: Config{ |
| 2312 | Bugs: ProtocolBugs{ |
| 2313 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2314 | ExpectCloseNotify: true, |
| 2315 | }, |
| 2316 | }, |
| 2317 | shimShutsDown: true, |
| 2318 | flags: []string{"-check-close-notify"}, |
| 2319 | shouldFail: true, |
| 2320 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2321 | }, |
| 2322 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2323 | name: "LargePlaintext", |
| 2324 | config: Config{ |
| 2325 | Bugs: ProtocolBugs{ |
| 2326 | SendLargeRecords: true, |
| 2327 | }, |
| 2328 | }, |
| 2329 | messageLen: maxPlaintext + 1, |
| 2330 | shouldFail: true, |
| 2331 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2332 | }, |
| 2333 | { |
| 2334 | protocol: dtls, |
| 2335 | name: "LargePlaintext-DTLS", |
| 2336 | config: Config{ |
| 2337 | Bugs: ProtocolBugs{ |
| 2338 | SendLargeRecords: true, |
| 2339 | }, |
| 2340 | }, |
| 2341 | messageLen: maxPlaintext + 1, |
| 2342 | shouldFail: true, |
| 2343 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2344 | }, |
| 2345 | { |
| 2346 | name: "LargeCiphertext", |
| 2347 | config: Config{ |
| 2348 | Bugs: ProtocolBugs{ |
| 2349 | SendLargeRecords: true, |
| 2350 | }, |
| 2351 | }, |
| 2352 | messageLen: maxPlaintext * 2, |
| 2353 | shouldFail: true, |
| 2354 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2355 | }, |
| 2356 | { |
| 2357 | protocol: dtls, |
| 2358 | name: "LargeCiphertext-DTLS", |
| 2359 | config: Config{ |
| 2360 | Bugs: ProtocolBugs{ |
| 2361 | SendLargeRecords: true, |
| 2362 | }, |
| 2363 | }, |
| 2364 | messageLen: maxPlaintext * 2, |
| 2365 | // Unlike the other four cases, DTLS drops records which |
| 2366 | // are invalid before authentication, so the connection |
| 2367 | // does not fail. |
| 2368 | expectMessageDropped: true, |
| 2369 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2370 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2371 | name: "BadHelloRequest-1", |
| 2372 | renegotiate: 1, |
| 2373 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2374 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2375 | Bugs: ProtocolBugs{ |
| 2376 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2377 | }, |
| 2378 | }, |
| 2379 | flags: []string{ |
| 2380 | "-renegotiate-freely", |
| 2381 | "-expect-total-renegotiations", "1", |
| 2382 | }, |
| 2383 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2384 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2385 | }, |
| 2386 | { |
| 2387 | name: "BadHelloRequest-2", |
| 2388 | renegotiate: 1, |
| 2389 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2390 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2391 | Bugs: ProtocolBugs{ |
| 2392 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2393 | }, |
| 2394 | }, |
| 2395 | flags: []string{ |
| 2396 | "-renegotiate-freely", |
| 2397 | "-expect-total-renegotiations", "1", |
| 2398 | }, |
| 2399 | shouldFail: true, |
| 2400 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2401 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2402 | { |
| 2403 | testType: serverTest, |
| 2404 | name: "SupportTicketsWithSessionID", |
| 2405 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2406 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2407 | SessionTicketsDisabled: true, |
| 2408 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2409 | resumeConfig: &Config{ |
| 2410 | MaxVersion: VersionTLS12, |
| 2411 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2412 | resumeSession: true, |
| 2413 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2414 | { |
| 2415 | protocol: dtls, |
| 2416 | name: "DTLS-SendExtraFinished", |
| 2417 | config: Config{ |
| 2418 | Bugs: ProtocolBugs{ |
| 2419 | SendExtraFinished: true, |
| 2420 | }, |
| 2421 | }, |
| 2422 | shouldFail: true, |
| 2423 | expectedError: ":UNEXPECTED_RECORD:", |
| 2424 | }, |
| 2425 | { |
| 2426 | protocol: dtls, |
| 2427 | name: "DTLS-SendExtraFinished-Reordered", |
| 2428 | config: Config{ |
| 2429 | Bugs: ProtocolBugs{ |
| 2430 | MaxHandshakeRecordLength: 2, |
| 2431 | ReorderHandshakeFragments: true, |
| 2432 | SendExtraFinished: true, |
| 2433 | }, |
| 2434 | }, |
| 2435 | shouldFail: true, |
| 2436 | expectedError: ":UNEXPECTED_RECORD:", |
| 2437 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2438 | { |
| 2439 | testType: serverTest, |
| 2440 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2441 | config: Config{ |
| 2442 | // Choose a cipher suite that does not involve |
| 2443 | // elliptic curves, so no extensions are |
| 2444 | // involved. |
| 2445 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2446 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2447 | Bugs: ProtocolBugs{ |
| 2448 | SendV2ClientHello: true, |
| 2449 | }, |
| 2450 | }, |
| 2451 | sendPrefix: string([]byte{ |
| 2452 | byte(recordTypeHandshake), |
| 2453 | 3, 1, // version |
| 2454 | 0, 0, // length |
| 2455 | }), |
| 2456 | // A no-op empty record may not be sent before V2ClientHello. |
| 2457 | shouldFail: true, |
| 2458 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2459 | }, |
| 2460 | { |
| 2461 | testType: serverTest, |
| 2462 | name: "V2ClientHello-WarningAlertPrefix", |
| 2463 | config: Config{ |
| 2464 | // Choose a cipher suite that does not involve |
| 2465 | // elliptic curves, so no extensions are |
| 2466 | // involved. |
| 2467 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2468 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2469 | Bugs: ProtocolBugs{ |
| 2470 | SendV2ClientHello: true, |
| 2471 | }, |
| 2472 | }, |
| 2473 | sendPrefix: string([]byte{ |
| 2474 | byte(recordTypeAlert), |
| 2475 | 3, 1, // version |
| 2476 | 0, 2, // length |
| 2477 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2478 | }), |
| 2479 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2480 | shouldFail: true, |
| 2481 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2482 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2483 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2484 | name: "KeyUpdate-Client", |
| 2485 | config: Config{ |
| 2486 | MaxVersion: VersionTLS13, |
| 2487 | }, |
| 2488 | sendKeyUpdates: 1, |
| 2489 | keyUpdateRequest: keyUpdateNotRequested, |
| 2490 | }, |
| 2491 | { |
| 2492 | testType: serverTest, |
| 2493 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2494 | config: Config{ |
| 2495 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2496 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2497 | sendKeyUpdates: 1, |
| 2498 | keyUpdateRequest: keyUpdateNotRequested, |
| 2499 | }, |
| 2500 | { |
| 2501 | name: "KeyUpdate-InvalidRequestMode", |
| 2502 | config: Config{ |
| 2503 | MaxVersion: VersionTLS13, |
| 2504 | }, |
| 2505 | sendKeyUpdates: 1, |
| 2506 | keyUpdateRequest: 42, |
| 2507 | shouldFail: true, |
| 2508 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2509 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2510 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2511 | // Test that KeyUpdates are acknowledged properly. |
| 2512 | name: "KeyUpdate-RequestACK", |
| 2513 | config: Config{ |
| 2514 | MaxVersion: VersionTLS13, |
| 2515 | Bugs: ProtocolBugs{ |
| 2516 | RejectUnsolicitedKeyUpdate: true, |
| 2517 | }, |
| 2518 | }, |
| 2519 | // Test the shim receiving many KeyUpdates in a row. |
| 2520 | sendKeyUpdates: 5, |
| 2521 | messageCount: 5, |
| 2522 | keyUpdateRequest: keyUpdateRequested, |
| 2523 | }, |
| 2524 | { |
| 2525 | // Test that KeyUpdates are acknowledged properly if the |
| 2526 | // peer's KeyUpdate is discovered while a write is |
| 2527 | // pending. |
| 2528 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2529 | config: Config{ |
| 2530 | MaxVersion: VersionTLS13, |
| 2531 | Bugs: ProtocolBugs{ |
| 2532 | RejectUnsolicitedKeyUpdate: true, |
| 2533 | }, |
| 2534 | }, |
| 2535 | // Test the shim receiving many KeyUpdates in a row. |
| 2536 | sendKeyUpdates: 5, |
| 2537 | messageCount: 5, |
| 2538 | keyUpdateRequest: keyUpdateRequested, |
| 2539 | readWithUnfinishedWrite: true, |
| 2540 | flags: []string{"-async"}, |
| 2541 | }, |
| 2542 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2543 | name: "SendSNIWarningAlert", |
| 2544 | config: Config{ |
| 2545 | MaxVersion: VersionTLS12, |
| 2546 | Bugs: ProtocolBugs{ |
| 2547 | SendSNIWarningAlert: true, |
| 2548 | }, |
| 2549 | }, |
| 2550 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2551 | { |
| 2552 | testType: serverTest, |
| 2553 | name: "ExtraCompressionMethods-TLS12", |
| 2554 | config: Config{ |
| 2555 | MaxVersion: VersionTLS12, |
| 2556 | Bugs: ProtocolBugs{ |
| 2557 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2558 | }, |
| 2559 | }, |
| 2560 | }, |
| 2561 | { |
| 2562 | testType: serverTest, |
| 2563 | name: "ExtraCompressionMethods-TLS13", |
| 2564 | config: Config{ |
| 2565 | MaxVersion: VersionTLS13, |
| 2566 | Bugs: ProtocolBugs{ |
| 2567 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2568 | }, |
| 2569 | }, |
| 2570 | shouldFail: true, |
| 2571 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2572 | expectedLocalError: "remote error: illegal parameter", |
| 2573 | }, |
| 2574 | { |
| 2575 | testType: serverTest, |
| 2576 | name: "NoNullCompression-TLS12", |
| 2577 | config: Config{ |
| 2578 | MaxVersion: VersionTLS12, |
| 2579 | Bugs: ProtocolBugs{ |
| 2580 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2581 | }, |
| 2582 | }, |
| 2583 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2584 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2585 | expectedLocalError: "remote error: illegal parameter", |
| 2586 | }, |
| 2587 | { |
| 2588 | testType: serverTest, |
| 2589 | name: "NoNullCompression-TLS13", |
| 2590 | config: Config{ |
| 2591 | MaxVersion: VersionTLS13, |
| 2592 | Bugs: ProtocolBugs{ |
| 2593 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2594 | }, |
| 2595 | }, |
| 2596 | shouldFail: true, |
| 2597 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2598 | expectedLocalError: "remote error: illegal parameter", |
| 2599 | }, |
David Benjamin | 413e79e | 2017-07-01 10:11:53 -0400 | [diff] [blame] | 2600 | // Test that the client rejects invalid compression methods |
| 2601 | // from the server. |
| 2602 | { |
| 2603 | testType: clientTest, |
| 2604 | name: "InvalidCompressionMethod", |
| 2605 | config: Config{ |
| 2606 | MaxVersion: VersionTLS12, |
| 2607 | Bugs: ProtocolBugs{ |
| 2608 | SendCompressionMethod: 1, |
| 2609 | }, |
| 2610 | }, |
| 2611 | shouldFail: true, |
| 2612 | expectedError: ":UNSUPPORTED_COMPRESSION_ALGORITHM:", |
| 2613 | expectedLocalError: "remote error: illegal parameter", |
| 2614 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2615 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2616 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2617 | config: Config{ |
| 2618 | MaxVersion: VersionTLS12, |
| 2619 | Bugs: ProtocolBugs{ |
| 2620 | ExpectGREASE: true, |
| 2621 | }, |
| 2622 | }, |
| 2623 | flags: []string{"-enable-grease"}, |
| 2624 | }, |
| 2625 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2626 | name: "GREASE-Client-TLS13", |
| 2627 | config: Config{ |
| 2628 | MaxVersion: VersionTLS13, |
| 2629 | Bugs: ProtocolBugs{ |
| 2630 | ExpectGREASE: true, |
| 2631 | }, |
| 2632 | }, |
| 2633 | flags: []string{"-enable-grease"}, |
| 2634 | }, |
| 2635 | { |
| 2636 | testType: serverTest, |
| 2637 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2638 | config: Config{ |
| 2639 | MaxVersion: VersionTLS13, |
| 2640 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2641 | // TLS 1.3 servers are expected to |
| 2642 | // always enable GREASE. TLS 1.3 is new, |
| 2643 | // so there is no existing ecosystem to |
| 2644 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2645 | ExpectGREASE: true, |
| 2646 | }, |
| 2647 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2648 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2649 | { |
| 2650 | // Test the server so there is a large certificate as |
| 2651 | // well as application data. |
| 2652 | testType: serverTest, |
| 2653 | name: "MaxSendFragment", |
| 2654 | config: Config{ |
| 2655 | Bugs: ProtocolBugs{ |
| 2656 | MaxReceivePlaintext: 512, |
| 2657 | }, |
| 2658 | }, |
| 2659 | messageLen: 1024, |
| 2660 | flags: []string{ |
| 2661 | "-max-send-fragment", "512", |
| 2662 | "-read-size", "1024", |
| 2663 | }, |
| 2664 | }, |
| 2665 | { |
| 2666 | // Test the server so there is a large certificate as |
| 2667 | // well as application data. |
| 2668 | testType: serverTest, |
| 2669 | name: "MaxSendFragment-TooLarge", |
| 2670 | config: Config{ |
| 2671 | Bugs: ProtocolBugs{ |
| 2672 | // Ensure that some of the records are |
| 2673 | // 512. |
| 2674 | MaxReceivePlaintext: 511, |
| 2675 | }, |
| 2676 | }, |
| 2677 | messageLen: 1024, |
| 2678 | flags: []string{ |
| 2679 | "-max-send-fragment", "512", |
| 2680 | "-read-size", "1024", |
| 2681 | }, |
| 2682 | shouldFail: true, |
| 2683 | expectedLocalError: "local error: record overflow", |
| 2684 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2685 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2686 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2687 | |
| 2688 | // Test that very large messages can be received. |
| 2689 | cert := rsaCertificate |
| 2690 | for i := 0; i < 50; i++ { |
| 2691 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2692 | } |
| 2693 | testCases = append(testCases, testCase{ |
| 2694 | name: "LargeMessage", |
| 2695 | config: Config{ |
| 2696 | Certificates: []Certificate{cert}, |
| 2697 | }, |
| 2698 | }) |
| 2699 | testCases = append(testCases, testCase{ |
| 2700 | protocol: dtls, |
| 2701 | name: "LargeMessage-DTLS", |
| 2702 | config: Config{ |
| 2703 | Certificates: []Certificate{cert}, |
| 2704 | }, |
| 2705 | }) |
| 2706 | |
| 2707 | // They are rejected if the maximum certificate chain length is capped. |
| 2708 | testCases = append(testCases, testCase{ |
| 2709 | name: "LargeMessage-Reject", |
| 2710 | config: Config{ |
| 2711 | Certificates: []Certificate{cert}, |
| 2712 | }, |
| 2713 | flags: []string{"-max-cert-list", "16384"}, |
| 2714 | shouldFail: true, |
| 2715 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2716 | }) |
| 2717 | testCases = append(testCases, testCase{ |
| 2718 | protocol: dtls, |
| 2719 | name: "LargeMessage-Reject-DTLS", |
| 2720 | config: Config{ |
| 2721 | Certificates: []Certificate{cert}, |
| 2722 | }, |
| 2723 | flags: []string{"-max-cert-list", "16384"}, |
| 2724 | shouldFail: true, |
| 2725 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2726 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2727 | } |
| 2728 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2729 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2730 | const psk = "12345" |
| 2731 | const pskIdentity = "luggage combo" |
| 2732 | |
| 2733 | var prefix string |
| 2734 | if protocol == dtls { |
| 2735 | if !ver.hasDTLS { |
| 2736 | return |
| 2737 | } |
| 2738 | prefix = "D" |
| 2739 | } |
| 2740 | |
| 2741 | var cert Certificate |
| 2742 | var certFile string |
| 2743 | var keyFile string |
| 2744 | if hasComponent(suite.name, "ECDSA") { |
| 2745 | cert = ecdsaP256Certificate |
| 2746 | certFile = ecdsaP256CertificateFile |
| 2747 | keyFile = ecdsaP256KeyFile |
| 2748 | } else { |
| 2749 | cert = rsaCertificate |
| 2750 | certFile = rsaCertificateFile |
| 2751 | keyFile = rsaKeyFile |
| 2752 | } |
| 2753 | |
| 2754 | var flags []string |
| 2755 | if hasComponent(suite.name, "PSK") { |
| 2756 | flags = append(flags, |
| 2757 | "-psk", psk, |
| 2758 | "-psk-identity", pskIdentity) |
| 2759 | } |
| 2760 | if hasComponent(suite.name, "NULL") { |
| 2761 | // NULL ciphers must be explicitly enabled. |
| 2762 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2763 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2764 | |
| 2765 | var shouldServerFail, shouldClientFail bool |
| 2766 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2767 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2768 | // a BoringSSL server will never select it |
| 2769 | // because the extension is missing. |
| 2770 | shouldServerFail = true |
| 2771 | } |
| 2772 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2773 | shouldClientFail = true |
| 2774 | shouldServerFail = true |
| 2775 | } |
| 2776 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2777 | shouldClientFail = true |
| 2778 | shouldServerFail = true |
| 2779 | } |
| 2780 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2781 | shouldClientFail = true |
| 2782 | shouldServerFail = true |
| 2783 | } |
| 2784 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2785 | shouldClientFail = true |
| 2786 | shouldServerFail = true |
| 2787 | } |
| 2788 | |
| 2789 | var sendCipherSuite uint16 |
| 2790 | var expectedServerError, expectedClientError string |
| 2791 | serverCipherSuites := []uint16{suite.id} |
| 2792 | if shouldServerFail { |
| 2793 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2794 | } |
| 2795 | if shouldClientFail { |
| 2796 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2797 | // Configure the server to select ciphers as normal but |
| 2798 | // select an incompatible cipher in ServerHello. |
| 2799 | serverCipherSuites = nil |
| 2800 | sendCipherSuite = suite.id |
| 2801 | } |
| 2802 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2803 | // For cipher suites and versions where exporters are defined, verify |
| 2804 | // that they interoperate. |
| 2805 | var exportKeyingMaterial int |
| 2806 | if ver.version > VersionSSL30 { |
| 2807 | exportKeyingMaterial = 1024 |
| 2808 | } |
| 2809 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2810 | testCases = append(testCases, testCase{ |
| 2811 | testType: serverTest, |
| 2812 | protocol: protocol, |
| 2813 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2814 | config: Config{ |
| 2815 | MinVersion: ver.version, |
| 2816 | MaxVersion: ver.version, |
| 2817 | CipherSuites: []uint16{suite.id}, |
| 2818 | Certificates: []Certificate{cert}, |
| 2819 | PreSharedKey: []byte(psk), |
| 2820 | PreSharedKeyIdentity: pskIdentity, |
| 2821 | Bugs: ProtocolBugs{ |
| 2822 | AdvertiseAllConfiguredCiphers: true, |
| 2823 | }, |
| 2824 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2825 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2826 | certFile: certFile, |
| 2827 | keyFile: keyFile, |
| 2828 | flags: flags, |
| 2829 | resumeSession: true, |
| 2830 | shouldFail: shouldServerFail, |
| 2831 | expectedError: expectedServerError, |
| 2832 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2833 | }) |
| 2834 | |
| 2835 | testCases = append(testCases, testCase{ |
| 2836 | testType: clientTest, |
| 2837 | protocol: protocol, |
| 2838 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2839 | config: Config{ |
| 2840 | MinVersion: ver.version, |
| 2841 | MaxVersion: ver.version, |
| 2842 | CipherSuites: serverCipherSuites, |
| 2843 | Certificates: []Certificate{cert}, |
| 2844 | PreSharedKey: []byte(psk), |
| 2845 | PreSharedKeyIdentity: pskIdentity, |
| 2846 | Bugs: ProtocolBugs{ |
| 2847 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2848 | SendCipherSuite: sendCipherSuite, |
| 2849 | }, |
| 2850 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2851 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2852 | flags: flags, |
| 2853 | resumeSession: true, |
| 2854 | shouldFail: shouldClientFail, |
| 2855 | expectedError: expectedClientError, |
| 2856 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2857 | }) |
| 2858 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2859 | if shouldClientFail { |
| 2860 | return |
| 2861 | } |
| 2862 | |
| 2863 | // Ensure the maximum record size is accepted. |
| 2864 | testCases = append(testCases, testCase{ |
| 2865 | protocol: protocol, |
| 2866 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2867 | config: Config{ |
| 2868 | MinVersion: ver.version, |
| 2869 | MaxVersion: ver.version, |
| 2870 | CipherSuites: []uint16{suite.id}, |
| 2871 | Certificates: []Certificate{cert}, |
| 2872 | PreSharedKey: []byte(psk), |
| 2873 | PreSharedKeyIdentity: pskIdentity, |
| 2874 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2875 | tls13Variant: ver.tls13Variant, |
| 2876 | flags: flags, |
| 2877 | messageLen: maxPlaintext, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2878 | }) |
| 2879 | |
| 2880 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2881 | // and ignored in DTLS. |
| 2882 | var shouldFail bool |
| 2883 | var expectedError string |
| 2884 | if protocol == tls { |
| 2885 | shouldFail = true |
| 2886 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2887 | } |
| 2888 | |
| 2889 | testCases = append(testCases, testCase{ |
| 2890 | protocol: protocol, |
| 2891 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2892 | config: Config{ |
| 2893 | MinVersion: ver.version, |
| 2894 | MaxVersion: ver.version, |
| 2895 | CipherSuites: []uint16{suite.id}, |
| 2896 | Certificates: []Certificate{cert}, |
| 2897 | PreSharedKey: []byte(psk), |
| 2898 | PreSharedKeyIdentity: pskIdentity, |
| 2899 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2900 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2901 | flags: flags, |
| 2902 | damageFirstWrite: true, |
| 2903 | messageLen: maxPlaintext, |
| 2904 | shouldFail: shouldFail, |
| 2905 | expectedError: expectedError, |
| 2906 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2907 | } |
| 2908 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2909 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2910 | const bogusCipher = 0xfe00 |
| 2911 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2912 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2913 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2914 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2915 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2916 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2917 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2918 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2919 | |
| 2920 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2921 | name: "NoSharedCipher", |
| 2922 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2923 | MaxVersion: VersionTLS12, |
| 2924 | CipherSuites: []uint16{}, |
| 2925 | }, |
| 2926 | shouldFail: true, |
| 2927 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2928 | }) |
| 2929 | |
| 2930 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2931 | name: "NoSharedCipher-TLS13", |
| 2932 | config: Config{ |
| 2933 | MaxVersion: VersionTLS13, |
| 2934 | CipherSuites: []uint16{}, |
| 2935 | }, |
| 2936 | shouldFail: true, |
| 2937 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2938 | }) |
| 2939 | |
| 2940 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2941 | name: "UnsupportedCipherSuite", |
| 2942 | config: Config{ |
| 2943 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2944 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2945 | Bugs: ProtocolBugs{ |
| 2946 | IgnorePeerCipherPreferences: true, |
| 2947 | }, |
| 2948 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2949 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2950 | shouldFail: true, |
| 2951 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2952 | }) |
| 2953 | |
| 2954 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2955 | name: "ServerHelloBogusCipher", |
| 2956 | config: Config{ |
| 2957 | MaxVersion: VersionTLS12, |
| 2958 | Bugs: ProtocolBugs{ |
| 2959 | SendCipherSuite: bogusCipher, |
| 2960 | }, |
| 2961 | }, |
| 2962 | shouldFail: true, |
| 2963 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2964 | }) |
| 2965 | testCases = append(testCases, testCase{ |
| 2966 | name: "ServerHelloBogusCipher-TLS13", |
| 2967 | config: Config{ |
| 2968 | MaxVersion: VersionTLS13, |
| 2969 | Bugs: ProtocolBugs{ |
| 2970 | SendCipherSuite: bogusCipher, |
| 2971 | }, |
| 2972 | }, |
| 2973 | shouldFail: true, |
| 2974 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2975 | }) |
| 2976 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2977 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2978 | testCases = append(testCases, testCase{ |
| 2979 | testType: serverTest, |
| 2980 | name: "UnknownCipher", |
| 2981 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2982 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2983 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2984 | Bugs: ProtocolBugs{ |
| 2985 | AdvertiseAllConfiguredCiphers: true, |
| 2986 | }, |
| 2987 | }, |
| 2988 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2989 | |
| 2990 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2991 | testCases = append(testCases, testCase{ |
| 2992 | testType: serverTest, |
| 2993 | name: "UnknownCipher-TLS13", |
| 2994 | config: Config{ |
| 2995 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2996 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2997 | Bugs: ProtocolBugs{ |
| 2998 | AdvertiseAllConfiguredCiphers: true, |
| 2999 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3000 | }, |
| 3001 | }) |
| 3002 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 3003 | // Test empty ECDHE_PSK identity hints work as expected. |
| 3004 | testCases = append(testCases, testCase{ |
| 3005 | name: "EmptyECDHEPSKHint", |
| 3006 | config: Config{ |
| 3007 | MaxVersion: VersionTLS12, |
| 3008 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3009 | PreSharedKey: []byte("secret"), |
| 3010 | }, |
| 3011 | flags: []string{"-psk", "secret"}, |
| 3012 | }) |
| 3013 | |
| 3014 | // Test empty PSK identity hints work as expected, even if an explicit |
| 3015 | // ServerKeyExchange is sent. |
| 3016 | testCases = append(testCases, testCase{ |
| 3017 | name: "ExplicitEmptyPSKHint", |
| 3018 | config: Config{ |
| 3019 | MaxVersion: VersionTLS12, |
| 3020 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3021 | PreSharedKey: []byte("secret"), |
| 3022 | Bugs: ProtocolBugs{ |
| 3023 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 3024 | }, |
| 3025 | }, |
| 3026 | flags: []string{"-psk", "secret"}, |
| 3027 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 3028 | |
| 3029 | // Test that clients enforce that the server-sent certificate and cipher |
| 3030 | // suite match in TLS 1.2. |
| 3031 | testCases = append(testCases, testCase{ |
| 3032 | name: "CertificateCipherMismatch-RSA", |
| 3033 | config: Config{ |
| 3034 | MaxVersion: VersionTLS12, |
| 3035 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3036 | Certificates: []Certificate{rsaCertificate}, |
| 3037 | Bugs: ProtocolBugs{ |
| 3038 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 3039 | }, |
| 3040 | }, |
| 3041 | shouldFail: true, |
| 3042 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3043 | }) |
| 3044 | testCases = append(testCases, testCase{ |
| 3045 | name: "CertificateCipherMismatch-ECDSA", |
| 3046 | config: Config{ |
| 3047 | MaxVersion: VersionTLS12, |
| 3048 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3049 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3050 | Bugs: ProtocolBugs{ |
| 3051 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3052 | }, |
| 3053 | }, |
| 3054 | shouldFail: true, |
| 3055 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3056 | }) |
| 3057 | testCases = append(testCases, testCase{ |
| 3058 | name: "CertificateCipherMismatch-Ed25519", |
| 3059 | config: Config{ |
| 3060 | MaxVersion: VersionTLS12, |
| 3061 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3062 | Certificates: []Certificate{ed25519Certificate}, |
| 3063 | Bugs: ProtocolBugs{ |
| 3064 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3065 | }, |
| 3066 | }, |
| 3067 | shouldFail: true, |
| 3068 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3069 | }) |
| 3070 | |
| 3071 | // Test that servers decline to select a cipher suite which is |
| 3072 | // inconsistent with their configured certificate. |
| 3073 | testCases = append(testCases, testCase{ |
| 3074 | testType: serverTest, |
| 3075 | name: "ServerCipherFilter-RSA", |
| 3076 | config: Config{ |
| 3077 | MaxVersion: VersionTLS12, |
| 3078 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3079 | }, |
| 3080 | flags: []string{ |
| 3081 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3082 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3083 | }, |
| 3084 | shouldFail: true, |
| 3085 | expectedError: ":NO_SHARED_CIPHER:", |
| 3086 | }) |
| 3087 | testCases = append(testCases, testCase{ |
| 3088 | testType: serverTest, |
| 3089 | name: "ServerCipherFilter-ECDSA", |
| 3090 | config: Config{ |
| 3091 | MaxVersion: VersionTLS12, |
| 3092 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3093 | }, |
| 3094 | flags: []string{ |
| 3095 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3096 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3097 | }, |
| 3098 | shouldFail: true, |
| 3099 | expectedError: ":NO_SHARED_CIPHER:", |
| 3100 | }) |
| 3101 | testCases = append(testCases, testCase{ |
| 3102 | testType: serverTest, |
| 3103 | name: "ServerCipherFilter-Ed25519", |
| 3104 | config: Config{ |
| 3105 | MaxVersion: VersionTLS12, |
| 3106 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3107 | }, |
| 3108 | flags: []string{ |
| 3109 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 3110 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 3111 | }, |
| 3112 | shouldFail: true, |
| 3113 | expectedError: ":NO_SHARED_CIPHER:", |
| 3114 | }) |
David Benjamin | 364af78 | 2017-07-01 10:35:27 -0400 | [diff] [blame] | 3115 | |
| 3116 | // Test cipher suite negotiation works as expected. Configure a |
| 3117 | // complicated cipher suite configuration. |
| 3118 | const negotiationTestCiphers = "" + |
| 3119 | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3120 | "[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]:" + |
| 3121 | "TLS_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3122 | "TLS_RSA_WITH_AES_128_CBC_SHA:" + |
| 3123 | "[TLS_RSA_WITH_AES_256_GCM_SHA384|TLS_RSA_WITH_AES_256_CBC_SHA]" |
| 3124 | negotiationTests := []struct { |
| 3125 | ciphers []uint16 |
| 3126 | expected uint16 |
| 3127 | }{ |
| 3128 | // Server preferences are honored, including when |
| 3129 | // equipreference groups are involved. |
| 3130 | { |
| 3131 | []uint16{ |
| 3132 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3133 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3134 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3135 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3136 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3137 | }, |
| 3138 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3139 | }, |
| 3140 | { |
| 3141 | []uint16{ |
| 3142 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3143 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3144 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3145 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3146 | }, |
| 3147 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3148 | }, |
| 3149 | { |
| 3150 | []uint16{ |
| 3151 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3152 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3153 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3154 | }, |
| 3155 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3156 | }, |
| 3157 | { |
| 3158 | []uint16{ |
| 3159 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3160 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3161 | }, |
| 3162 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3163 | }, |
| 3164 | // Equipreference groups use the client preference. |
| 3165 | { |
| 3166 | []uint16{ |
| 3167 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3168 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3169 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3170 | }, |
| 3171 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3172 | }, |
| 3173 | { |
| 3174 | []uint16{ |
| 3175 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3176 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3177 | }, |
| 3178 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3179 | }, |
| 3180 | { |
| 3181 | []uint16{ |
| 3182 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3183 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3184 | }, |
| 3185 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3186 | }, |
| 3187 | { |
| 3188 | []uint16{ |
| 3189 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3190 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3191 | }, |
| 3192 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3193 | }, |
| 3194 | { |
| 3195 | []uint16{ |
| 3196 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3197 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3198 | }, |
| 3199 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3200 | }, |
| 3201 | // If there are two equipreference groups, the preferred one |
| 3202 | // takes precedence. |
| 3203 | { |
| 3204 | []uint16{ |
| 3205 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3206 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3207 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3208 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3209 | }, |
| 3210 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3211 | }, |
| 3212 | } |
| 3213 | for i, t := range negotiationTests { |
| 3214 | testCases = append(testCases, testCase{ |
| 3215 | testType: serverTest, |
| 3216 | name: "CipherNegotiation-" + strconv.Itoa(i), |
| 3217 | config: Config{ |
| 3218 | MaxVersion: VersionTLS12, |
| 3219 | CipherSuites: t.ciphers, |
| 3220 | }, |
| 3221 | flags: []string{"-cipher", negotiationTestCiphers}, |
| 3222 | expectedCipher: t.expected, |
| 3223 | }) |
| 3224 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | func addBadECDSASignatureTests() { |
| 3228 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 3229 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3230 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3231 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 3232 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3233 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3234 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3235 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3236 | Bugs: ProtocolBugs{ |
| 3237 | BadECDSAR: badR, |
| 3238 | BadECDSAS: badS, |
| 3239 | }, |
| 3240 | }, |
| 3241 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3242 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3243 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3244 | testCases = append(testCases, testCase{ |
| 3245 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 3246 | config: Config{ |
| 3247 | MaxVersion: VersionTLS13, |
| 3248 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3249 | Bugs: ProtocolBugs{ |
| 3250 | BadECDSAR: badR, |
| 3251 | BadECDSAS: badS, |
| 3252 | }, |
| 3253 | }, |
| 3254 | shouldFail: true, |
| 3255 | expectedError: ":BAD_SIGNATURE:", |
| 3256 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3257 | } |
| 3258 | } |
| 3259 | } |
| 3260 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3261 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3262 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3263 | name: "MaxCBCPadding", |
| 3264 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3265 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3266 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3267 | Bugs: ProtocolBugs{ |
| 3268 | MaxPadding: true, |
| 3269 | }, |
| 3270 | }, |
| 3271 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3272 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3273 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3274 | name: "BadCBCPadding", |
| 3275 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3276 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3277 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3278 | Bugs: ProtocolBugs{ |
| 3279 | PaddingFirstByteBad: true, |
| 3280 | }, |
| 3281 | }, |
| 3282 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3283 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3284 | }) |
| 3285 | // OpenSSL previously had an issue where the first byte of padding in |
| 3286 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3287 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3288 | name: "BadCBCPadding255", |
| 3289 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3290 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3291 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3292 | Bugs: ProtocolBugs{ |
| 3293 | MaxPadding: true, |
| 3294 | PaddingFirstByteBadIf255: true, |
| 3295 | }, |
| 3296 | }, |
| 3297 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3298 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3299 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3300 | }) |
| 3301 | } |
| 3302 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3303 | func addCBCSplittingTests() { |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3304 | var cbcCiphers = []struct { |
| 3305 | name string |
| 3306 | cipher uint16 |
| 3307 | }{ |
| 3308 | {"3DES", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
| 3309 | {"AES128", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3310 | {"AES256", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
| 3311 | } |
| 3312 | for _, t := range cbcCiphers { |
| 3313 | testCases = append(testCases, testCase{ |
| 3314 | name: "CBCRecordSplitting-" + t.name, |
| 3315 | config: Config{ |
| 3316 | MaxVersion: VersionTLS10, |
| 3317 | MinVersion: VersionTLS10, |
| 3318 | CipherSuites: []uint16{t.cipher}, |
| 3319 | }, |
| 3320 | messageLen: -1, // read until EOF |
| 3321 | resumeSession: true, |
| 3322 | flags: []string{ |
| 3323 | "-async", |
| 3324 | "-write-different-record-sizes", |
| 3325 | "-cbc-record-splitting", |
| 3326 | }, |
| 3327 | }) |
| 3328 | testCases = append(testCases, testCase{ |
| 3329 | name: "CBCRecordSplittingPartialWrite-" + t.name, |
| 3330 | config: Config{ |
| 3331 | MaxVersion: VersionTLS10, |
| 3332 | MinVersion: VersionTLS10, |
| 3333 | CipherSuites: []uint16{t.cipher}, |
| 3334 | }, |
| 3335 | messageLen: -1, // read until EOF |
| 3336 | flags: []string{ |
| 3337 | "-async", |
| 3338 | "-write-different-record-sizes", |
| 3339 | "-cbc-record-splitting", |
| 3340 | "-partial-write", |
| 3341 | }, |
| 3342 | }) |
| 3343 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3344 | } |
| 3345 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3346 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3347 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3348 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3349 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3350 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3351 | if err != nil { |
| 3352 | panic(err) |
| 3353 | } |
| 3354 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3355 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3356 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3357 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3358 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3359 | testCases = append(testCases, testCase{ |
| 3360 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3361 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3362 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3363 | MinVersion: ver.version, |
| 3364 | MaxVersion: ver.version, |
| 3365 | ClientAuth: RequireAnyClientCert, |
| 3366 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3367 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3368 | tls13Variant: ver.tls13Variant, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3369 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3370 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3371 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3372 | }, |
| 3373 | }) |
| 3374 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3375 | testType: serverTest, |
| 3376 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3377 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3378 | MinVersion: ver.version, |
| 3379 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3380 | Certificates: []Certificate{rsaCertificate}, |
| 3381 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3382 | tls13Variant: ver.tls13Variant, |
| 3383 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3384 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3385 | if ver.version != VersionSSL30 { |
| 3386 | testCases = append(testCases, testCase{ |
| 3387 | testType: serverTest, |
| 3388 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3389 | config: Config{ |
| 3390 | MinVersion: ver.version, |
| 3391 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3392 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3393 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3394 | tls13Variant: ver.tls13Variant, |
| 3395 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3396 | }) |
| 3397 | testCases = append(testCases, testCase{ |
| 3398 | testType: clientTest, |
| 3399 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3400 | config: Config{ |
| 3401 | MinVersion: ver.version, |
| 3402 | MaxVersion: ver.version, |
| 3403 | ClientAuth: RequireAnyClientCert, |
| 3404 | ClientCAs: certPool, |
| 3405 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3406 | tls13Variant: ver.tls13Variant, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3407 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3408 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3409 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3410 | }, |
| 3411 | }) |
| 3412 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3413 | |
| 3414 | testCases = append(testCases, testCase{ |
| 3415 | name: "NoClientCertificate-" + ver.name, |
| 3416 | config: Config{ |
| 3417 | MinVersion: ver.version, |
| 3418 | MaxVersion: ver.version, |
| 3419 | ClientAuth: RequireAnyClientCert, |
| 3420 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3421 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3422 | shouldFail: true, |
| 3423 | expectedLocalError: "client didn't provide a certificate", |
| 3424 | }) |
| 3425 | |
| 3426 | testCases = append(testCases, testCase{ |
| 3427 | // Even if not configured to expect a certificate, OpenSSL will |
| 3428 | // return X509_V_OK as the verify_result. |
| 3429 | testType: serverTest, |
| 3430 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3431 | config: Config{ |
| 3432 | MinVersion: ver.version, |
| 3433 | MaxVersion: ver.version, |
| 3434 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3435 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3436 | flags: []string{ |
| 3437 | "-expect-verify-result", |
| 3438 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3439 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3440 | }) |
| 3441 | |
| 3442 | testCases = append(testCases, testCase{ |
| 3443 | // If a client certificate is not provided, OpenSSL will still |
| 3444 | // return X509_V_OK as the verify_result. |
| 3445 | testType: serverTest, |
| 3446 | name: "NoClientCertificate-Server-" + ver.name, |
| 3447 | config: Config{ |
| 3448 | MinVersion: ver.version, |
| 3449 | MaxVersion: ver.version, |
| 3450 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3451 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3452 | flags: []string{ |
| 3453 | "-expect-verify-result", |
| 3454 | "-verify-peer", |
| 3455 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3456 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3457 | }) |
| 3458 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3459 | certificateRequired := "remote error: certificate required" |
| 3460 | if ver.version < VersionTLS13 { |
| 3461 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3462 | // was used. |
| 3463 | certificateRequired = "remote error: handshake failure" |
| 3464 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3465 | testCases = append(testCases, testCase{ |
| 3466 | testType: serverTest, |
| 3467 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3468 | config: Config{ |
| 3469 | MinVersion: ver.version, |
| 3470 | MaxVersion: ver.version, |
| 3471 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3472 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3473 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3474 | shouldFail: true, |
| 3475 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3476 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3477 | }) |
| 3478 | |
| 3479 | if ver.version != VersionSSL30 { |
| 3480 | testCases = append(testCases, testCase{ |
| 3481 | testType: serverTest, |
| 3482 | name: "SkipClientCertificate-" + ver.name, |
| 3483 | config: Config{ |
| 3484 | MinVersion: ver.version, |
| 3485 | MaxVersion: ver.version, |
| 3486 | Bugs: ProtocolBugs{ |
| 3487 | SkipClientCertificate: true, |
| 3488 | }, |
| 3489 | }, |
| 3490 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3491 | flags: []string{"-verify-peer"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3492 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3493 | shouldFail: true, |
| 3494 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3495 | }) |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3496 | |
| 3497 | testCases = append(testCases, testCase{ |
| 3498 | testType: serverTest, |
| 3499 | name: "VerifyPeerIfNoOBC-NoChannelID-" + ver.name, |
| 3500 | config: Config{ |
| 3501 | MinVersion: ver.version, |
| 3502 | MaxVersion: ver.version, |
| 3503 | }, |
| 3504 | flags: []string{ |
| 3505 | "-enable-channel-id", |
| 3506 | "-verify-peer-if-no-obc", |
| 3507 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3508 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3509 | shouldFail: true, |
| 3510 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3511 | expectedLocalError: certificateRequired, |
| 3512 | }) |
| 3513 | |
| 3514 | testCases = append(testCases, testCase{ |
| 3515 | testType: serverTest, |
| 3516 | name: "VerifyPeerIfNoOBC-ChannelID-" + ver.name, |
| 3517 | config: Config{ |
| 3518 | MinVersion: ver.version, |
| 3519 | MaxVersion: ver.version, |
| 3520 | ChannelID: channelIDKey, |
| 3521 | }, |
| 3522 | expectChannelID: true, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3523 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3524 | flags: []string{ |
| 3525 | "-enable-channel-id", |
| 3526 | "-verify-peer-if-no-obc", |
| 3527 | }, |
| 3528 | }) |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3529 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3530 | |
| 3531 | testCases = append(testCases, testCase{ |
| 3532 | testType: serverTest, |
| 3533 | name: ver.name + "-Server-CertReq-CA-List", |
| 3534 | config: Config{ |
| 3535 | MinVersion: ver.version, |
| 3536 | MaxVersion: ver.version, |
| 3537 | Certificates: []Certificate{rsaCertificate}, |
| 3538 | Bugs: ProtocolBugs{ |
| 3539 | ExpectCertificateReqNames: caNames, |
| 3540 | }, |
| 3541 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3542 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3543 | flags: []string{ |
| 3544 | "-require-any-client-certificate", |
| 3545 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3546 | }, |
| 3547 | }) |
| 3548 | |
| 3549 | testCases = append(testCases, testCase{ |
| 3550 | testType: clientTest, |
| 3551 | name: ver.name + "-Client-CertReq-CA-List", |
| 3552 | config: Config{ |
| 3553 | MinVersion: ver.version, |
| 3554 | MaxVersion: ver.version, |
| 3555 | Certificates: []Certificate{rsaCertificate}, |
| 3556 | ClientAuth: RequireAnyClientCert, |
| 3557 | ClientCAs: certPool, |
| 3558 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3559 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3560 | flags: []string{ |
| 3561 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3562 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3563 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3564 | }, |
| 3565 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3566 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3567 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3568 | // Client auth is only legal in certificate-based ciphers. |
| 3569 | testCases = append(testCases, testCase{ |
| 3570 | testType: clientTest, |
| 3571 | name: "ClientAuth-PSK", |
| 3572 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3573 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3574 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3575 | PreSharedKey: []byte("secret"), |
| 3576 | ClientAuth: RequireAnyClientCert, |
| 3577 | }, |
| 3578 | flags: []string{ |
| 3579 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3580 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3581 | "-psk", "secret", |
| 3582 | }, |
| 3583 | shouldFail: true, |
| 3584 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3585 | }) |
| 3586 | testCases = append(testCases, testCase{ |
| 3587 | testType: clientTest, |
| 3588 | name: "ClientAuth-ECDHE_PSK", |
| 3589 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3590 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3591 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3592 | PreSharedKey: []byte("secret"), |
| 3593 | ClientAuth: RequireAnyClientCert, |
| 3594 | }, |
| 3595 | flags: []string{ |
| 3596 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3597 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3598 | "-psk", "secret", |
| 3599 | }, |
| 3600 | shouldFail: true, |
| 3601 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3602 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3603 | |
| 3604 | // Regression test for a bug where the client CA list, if explicitly |
| 3605 | // set to NULL, was mis-encoded. |
| 3606 | testCases = append(testCases, testCase{ |
| 3607 | testType: serverTest, |
| 3608 | name: "Null-Client-CA-List", |
| 3609 | config: Config{ |
| 3610 | MaxVersion: VersionTLS12, |
| 3611 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3612 | Bugs: ProtocolBugs{ |
| 3613 | ExpectCertificateReqNames: [][]byte{}, |
| 3614 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3615 | }, |
| 3616 | flags: []string{ |
| 3617 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3618 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3619 | }, |
| 3620 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3621 | } |
| 3622 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3623 | func addExtendedMasterSecretTests() { |
| 3624 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3625 | |
| 3626 | for _, with := range []bool{false, true} { |
| 3627 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3628 | if with { |
| 3629 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3630 | } |
| 3631 | |
| 3632 | for _, isClient := range []bool{false, true} { |
| 3633 | suffix := "-Server" |
| 3634 | testType := serverTest |
| 3635 | if isClient { |
| 3636 | suffix = "-Client" |
| 3637 | testType = clientTest |
| 3638 | } |
| 3639 | |
| 3640 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3641 | // In TLS 1.3, the extension is irrelevant and |
| 3642 | // always reports as enabled. |
| 3643 | var flags []string |
| 3644 | if with || ver.version >= VersionTLS13 { |
| 3645 | flags = []string{expectEMSFlag} |
| 3646 | } |
| 3647 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3648 | test := testCase{ |
| 3649 | testType: testType, |
| 3650 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3651 | config: Config{ |
| 3652 | MinVersion: ver.version, |
| 3653 | MaxVersion: ver.version, |
| 3654 | Bugs: ProtocolBugs{ |
| 3655 | NoExtendedMasterSecret: !with, |
| 3656 | RequireExtendedMasterSecret: with, |
| 3657 | }, |
| 3658 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3659 | tls13Variant: ver.tls13Variant, |
| 3660 | flags: flags, |
| 3661 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3662 | } |
| 3663 | if test.shouldFail { |
| 3664 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3665 | } |
| 3666 | testCases = append(testCases, test) |
| 3667 | } |
| 3668 | } |
| 3669 | } |
| 3670 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3671 | for _, isClient := range []bool{false, true} { |
| 3672 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3673 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3674 | boolToWord := func(b bool) string { |
| 3675 | if b { |
| 3676 | return "Yes" |
| 3677 | } |
| 3678 | return "No" |
| 3679 | } |
| 3680 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3681 | if isClient { |
| 3682 | suffix += "Client" |
| 3683 | } else { |
| 3684 | suffix += "Server" |
| 3685 | } |
| 3686 | |
| 3687 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3688 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3689 | Bugs: ProtocolBugs{ |
| 3690 | RequireExtendedMasterSecret: true, |
| 3691 | }, |
| 3692 | } |
| 3693 | |
| 3694 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3695 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3696 | Bugs: ProtocolBugs{ |
| 3697 | NoExtendedMasterSecret: true, |
| 3698 | }, |
| 3699 | } |
| 3700 | |
| 3701 | test := testCase{ |
| 3702 | name: "ExtendedMasterSecret-" + suffix, |
| 3703 | resumeSession: true, |
| 3704 | } |
| 3705 | |
| 3706 | if !isClient { |
| 3707 | test.testType = serverTest |
| 3708 | } |
| 3709 | |
| 3710 | if supportedInFirstConnection { |
| 3711 | test.config = supportedConfig |
| 3712 | } else { |
| 3713 | test.config = noSupportConfig |
| 3714 | } |
| 3715 | |
| 3716 | if supportedInResumeConnection { |
| 3717 | test.resumeConfig = &supportedConfig |
| 3718 | } else { |
| 3719 | test.resumeConfig = &noSupportConfig |
| 3720 | } |
| 3721 | |
| 3722 | switch suffix { |
| 3723 | case "YesToYes-Client", "YesToYes-Server": |
| 3724 | // When a session is resumed, it should |
| 3725 | // still be aware that its master |
| 3726 | // secret was generated via EMS and |
| 3727 | // thus it's safe to use tls-unique. |
| 3728 | test.flags = []string{expectEMSFlag} |
| 3729 | case "NoToYes-Server": |
| 3730 | // If an original connection did not |
| 3731 | // contain EMS, but a resumption |
| 3732 | // handshake does, then a server should |
| 3733 | // not resume the session. |
| 3734 | test.expectResumeRejected = true |
| 3735 | case "YesToNo-Server": |
| 3736 | // Resuming an EMS session without the |
| 3737 | // EMS extension should cause the |
| 3738 | // server to abort the connection. |
| 3739 | test.shouldFail = true |
| 3740 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3741 | case "NoToYes-Client": |
| 3742 | // A client should abort a connection |
| 3743 | // where the server resumed a non-EMS |
| 3744 | // session but echoed the EMS |
| 3745 | // extension. |
| 3746 | test.shouldFail = true |
| 3747 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3748 | case "YesToNo-Client": |
| 3749 | // A client should abort a connection |
| 3750 | // where the server didn't echo EMS |
| 3751 | // when the session used it. |
| 3752 | test.shouldFail = true |
| 3753 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3754 | } |
| 3755 | |
| 3756 | testCases = append(testCases, test) |
| 3757 | } |
| 3758 | } |
| 3759 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3760 | |
| 3761 | // Switching EMS on renegotiation is forbidden. |
| 3762 | testCases = append(testCases, testCase{ |
| 3763 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3764 | config: Config{ |
| 3765 | MaxVersion: VersionTLS12, |
| 3766 | Bugs: ProtocolBugs{ |
| 3767 | NoExtendedMasterSecret: true, |
| 3768 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3769 | }, |
| 3770 | }, |
| 3771 | renegotiate: 1, |
| 3772 | flags: []string{ |
| 3773 | "-renegotiate-freely", |
| 3774 | "-expect-total-renegotiations", "1", |
| 3775 | }, |
| 3776 | }) |
| 3777 | |
| 3778 | testCases = append(testCases, testCase{ |
| 3779 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3780 | config: Config{ |
| 3781 | MaxVersion: VersionTLS12, |
| 3782 | Bugs: ProtocolBugs{ |
| 3783 | NoExtendedMasterSecret: true, |
| 3784 | }, |
| 3785 | }, |
| 3786 | renegotiate: 1, |
| 3787 | flags: []string{ |
| 3788 | "-renegotiate-freely", |
| 3789 | "-expect-total-renegotiations", "1", |
| 3790 | }, |
| 3791 | shouldFail: true, |
| 3792 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3793 | }) |
| 3794 | |
| 3795 | testCases = append(testCases, testCase{ |
| 3796 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3797 | config: Config{ |
| 3798 | MaxVersion: VersionTLS12, |
| 3799 | Bugs: ProtocolBugs{ |
| 3800 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3801 | }, |
| 3802 | }, |
| 3803 | renegotiate: 1, |
| 3804 | flags: []string{ |
| 3805 | "-renegotiate-freely", |
| 3806 | "-expect-total-renegotiations", "1", |
| 3807 | }, |
| 3808 | shouldFail: true, |
| 3809 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3810 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3811 | } |
| 3812 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3813 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3814 | protocol protocol |
| 3815 | async bool |
| 3816 | splitHandshake bool |
| 3817 | packHandshakeFlight bool |
| 3818 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3819 | } |
| 3820 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3821 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3822 | // various conditions. Some of these are redundant with other tests, but they |
| 3823 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3824 | func addAllStateMachineCoverageTests() { |
| 3825 | for _, async := range []bool{false, true} { |
| 3826 | for _, protocol := range []protocol{tls, dtls} { |
| 3827 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3828 | protocol: protocol, |
| 3829 | async: async, |
| 3830 | }) |
| 3831 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3832 | protocol: protocol, |
| 3833 | async: async, |
| 3834 | implicitHandshake: true, |
| 3835 | }) |
| 3836 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3837 | protocol: protocol, |
| 3838 | async: async, |
| 3839 | splitHandshake: true, |
| 3840 | }) |
| 3841 | if protocol == tls { |
| 3842 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3843 | protocol: protocol, |
| 3844 | async: async, |
| 3845 | packHandshakeFlight: true, |
| 3846 | }) |
| 3847 | } |
| 3848 | } |
| 3849 | } |
| 3850 | } |
| 3851 | |
| 3852 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3853 | var tests []testCase |
| 3854 | |
| 3855 | // Basic handshake, with resumption. Client and server, |
| 3856 | // session ID and session ticket. |
| 3857 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3858 | name: "Basic-Client", |
| 3859 | config: Config{ |
| 3860 | MaxVersion: VersionTLS12, |
| 3861 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3862 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3863 | // Ensure session tickets are used, not session IDs. |
| 3864 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3865 | }) |
| 3866 | tests = append(tests, testCase{ |
| 3867 | name: "Basic-Client-RenewTicket", |
| 3868 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3869 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3870 | Bugs: ProtocolBugs{ |
| 3871 | RenewTicketOnResume: true, |
| 3872 | }, |
| 3873 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3874 | flags: []string{"-expect-ticket-renewal"}, |
| 3875 | resumeSession: true, |
| 3876 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3877 | }) |
| 3878 | tests = append(tests, testCase{ |
| 3879 | name: "Basic-Client-NoTicket", |
| 3880 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3881 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3882 | SessionTicketsDisabled: true, |
| 3883 | }, |
| 3884 | resumeSession: true, |
| 3885 | }) |
| 3886 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3887 | testType: serverTest, |
| 3888 | name: "Basic-Server", |
| 3889 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3890 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3891 | Bugs: ProtocolBugs{ |
| 3892 | RequireSessionTickets: true, |
| 3893 | }, |
| 3894 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3895 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3896 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3897 | }) |
| 3898 | tests = append(tests, testCase{ |
| 3899 | testType: serverTest, |
| 3900 | name: "Basic-Server-NoTickets", |
| 3901 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3902 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3903 | SessionTicketsDisabled: true, |
| 3904 | }, |
| 3905 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3906 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3907 | }) |
| 3908 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3909 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3910 | name: "Basic-Server-EarlyCallback", |
| 3911 | config: Config{ |
| 3912 | MaxVersion: VersionTLS12, |
| 3913 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3914 | flags: []string{"-use-early-callback"}, |
| 3915 | resumeSession: true, |
| 3916 | }) |
| 3917 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3918 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3919 | if config.protocol == tls { |
| 3920 | tests = append(tests, testCase{ |
| 3921 | name: "TLS13-1RTT-Client", |
| 3922 | config: Config{ |
| 3923 | MaxVersion: VersionTLS13, |
| 3924 | MinVersion: VersionTLS13, |
| 3925 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3926 | resumeSession: true, |
| 3927 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3928 | }) |
| 3929 | |
| 3930 | tests = append(tests, testCase{ |
| 3931 | testType: serverTest, |
| 3932 | name: "TLS13-1RTT-Server", |
| 3933 | config: Config{ |
| 3934 | MaxVersion: VersionTLS13, |
| 3935 | MinVersion: VersionTLS13, |
| 3936 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3937 | resumeSession: true, |
| 3938 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3939 | // TLS 1.3 uses tickets, so the session should not be |
| 3940 | // cached statefully. |
| 3941 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3942 | }) |
| 3943 | |
| 3944 | tests = append(tests, testCase{ |
| 3945 | name: "TLS13-HelloRetryRequest-Client", |
| 3946 | config: Config{ |
| 3947 | MaxVersion: VersionTLS13, |
| 3948 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3949 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3950 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3951 | CurvePreferences: []CurveID{CurveP384}, |
| 3952 | Bugs: ProtocolBugs{ |
| 3953 | ExpectMissingKeyShare: true, |
| 3954 | }, |
| 3955 | }, |
| 3956 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3957 | resumeSession: true, |
| 3958 | }) |
| 3959 | |
| 3960 | tests = append(tests, testCase{ |
| 3961 | testType: serverTest, |
| 3962 | name: "TLS13-HelloRetryRequest-Server", |
| 3963 | config: Config{ |
| 3964 | MaxVersion: VersionTLS13, |
| 3965 | MinVersion: VersionTLS13, |
| 3966 | // Require a HelloRetryRequest for every curve. |
| 3967 | DefaultCurves: []CurveID{}, |
| 3968 | }, |
| 3969 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3970 | resumeSession: true, |
| 3971 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3972 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3973 | tests = append(tests, testCase{ |
| 3974 | testType: clientTest, |
| 3975 | name: "TLS13-EarlyData-Client", |
| 3976 | config: Config{ |
| 3977 | MaxVersion: VersionTLS13, |
| 3978 | MinVersion: VersionTLS13, |
| 3979 | MaxEarlyDataSize: 16384, |
| 3980 | }, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3981 | resumeConfig: &Config{ |
| 3982 | MaxVersion: VersionTLS13, |
| 3983 | MinVersion: VersionTLS13, |
| 3984 | MaxEarlyDataSize: 16384, |
| 3985 | Bugs: ProtocolBugs{ |
| 3986 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 3987 | }, |
| 3988 | }, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3989 | resumeSession: true, |
| 3990 | flags: []string{ |
| 3991 | "-enable-early-data", |
| 3992 | "-expect-early-data-info", |
| 3993 | "-expect-accept-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3994 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3995 | }, |
| 3996 | }) |
| 3997 | |
| 3998 | tests = append(tests, testCase{ |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3999 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4000 | name: "TLS13Experiment-EarlyData-Client", |
| 4001 | config: Config{ |
| 4002 | MaxVersion: VersionTLS13, |
| 4003 | MinVersion: VersionTLS13, |
| 4004 | TLS13Variant: TLS13Experiment, |
| 4005 | MaxEarlyDataSize: 16384, |
| 4006 | }, |
| 4007 | resumeConfig: &Config{ |
| 4008 | MaxVersion: VersionTLS13, |
| 4009 | MinVersion: VersionTLS13, |
| 4010 | TLS13Variant: TLS13Experiment, |
| 4011 | MaxEarlyDataSize: 16384, |
| 4012 | Bugs: ProtocolBugs{ |
| 4013 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4014 | }, |
| 4015 | }, |
| 4016 | resumeSession: true, |
| 4017 | flags: []string{ |
| 4018 | "-enable-early-data", |
| 4019 | "-expect-early-data-info", |
| 4020 | "-expect-accept-early-data", |
| 4021 | "-on-resume-shim-writes-first", |
| 4022 | "-tls13-variant", "1", |
| 4023 | }, |
| 4024 | }) |
| 4025 | |
| 4026 | tests = append(tests, testCase{ |
| 4027 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4028 | name: "TLS13RecordTypeExperiment-EarlyData-Client", |
| 4029 | config: Config{ |
| 4030 | MaxVersion: VersionTLS13, |
| 4031 | MinVersion: VersionTLS13, |
| 4032 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4033 | MaxEarlyDataSize: 16384, |
| 4034 | }, |
| 4035 | resumeConfig: &Config{ |
| 4036 | MaxVersion: VersionTLS13, |
| 4037 | MinVersion: VersionTLS13, |
| 4038 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4039 | MaxEarlyDataSize: 16384, |
| 4040 | Bugs: ProtocolBugs{ |
| 4041 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4042 | }, |
| 4043 | }, |
| 4044 | resumeSession: true, |
| 4045 | flags: []string{ |
| 4046 | "-enable-early-data", |
| 4047 | "-expect-early-data-info", |
| 4048 | "-expect-accept-early-data", |
| 4049 | "-on-resume-shim-writes-first", |
| 4050 | "-tls13-variant", "2", |
| 4051 | }, |
| 4052 | }) |
| 4053 | |
| 4054 | tests = append(tests, testCase{ |
| 4055 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4056 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 4057 | config: Config{ |
| 4058 | MaxVersion: VersionTLS13, |
| 4059 | MinVersion: VersionTLS13, |
| 4060 | MaxEarlyDataSize: 2, |
| 4061 | }, |
| 4062 | resumeConfig: &Config{ |
| 4063 | MaxVersion: VersionTLS13, |
| 4064 | MinVersion: VersionTLS13, |
| 4065 | MaxEarlyDataSize: 2, |
| 4066 | Bugs: ProtocolBugs{ |
| 4067 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 4068 | }, |
| 4069 | }, |
| 4070 | resumeShimPrefix: "llo", |
| 4071 | resumeSession: true, |
| 4072 | flags: []string{ |
| 4073 | "-enable-early-data", |
| 4074 | "-expect-early-data-info", |
| 4075 | "-expect-accept-early-data", |
| 4076 | "-on-resume-shim-writes-first", |
| 4077 | }, |
| 4078 | }) |
| 4079 | |
| 4080 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 4081 | // can't be tested as part of an ImplicitHandshake in this case since |
| 4082 | // otherwise the early data will be sent as normal data. |
| 4083 | if config.async && !config.implicitHandshake { |
| 4084 | tests = append(tests, testCase{ |
| 4085 | testType: clientTest, |
| 4086 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 4087 | config: Config{ |
| 4088 | MaxVersion: VersionTLS13, |
| 4089 | MinVersion: VersionTLS13, |
| 4090 | MaxEarlyDataSize: 16384, |
| 4091 | }, |
| 4092 | resumeConfig: &Config{ |
| 4093 | MaxVersion: VersionTLS13, |
| 4094 | MinVersion: VersionTLS13, |
| 4095 | MaxEarlyDataSize: 16384, |
| 4096 | Bugs: ProtocolBugs{ |
| 4097 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4098 | }, |
| 4099 | }, |
| 4100 | resumeSession: true, |
| 4101 | flags: []string{ |
| 4102 | "-enable-early-data", |
| 4103 | "-expect-early-data-info", |
| 4104 | "-expect-accept-early-data", |
| 4105 | "-on-resume-read-with-unfinished-write", |
| 4106 | "-on-resume-shim-writes-first", |
| 4107 | }, |
| 4108 | }) |
| 4109 | |
| 4110 | // Rejected unfinished writes are discarded (from the |
| 4111 | // perspective of the calling application) on 0-RTT |
| 4112 | // reject. |
| 4113 | tests = append(tests, testCase{ |
| 4114 | testType: clientTest, |
| 4115 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 4116 | config: Config{ |
| 4117 | MaxVersion: VersionTLS13, |
| 4118 | MinVersion: VersionTLS13, |
| 4119 | MaxEarlyDataSize: 16384, |
| 4120 | }, |
| 4121 | resumeConfig: &Config{ |
| 4122 | MaxVersion: VersionTLS13, |
| 4123 | MinVersion: VersionTLS13, |
| 4124 | MaxEarlyDataSize: 16384, |
| 4125 | Bugs: ProtocolBugs{ |
| 4126 | AlwaysRejectEarlyData: true, |
| 4127 | }, |
| 4128 | }, |
| 4129 | resumeSession: true, |
| 4130 | flags: []string{ |
| 4131 | "-enable-early-data", |
| 4132 | "-expect-early-data-info", |
| 4133 | "-expect-reject-early-data", |
| 4134 | "-on-resume-read-with-unfinished-write", |
| 4135 | "-on-resume-shim-writes-first", |
| 4136 | }, |
| 4137 | }) |
| 4138 | } |
| 4139 | |
| 4140 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4141 | testType: serverTest, |
| 4142 | name: "TLS13-EarlyData-Server", |
| 4143 | config: Config{ |
| 4144 | MaxVersion: VersionTLS13, |
| 4145 | MinVersion: VersionTLS13, |
| 4146 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4147 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4148 | ExpectEarlyDataAccepted: true, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4149 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4150 | }, |
| 4151 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4152 | messageCount: 2, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4153 | resumeSession: true, |
| 4154 | flags: []string{ |
| 4155 | "-enable-early-data", |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4156 | "-expect-accept-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4157 | }, |
| 4158 | }) |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4159 | |
| 4160 | tests = append(tests, testCase{ |
| 4161 | testType: serverTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4162 | name: "TLS13Experiment-EarlyData-Server", |
| 4163 | config: Config{ |
| 4164 | MaxVersion: VersionTLS13, |
| 4165 | MinVersion: VersionTLS13, |
| 4166 | TLS13Variant: TLS13Experiment, |
| 4167 | Bugs: ProtocolBugs{ |
| 4168 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4169 | ExpectEarlyDataAccepted: true, |
| 4170 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4171 | }, |
| 4172 | }, |
| 4173 | messageCount: 2, |
| 4174 | resumeSession: true, |
| 4175 | flags: []string{ |
| 4176 | "-enable-early-data", |
| 4177 | "-expect-accept-early-data", |
| 4178 | "-tls13-variant", "1", |
| 4179 | }, |
| 4180 | }) |
| 4181 | |
| 4182 | tests = append(tests, testCase{ |
| 4183 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4184 | name: "TLS13RecordTypeExperiment-EarlyData-Server", |
| 4185 | config: Config{ |
| 4186 | MaxVersion: VersionTLS13, |
| 4187 | MinVersion: VersionTLS13, |
| 4188 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4189 | Bugs: ProtocolBugs{ |
| 4190 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4191 | ExpectEarlyDataAccepted: true, |
| 4192 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4193 | }, |
| 4194 | }, |
| 4195 | messageCount: 2, |
| 4196 | resumeSession: true, |
| 4197 | flags: []string{ |
| 4198 | "-enable-early-data", |
| 4199 | "-expect-accept-early-data", |
| 4200 | "-tls13-variant", "2", |
| 4201 | }, |
| 4202 | }) |
| 4203 | |
| 4204 | tests = append(tests, testCase{ |
| 4205 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4206 | name: "TLS13-MaxEarlyData-Server", |
| 4207 | config: Config{ |
| 4208 | MaxVersion: VersionTLS13, |
| 4209 | MinVersion: VersionTLS13, |
| 4210 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4211 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4212 | ExpectEarlyDataAccepted: true, |
| 4213 | }, |
| 4214 | }, |
| 4215 | messageCount: 2, |
| 4216 | resumeSession: true, |
| 4217 | flags: []string{ |
| 4218 | "-enable-early-data", |
| 4219 | "-expect-accept-early-data", |
| 4220 | }, |
| 4221 | shouldFail: true, |
| 4222 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4223 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4224 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4225 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4226 | // TLS client auth. |
| 4227 | tests = append(tests, testCase{ |
| 4228 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4229 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4230 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4231 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4232 | ClientAuth: RequestClientCert, |
| 4233 | }, |
| 4234 | }) |
| 4235 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4236 | testType: serverTest, |
| 4237 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4238 | config: Config{ |
| 4239 | MaxVersion: VersionTLS12, |
| 4240 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4241 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4242 | flags: []string{"-verify-peer"}, |
| 4243 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4244 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4245 | tests = append(tests, testCase{ |
| 4246 | testType: clientTest, |
| 4247 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4248 | config: Config{ |
| 4249 | MaxVersion: VersionSSL30, |
| 4250 | ClientAuth: RequestClientCert, |
| 4251 | }, |
| 4252 | }) |
| 4253 | tests = append(tests, testCase{ |
| 4254 | testType: serverTest, |
| 4255 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4256 | config: Config{ |
| 4257 | MaxVersion: VersionSSL30, |
| 4258 | }, |
| 4259 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4260 | flags: []string{"-verify-peer"}, |
| 4261 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4262 | tests = append(tests, testCase{ |
| 4263 | testType: clientTest, |
| 4264 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4265 | config: Config{ |
| 4266 | MaxVersion: VersionTLS13, |
| 4267 | ClientAuth: RequestClientCert, |
| 4268 | }, |
| 4269 | }) |
| 4270 | tests = append(tests, testCase{ |
| 4271 | testType: serverTest, |
| 4272 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4273 | config: Config{ |
| 4274 | MaxVersion: VersionTLS13, |
| 4275 | }, |
| 4276 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4277 | flags: []string{"-verify-peer"}, |
| 4278 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4279 | } |
| 4280 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4281 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4282 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4283 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4284 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4285 | ClientAuth: RequireAnyClientCert, |
| 4286 | }, |
| 4287 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4288 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4289 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4290 | }, |
| 4291 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4292 | tests = append(tests, testCase{ |
| 4293 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4294 | name: "ClientAuth-RSA-Client-TLS13", |
| 4295 | config: Config{ |
| 4296 | MaxVersion: VersionTLS13, |
| 4297 | ClientAuth: RequireAnyClientCert, |
| 4298 | }, |
| 4299 | flags: []string{ |
| 4300 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4301 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4302 | }, |
| 4303 | }) |
| 4304 | tests = append(tests, testCase{ |
| 4305 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4306 | name: "ClientAuth-ECDSA-Client", |
| 4307 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4308 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4309 | ClientAuth: RequireAnyClientCert, |
| 4310 | }, |
| 4311 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4312 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4313 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4314 | }, |
| 4315 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4316 | tests = append(tests, testCase{ |
| 4317 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4318 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4319 | config: Config{ |
| 4320 | MaxVersion: VersionTLS13, |
| 4321 | ClientAuth: RequireAnyClientCert, |
| 4322 | }, |
| 4323 | flags: []string{ |
| 4324 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4325 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4326 | }, |
| 4327 | }) |
| 4328 | tests = append(tests, testCase{ |
| 4329 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4330 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4331 | config: Config{ |
| 4332 | MaxVersion: VersionTLS12, |
| 4333 | ClientAuth: RequestClientCert, |
| 4334 | }, |
| 4335 | flags: []string{"-use-old-client-cert-callback"}, |
| 4336 | }) |
| 4337 | tests = append(tests, testCase{ |
| 4338 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4339 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4340 | config: Config{ |
| 4341 | MaxVersion: VersionTLS13, |
| 4342 | ClientAuth: RequestClientCert, |
| 4343 | }, |
| 4344 | flags: []string{"-use-old-client-cert-callback"}, |
| 4345 | }) |
| 4346 | tests = append(tests, testCase{ |
| 4347 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4348 | name: "ClientAuth-OldCallback", |
| 4349 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4350 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4351 | ClientAuth: RequireAnyClientCert, |
| 4352 | }, |
| 4353 | flags: []string{ |
| 4354 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4355 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4356 | "-use-old-client-cert-callback", |
| 4357 | }, |
| 4358 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4359 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4360 | testType: clientTest, |
| 4361 | name: "ClientAuth-OldCallback-TLS13", |
| 4362 | config: Config{ |
| 4363 | MaxVersion: VersionTLS13, |
| 4364 | ClientAuth: RequireAnyClientCert, |
| 4365 | }, |
| 4366 | flags: []string{ |
| 4367 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4368 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4369 | "-use-old-client-cert-callback", |
| 4370 | }, |
| 4371 | }) |
| 4372 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4373 | testType: serverTest, |
| 4374 | name: "ClientAuth-Server", |
| 4375 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4376 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4377 | Certificates: []Certificate{rsaCertificate}, |
| 4378 | }, |
| 4379 | flags: []string{"-require-any-client-certificate"}, |
| 4380 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4381 | tests = append(tests, testCase{ |
| 4382 | testType: serverTest, |
| 4383 | name: "ClientAuth-Server-TLS13", |
| 4384 | config: Config{ |
| 4385 | MaxVersion: VersionTLS13, |
| 4386 | Certificates: []Certificate{rsaCertificate}, |
| 4387 | }, |
| 4388 | flags: []string{"-require-any-client-certificate"}, |
| 4389 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4390 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4391 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4392 | tests = append(tests, testCase{ |
| 4393 | testType: serverTest, |
| 4394 | name: "Basic-Server-RSA", |
| 4395 | config: Config{ |
| 4396 | MaxVersion: VersionTLS12, |
| 4397 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4398 | }, |
| 4399 | flags: []string{ |
| 4400 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4401 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4402 | }, |
| 4403 | }) |
| 4404 | tests = append(tests, testCase{ |
| 4405 | testType: serverTest, |
| 4406 | name: "Basic-Server-ECDHE-RSA", |
| 4407 | config: Config{ |
| 4408 | MaxVersion: VersionTLS12, |
| 4409 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4410 | }, |
| 4411 | flags: []string{ |
| 4412 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4413 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4414 | }, |
| 4415 | }) |
| 4416 | tests = append(tests, testCase{ |
| 4417 | testType: serverTest, |
| 4418 | name: "Basic-Server-ECDHE-ECDSA", |
| 4419 | config: Config{ |
| 4420 | MaxVersion: VersionTLS12, |
| 4421 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4422 | }, |
| 4423 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4424 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4425 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4426 | }, |
| 4427 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4428 | tests = append(tests, testCase{ |
| 4429 | testType: serverTest, |
| 4430 | name: "Basic-Server-Ed25519", |
| 4431 | config: Config{ |
| 4432 | MaxVersion: VersionTLS12, |
| 4433 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4434 | }, |
| 4435 | flags: []string{ |
| 4436 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4437 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4438 | "-enable-ed25519", |
| 4439 | }, |
| 4440 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4441 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4442 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4443 | tests = append(tests, testCase{ |
| 4444 | name: "SessionTicketsDisabled-Client", |
| 4445 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4446 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4447 | SessionTicketsDisabled: true, |
| 4448 | }, |
| 4449 | }) |
| 4450 | tests = append(tests, testCase{ |
| 4451 | testType: serverTest, |
| 4452 | name: "SessionTicketsDisabled-Server", |
| 4453 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4454 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4455 | SessionTicketsDisabled: true, |
| 4456 | }, |
| 4457 | }) |
| 4458 | |
| 4459 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4460 | // identity hint. |
| 4461 | tests = append(tests, testCase{ |
| 4462 | name: "EmptyPSKHint-Client", |
| 4463 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4464 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4465 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4466 | PreSharedKey: []byte("secret"), |
| 4467 | }, |
| 4468 | flags: []string{"-psk", "secret"}, |
| 4469 | }) |
| 4470 | tests = append(tests, testCase{ |
| 4471 | testType: serverTest, |
| 4472 | name: "EmptyPSKHint-Server", |
| 4473 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4474 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4475 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4476 | PreSharedKey: []byte("secret"), |
| 4477 | }, |
| 4478 | flags: []string{"-psk", "secret"}, |
| 4479 | }) |
| 4480 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4481 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4482 | tests = append(tests, testCase{ |
| 4483 | testType: clientTest, |
| 4484 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4485 | config: Config{ |
| 4486 | MaxVersion: VersionTLS12, |
| 4487 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4488 | flags: []string{ |
| 4489 | "-enable-ocsp-stapling", |
| 4490 | "-expect-ocsp-response", |
| 4491 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4492 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4493 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4494 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4495 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4496 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4497 | testType: serverTest, |
| 4498 | name: "OCSPStapling-Server", |
| 4499 | config: Config{ |
| 4500 | MaxVersion: VersionTLS12, |
| 4501 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4502 | expectedOCSPResponse: testOCSPResponse, |
| 4503 | flags: []string{ |
| 4504 | "-ocsp-response", |
| 4505 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4506 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4507 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4508 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4509 | tests = append(tests, testCase{ |
| 4510 | testType: clientTest, |
| 4511 | name: "OCSPStapling-Client-TLS13", |
| 4512 | config: Config{ |
| 4513 | MaxVersion: VersionTLS13, |
| 4514 | }, |
| 4515 | flags: []string{ |
| 4516 | "-enable-ocsp-stapling", |
| 4517 | "-expect-ocsp-response", |
| 4518 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4519 | "-verify-peer", |
| 4520 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4521 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4522 | }) |
| 4523 | tests = append(tests, testCase{ |
| 4524 | testType: serverTest, |
| 4525 | name: "OCSPStapling-Server-TLS13", |
| 4526 | config: Config{ |
| 4527 | MaxVersion: VersionTLS13, |
| 4528 | }, |
| 4529 | expectedOCSPResponse: testOCSPResponse, |
| 4530 | flags: []string{ |
| 4531 | "-ocsp-response", |
| 4532 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4533 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4534 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4535 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4536 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4537 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4538 | for _, vers := range tlsVersions { |
| 4539 | if config.protocol == dtls && !vers.hasDTLS { |
| 4540 | continue |
| 4541 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4542 | for _, testType := range []testType{clientTest, serverTest} { |
| 4543 | suffix := "-Client" |
| 4544 | if testType == serverTest { |
| 4545 | suffix = "-Server" |
| 4546 | } |
| 4547 | suffix += "-" + vers.name |
| 4548 | |
| 4549 | flag := "-verify-peer" |
| 4550 | if testType == serverTest { |
| 4551 | flag = "-require-any-client-certificate" |
| 4552 | } |
| 4553 | |
| 4554 | tests = append(tests, testCase{ |
| 4555 | testType: testType, |
| 4556 | name: "CertificateVerificationSucceed" + suffix, |
| 4557 | config: Config{ |
| 4558 | MaxVersion: vers.version, |
| 4559 | Certificates: []Certificate{rsaCertificate}, |
| 4560 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4561 | tls13Variant: vers.tls13Variant, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4562 | flags: []string{ |
| 4563 | flag, |
| 4564 | "-expect-verify-result", |
| 4565 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4566 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4567 | }) |
| 4568 | tests = append(tests, testCase{ |
| 4569 | testType: testType, |
| 4570 | name: "CertificateVerificationFail" + suffix, |
| 4571 | config: Config{ |
| 4572 | MaxVersion: vers.version, |
| 4573 | Certificates: []Certificate{rsaCertificate}, |
| 4574 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4575 | tls13Variant: vers.tls13Variant, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4576 | flags: []string{ |
| 4577 | flag, |
| 4578 | "-verify-fail", |
| 4579 | }, |
| 4580 | shouldFail: true, |
| 4581 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4582 | }) |
| 4583 | } |
| 4584 | |
| 4585 | // By default, the client is in a soft fail mode where the peer |
| 4586 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4587 | tests = append(tests, testCase{ |
| 4588 | testType: clientTest, |
| 4589 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4590 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4591 | MaxVersion: vers.version, |
| 4592 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4593 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4594 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4595 | flags: []string{ |
| 4596 | "-verify-fail", |
| 4597 | "-expect-verify-result", |
| 4598 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4599 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4600 | }) |
| 4601 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4602 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4603 | tests = append(tests, testCase{ |
| 4604 | name: "ShimSendAlert", |
| 4605 | flags: []string{"-send-alert"}, |
| 4606 | shimWritesFirst: true, |
| 4607 | shouldFail: true, |
| 4608 | expectedLocalError: "remote error: decompression failure", |
| 4609 | }) |
| 4610 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4611 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4612 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4613 | name: "Renegotiate-Client", |
| 4614 | config: Config{ |
| 4615 | MaxVersion: VersionTLS12, |
| 4616 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4617 | renegotiate: 1, |
| 4618 | flags: []string{ |
| 4619 | "-renegotiate-freely", |
| 4620 | "-expect-total-renegotiations", "1", |
| 4621 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4622 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4623 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4624 | tests = append(tests, testCase{ |
| 4625 | name: "SendHalfHelloRequest", |
| 4626 | config: Config{ |
| 4627 | MaxVersion: VersionTLS12, |
| 4628 | Bugs: ProtocolBugs{ |
| 4629 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4630 | }, |
| 4631 | }, |
| 4632 | sendHalfHelloRequest: true, |
| 4633 | flags: []string{"-renegotiate-ignore"}, |
| 4634 | shouldFail: true, |
| 4635 | expectedError: ":UNEXPECTED_RECORD:", |
| 4636 | }) |
| 4637 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4638 | // NPN on client and server; results in post-handshake message. |
| 4639 | tests = append(tests, testCase{ |
| 4640 | name: "NPN-Client", |
| 4641 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4642 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4643 | NextProtos: []string{"foo"}, |
| 4644 | }, |
| 4645 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4646 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4647 | expectedNextProto: "foo", |
| 4648 | expectedNextProtoType: npn, |
| 4649 | }) |
| 4650 | tests = append(tests, testCase{ |
| 4651 | testType: serverTest, |
| 4652 | name: "NPN-Server", |
| 4653 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4654 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4655 | NextProtos: []string{"bar"}, |
| 4656 | }, |
| 4657 | flags: []string{ |
| 4658 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4659 | "-expect-next-proto", "bar", |
| 4660 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4661 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4662 | expectedNextProto: "bar", |
| 4663 | expectedNextProtoType: npn, |
| 4664 | }) |
| 4665 | |
| 4666 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4667 | |
| 4668 | // Client does False Start and negotiates NPN. |
| 4669 | tests = append(tests, testCase{ |
| 4670 | name: "FalseStart", |
| 4671 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4672 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4673 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4674 | NextProtos: []string{"foo"}, |
| 4675 | Bugs: ProtocolBugs{ |
| 4676 | ExpectFalseStart: true, |
| 4677 | }, |
| 4678 | }, |
| 4679 | flags: []string{ |
| 4680 | "-false-start", |
| 4681 | "-select-next-proto", "foo", |
| 4682 | }, |
| 4683 | shimWritesFirst: true, |
| 4684 | resumeSession: true, |
| 4685 | }) |
| 4686 | |
| 4687 | // Client does False Start and negotiates ALPN. |
| 4688 | tests = append(tests, testCase{ |
| 4689 | name: "FalseStart-ALPN", |
| 4690 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4691 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4692 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4693 | NextProtos: []string{"foo"}, |
| 4694 | Bugs: ProtocolBugs{ |
| 4695 | ExpectFalseStart: true, |
| 4696 | }, |
| 4697 | }, |
| 4698 | flags: []string{ |
| 4699 | "-false-start", |
| 4700 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4701 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4702 | }, |
| 4703 | shimWritesFirst: true, |
| 4704 | resumeSession: true, |
| 4705 | }) |
| 4706 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4707 | // False Start without session tickets. |
| 4708 | tests = append(tests, testCase{ |
| 4709 | name: "FalseStart-SessionTicketsDisabled", |
| 4710 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4711 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4712 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4713 | NextProtos: []string{"foo"}, |
| 4714 | SessionTicketsDisabled: true, |
| 4715 | Bugs: ProtocolBugs{ |
| 4716 | ExpectFalseStart: true, |
| 4717 | }, |
| 4718 | }, |
| 4719 | flags: []string{ |
| 4720 | "-false-start", |
| 4721 | "-select-next-proto", "foo", |
| 4722 | }, |
| 4723 | shimWritesFirst: true, |
| 4724 | }) |
| 4725 | |
| 4726 | // Server parses a V2ClientHello. |
| 4727 | tests = append(tests, testCase{ |
| 4728 | testType: serverTest, |
| 4729 | name: "SendV2ClientHello", |
| 4730 | config: Config{ |
| 4731 | // Choose a cipher suite that does not involve |
| 4732 | // elliptic curves, so no extensions are |
| 4733 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4734 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4735 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4736 | Bugs: ProtocolBugs{ |
| 4737 | SendV2ClientHello: true, |
| 4738 | }, |
| 4739 | }, |
| 4740 | }) |
| 4741 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4742 | // Test Channel ID |
| 4743 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4744 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4745 | continue |
| 4746 | } |
| 4747 | // Client sends a Channel ID. |
| 4748 | tests = append(tests, testCase{ |
| 4749 | name: "ChannelID-Client-" + ver.name, |
| 4750 | config: Config{ |
| 4751 | MaxVersion: ver.version, |
| 4752 | RequestChannelID: true, |
| 4753 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4754 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4755 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4756 | resumeSession: true, |
| 4757 | expectChannelID: true, |
| 4758 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4759 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4760 | // Server accepts a Channel ID. |
| 4761 | tests = append(tests, testCase{ |
| 4762 | testType: serverTest, |
| 4763 | name: "ChannelID-Server-" + ver.name, |
| 4764 | config: Config{ |
| 4765 | MaxVersion: ver.version, |
| 4766 | ChannelID: channelIDKey, |
| 4767 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4768 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4769 | flags: []string{ |
| 4770 | "-expect-channel-id", |
| 4771 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4772 | }, |
| 4773 | resumeSession: true, |
| 4774 | expectChannelID: true, |
| 4775 | }) |
| 4776 | |
| 4777 | tests = append(tests, testCase{ |
| 4778 | testType: serverTest, |
| 4779 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4780 | config: Config{ |
| 4781 | MaxVersion: ver.version, |
| 4782 | ChannelID: channelIDKey, |
| 4783 | Bugs: ProtocolBugs{ |
| 4784 | InvalidChannelIDSignature: true, |
| 4785 | }, |
| 4786 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4787 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4788 | flags: []string{"-enable-channel-id"}, |
| 4789 | shouldFail: true, |
| 4790 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4791 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4792 | |
| 4793 | if ver.version < VersionTLS13 { |
| 4794 | // Channel ID requires ECDHE ciphers. |
| 4795 | tests = append(tests, testCase{ |
| 4796 | testType: serverTest, |
| 4797 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4798 | config: Config{ |
| 4799 | MaxVersion: ver.version, |
| 4800 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4801 | ChannelID: channelIDKey, |
| 4802 | }, |
| 4803 | expectChannelID: false, |
| 4804 | flags: []string{"-enable-channel-id"}, |
| 4805 | }) |
| 4806 | |
| 4807 | // Sanity-check setting expectChannelID false works. |
| 4808 | tests = append(tests, testCase{ |
| 4809 | testType: serverTest, |
| 4810 | name: "ChannelID-ECDHE-" + ver.name, |
| 4811 | config: Config{ |
| 4812 | MaxVersion: ver.version, |
| 4813 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4814 | ChannelID: channelIDKey, |
| 4815 | }, |
| 4816 | expectChannelID: false, |
| 4817 | flags: []string{"-enable-channel-id"}, |
| 4818 | shouldFail: true, |
| 4819 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4820 | }) |
| 4821 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4822 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4823 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4824 | // Channel ID and NPN at the same time, to ensure their relative |
| 4825 | // ordering is correct. |
| 4826 | tests = append(tests, testCase{ |
| 4827 | name: "ChannelID-NPN-Client", |
| 4828 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4829 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4830 | RequestChannelID: true, |
| 4831 | NextProtos: []string{"foo"}, |
| 4832 | }, |
| 4833 | flags: []string{ |
| 4834 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4835 | "-select-next-proto", "foo", |
| 4836 | }, |
| 4837 | resumeSession: true, |
| 4838 | expectChannelID: true, |
| 4839 | expectedNextProto: "foo", |
| 4840 | expectedNextProtoType: npn, |
| 4841 | }) |
| 4842 | tests = append(tests, testCase{ |
| 4843 | testType: serverTest, |
| 4844 | name: "ChannelID-NPN-Server", |
| 4845 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4846 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4847 | ChannelID: channelIDKey, |
| 4848 | NextProtos: []string{"bar"}, |
| 4849 | }, |
| 4850 | flags: []string{ |
| 4851 | "-expect-channel-id", |
| 4852 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4853 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4854 | "-expect-next-proto", "bar", |
| 4855 | }, |
| 4856 | resumeSession: true, |
| 4857 | expectChannelID: true, |
| 4858 | expectedNextProto: "bar", |
| 4859 | expectedNextProtoType: npn, |
| 4860 | }) |
| 4861 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4862 | // Bidirectional shutdown with the runner initiating. |
| 4863 | tests = append(tests, testCase{ |
| 4864 | name: "Shutdown-Runner", |
| 4865 | config: Config{ |
| 4866 | Bugs: ProtocolBugs{ |
| 4867 | ExpectCloseNotify: true, |
| 4868 | }, |
| 4869 | }, |
| 4870 | flags: []string{"-check-close-notify"}, |
| 4871 | }) |
| 4872 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4873 | if !config.implicitHandshake { |
| 4874 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4875 | // in the meantime, sends garbage before the close_notify which |
| 4876 | // the shim must ignore. This test is disabled under implicit |
| 4877 | // handshake tests because the shim never reads or writes. |
| 4878 | tests = append(tests, testCase{ |
| 4879 | name: "Shutdown-Shim", |
| 4880 | config: Config{ |
| 4881 | MaxVersion: VersionTLS12, |
| 4882 | Bugs: ProtocolBugs{ |
| 4883 | ExpectCloseNotify: true, |
| 4884 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4885 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4886 | shimShutsDown: true, |
| 4887 | sendEmptyRecords: 1, |
| 4888 | sendWarningAlerts: 1, |
| 4889 | flags: []string{"-check-close-notify"}, |
| 4890 | }) |
| 4891 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4892 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4893 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4894 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4895 | tests = append(tests, testCase{ |
| 4896 | name: "SkipHelloVerifyRequest", |
| 4897 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4898 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4899 | Bugs: ProtocolBugs{ |
| 4900 | SkipHelloVerifyRequest: true, |
| 4901 | }, |
| 4902 | }, |
| 4903 | }) |
| 4904 | } |
| 4905 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4906 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4907 | test.protocol = config.protocol |
| 4908 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4909 | test.name += "-DTLS" |
| 4910 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4911 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4912 | test.name += "-Async" |
| 4913 | test.flags = append(test.flags, "-async") |
| 4914 | } else { |
| 4915 | test.name += "-Sync" |
| 4916 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4917 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4918 | test.name += "-SplitHandshakeRecords" |
| 4919 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4920 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4921 | test.config.Bugs.MaxPacketLength = 256 |
| 4922 | test.flags = append(test.flags, "-mtu", "256") |
| 4923 | } |
| 4924 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4925 | if config.packHandshakeFlight { |
| 4926 | test.name += "-PackHandshakeFlight" |
| 4927 | test.config.Bugs.PackHandshakeFlight = true |
| 4928 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4929 | if config.implicitHandshake { |
| 4930 | test.name += "-ImplicitHandshake" |
| 4931 | test.flags = append(test.flags, "-implicit-handshake") |
| 4932 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4933 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4934 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4935 | } |
| 4936 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4937 | func addDDoSCallbackTests() { |
| 4938 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4939 | for _, resume := range []bool{false, true} { |
| 4940 | suffix := "Resume" |
| 4941 | if resume { |
| 4942 | suffix = "No" + suffix |
| 4943 | } |
| 4944 | |
| 4945 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4946 | testType: serverTest, |
| 4947 | name: "Server-DDoS-OK-" + suffix, |
| 4948 | config: Config{ |
| 4949 | MaxVersion: VersionTLS12, |
| 4950 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4951 | flags: []string{"-install-ddos-callback"}, |
| 4952 | resumeSession: resume, |
| 4953 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4954 | testCases = append(testCases, testCase{ |
| 4955 | testType: serverTest, |
| 4956 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4957 | config: Config{ |
| 4958 | MaxVersion: VersionTLS13, |
| 4959 | }, |
| 4960 | flags: []string{"-install-ddos-callback"}, |
| 4961 | resumeSession: resume, |
| 4962 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4963 | |
| 4964 | failFlag := "-fail-ddos-callback" |
| 4965 | if resume { |
| 4966 | failFlag = "-fail-second-ddos-callback" |
| 4967 | } |
| 4968 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4969 | testType: serverTest, |
| 4970 | name: "Server-DDoS-Reject-" + suffix, |
| 4971 | config: Config{ |
| 4972 | MaxVersion: VersionTLS12, |
| 4973 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4974 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4975 | resumeSession: resume, |
| 4976 | shouldFail: true, |
| 4977 | expectedError: ":CONNECTION_REJECTED:", |
| 4978 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4979 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4980 | testCases = append(testCases, testCase{ |
| 4981 | testType: serverTest, |
| 4982 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4983 | config: Config{ |
| 4984 | MaxVersion: VersionTLS13, |
| 4985 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4986 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4987 | resumeSession: resume, |
| 4988 | shouldFail: true, |
| 4989 | expectedError: ":CONNECTION_REJECTED:", |
| 4990 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4991 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4992 | } |
| 4993 | } |
| 4994 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4995 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4996 | for _, protocol := range []protocol{tls, dtls} { |
| 4997 | for _, shimVers := range allVersions(protocol) { |
| 4998 | // Assemble flags to disable all newer versions on the shim. |
| 4999 | var flags []string |
| 5000 | for _, vers := range allVersions(protocol) { |
| 5001 | if vers.version > shimVers.version { |
| 5002 | flags = append(flags, vers.excludeFlag) |
| 5003 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5004 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5005 | |
| 5006 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 5007 | |
| 5008 | if shimVers.tls13Variant != 0 { |
| 5009 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5010 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5011 | } |
| 5012 | |
| 5013 | // Test configuring the runner's maximum version. |
| 5014 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5015 | expectedVersion := shimVers.version |
| 5016 | if runnerVers.version < shimVers.version { |
| 5017 | expectedVersion = runnerVers.version |
| 5018 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5019 | // When running and shim have different TLS 1.3 variants enabled, |
| 5020 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5021 | // servers support both variants when enabled when the experiment is |
| 5022 | // enabled. |
| 5023 | expectedServerVersion := expectedVersion |
| 5024 | expectedClientVersion := expectedVersion |
| 5025 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5026 | expectedClientVersion = VersionTLS12 |
| 5027 | expectedServerVersion = VersionTLS12 |
| 5028 | if shimVers.tls13Variant != TLS13Default { |
| 5029 | expectedServerVersion = VersionTLS13 |
| 5030 | } |
| 5031 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5032 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5033 | suffix := shimVers.name + "-" + runnerVers.name |
| 5034 | if protocol == dtls { |
| 5035 | suffix += "-DTLS" |
| 5036 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5037 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5038 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5039 | clientVers := shimVers.version |
| 5040 | if clientVers > VersionTLS10 { |
| 5041 | clientVers = VersionTLS10 |
| 5042 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5043 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5044 | serverVers := expectedServerVersion |
| 5045 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5046 | serverVers = VersionTLS10 |
| 5047 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5048 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5049 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5050 | testCases = append(testCases, testCase{ |
| 5051 | protocol: protocol, |
| 5052 | testType: clientTest, |
| 5053 | name: "VersionNegotiation-Client-" + suffix, |
| 5054 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5055 | MaxVersion: runnerVers.version, |
| 5056 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5057 | Bugs: ProtocolBugs{ |
| 5058 | ExpectInitialRecordVersion: clientVers, |
| 5059 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5060 | }, |
| 5061 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5062 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5063 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5064 | testCases = append(testCases, testCase{ |
| 5065 | protocol: protocol, |
| 5066 | testType: clientTest, |
| 5067 | name: "VersionNegotiation-Client2-" + suffix, |
| 5068 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5069 | MaxVersion: runnerVers.version, |
| 5070 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5071 | Bugs: ProtocolBugs{ |
| 5072 | ExpectInitialRecordVersion: clientVers, |
| 5073 | }, |
| 5074 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5075 | flags: flags2, |
| 5076 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5077 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5078 | |
| 5079 | testCases = append(testCases, testCase{ |
| 5080 | protocol: protocol, |
| 5081 | testType: serverTest, |
| 5082 | name: "VersionNegotiation-Server-" + suffix, |
| 5083 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5084 | MaxVersion: runnerVers.version, |
| 5085 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5086 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5087 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5088 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5089 | }, |
| 5090 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5091 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5092 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5093 | testCases = append(testCases, testCase{ |
| 5094 | protocol: protocol, |
| 5095 | testType: serverTest, |
| 5096 | name: "VersionNegotiation-Server2-" + suffix, |
| 5097 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5098 | MaxVersion: runnerVers.version, |
| 5099 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5100 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5101 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5102 | }, |
| 5103 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5104 | flags: flags2, |
| 5105 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5106 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5107 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5108 | } |
| 5109 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5110 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5111 | // Test the version extension at all versions. |
| 5112 | for _, vers := range tlsVersions { |
| 5113 | protocols := []protocol{tls} |
| 5114 | if vers.hasDTLS { |
| 5115 | protocols = append(protocols, dtls) |
| 5116 | } |
| 5117 | for _, protocol := range protocols { |
| 5118 | suffix := vers.name |
| 5119 | if protocol == dtls { |
| 5120 | suffix += "-DTLS" |
| 5121 | } |
| 5122 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5123 | testCases = append(testCases, testCase{ |
| 5124 | protocol: protocol, |
| 5125 | testType: serverTest, |
| 5126 | name: "VersionNegotiationExtension-" + suffix, |
| 5127 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5128 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5129 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5130 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5131 | }, |
| 5132 | }, |
| 5133 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5134 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5135 | }) |
| 5136 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5137 | } |
| 5138 | |
| 5139 | // If all versions are unknown, negotiation fails. |
| 5140 | testCases = append(testCases, testCase{ |
| 5141 | testType: serverTest, |
| 5142 | name: "NoSupportedVersions", |
| 5143 | config: Config{ |
| 5144 | Bugs: ProtocolBugs{ |
| 5145 | SendSupportedVersions: []uint16{0x1111}, |
| 5146 | }, |
| 5147 | }, |
| 5148 | shouldFail: true, |
| 5149 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5150 | }) |
| 5151 | testCases = append(testCases, testCase{ |
| 5152 | protocol: dtls, |
| 5153 | testType: serverTest, |
| 5154 | name: "NoSupportedVersions-DTLS", |
| 5155 | config: Config{ |
| 5156 | Bugs: ProtocolBugs{ |
| 5157 | SendSupportedVersions: []uint16{0x1111}, |
| 5158 | }, |
| 5159 | }, |
| 5160 | shouldFail: true, |
| 5161 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5162 | }) |
| 5163 | |
| 5164 | testCases = append(testCases, testCase{ |
| 5165 | testType: serverTest, |
| 5166 | name: "ClientHelloVersionTooHigh", |
| 5167 | config: Config{ |
| 5168 | MaxVersion: VersionTLS13, |
| 5169 | Bugs: ProtocolBugs{ |
| 5170 | SendClientVersion: 0x0304, |
| 5171 | OmitSupportedVersions: true, |
| 5172 | }, |
| 5173 | }, |
| 5174 | expectedVersion: VersionTLS12, |
| 5175 | }) |
| 5176 | |
| 5177 | testCases = append(testCases, testCase{ |
| 5178 | testType: serverTest, |
| 5179 | name: "ConflictingVersionNegotiation", |
| 5180 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5181 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5182 | SendClientVersion: VersionTLS12, |
| 5183 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5184 | }, |
| 5185 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5186 | // The extension takes precedence over the ClientHello version. |
| 5187 | expectedVersion: VersionTLS11, |
| 5188 | }) |
| 5189 | |
| 5190 | testCases = append(testCases, testCase{ |
| 5191 | testType: serverTest, |
| 5192 | name: "ConflictingVersionNegotiation-2", |
| 5193 | config: Config{ |
| 5194 | Bugs: ProtocolBugs{ |
| 5195 | SendClientVersion: VersionTLS11, |
| 5196 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5197 | }, |
| 5198 | }, |
| 5199 | // The extension takes precedence over the ClientHello version. |
| 5200 | expectedVersion: VersionTLS12, |
| 5201 | }) |
| 5202 | |
| 5203 | testCases = append(testCases, testCase{ |
| 5204 | testType: serverTest, |
| 5205 | name: "RejectFinalTLS13", |
| 5206 | config: Config{ |
| 5207 | Bugs: ProtocolBugs{ |
| 5208 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5209 | }, |
| 5210 | }, |
| 5211 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5212 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5213 | expectedVersion: VersionTLS12, |
| 5214 | }) |
| 5215 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5216 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5217 | // the ServerHello. |
| 5218 | testCases = append(testCases, testCase{ |
| 5219 | testType: clientTest, |
| 5220 | name: "SupportedVersionSelection-TLS12", |
| 5221 | config: Config{ |
| 5222 | MaxVersion: VersionTLS12, |
| 5223 | Bugs: ProtocolBugs{ |
| 5224 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5225 | }, |
| 5226 | }, |
| 5227 | shouldFail: true, |
| 5228 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5229 | }) |
| 5230 | |
| 5231 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5232 | // supported_versions extension in the ServerHello. |
| 5233 | testCases = append(testCases, testCase{ |
| 5234 | testType: clientTest, |
| 5235 | name: "SupportedVersionSelection-TLS13", |
| 5236 | config: Config{ |
| 5237 | MaxVersion: VersionTLS13, |
| 5238 | Bugs: ProtocolBugs{ |
| 5239 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5240 | }, |
| 5241 | }, |
| 5242 | shouldFail: true, |
| 5243 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5244 | }) |
| 5245 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5246 | // Test that the maximum version is selected regardless of the |
| 5247 | // client-sent order. |
| 5248 | testCases = append(testCases, testCase{ |
| 5249 | testType: serverTest, |
| 5250 | name: "IgnoreClientVersionOrder", |
| 5251 | config: Config{ |
| 5252 | Bugs: ProtocolBugs{ |
| 5253 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5254 | }, |
| 5255 | }, |
| 5256 | expectedVersion: VersionTLS13, |
| 5257 | }) |
| 5258 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5259 | // Test for version tolerance. |
| 5260 | testCases = append(testCases, testCase{ |
| 5261 | testType: serverTest, |
| 5262 | name: "MinorVersionTolerance", |
| 5263 | config: Config{ |
| 5264 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5265 | SendClientVersion: 0x03ff, |
| 5266 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5267 | }, |
| 5268 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5269 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5270 | }) |
| 5271 | testCases = append(testCases, testCase{ |
| 5272 | testType: serverTest, |
| 5273 | name: "MajorVersionTolerance", |
| 5274 | config: Config{ |
| 5275 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5276 | SendClientVersion: 0x0400, |
| 5277 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5278 | }, |
| 5279 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5280 | // TLS 1.3 must be negotiated with the supported_versions |
| 5281 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5282 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5283 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5284 | testCases = append(testCases, testCase{ |
| 5285 | testType: serverTest, |
| 5286 | name: "VersionTolerance-TLS13", |
| 5287 | config: Config{ |
| 5288 | Bugs: ProtocolBugs{ |
| 5289 | // Although TLS 1.3 does not use |
| 5290 | // ClientHello.version, it still tolerates high |
| 5291 | // values there. |
| 5292 | SendClientVersion: 0x0400, |
| 5293 | }, |
| 5294 | }, |
| 5295 | expectedVersion: VersionTLS13, |
| 5296 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5297 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5298 | testCases = append(testCases, testCase{ |
| 5299 | protocol: dtls, |
| 5300 | testType: serverTest, |
| 5301 | name: "MinorVersionTolerance-DTLS", |
| 5302 | config: Config{ |
| 5303 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5304 | SendClientVersion: 0xfe00, |
| 5305 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5306 | }, |
| 5307 | }, |
| 5308 | expectedVersion: VersionTLS12, |
| 5309 | }) |
| 5310 | testCases = append(testCases, testCase{ |
| 5311 | protocol: dtls, |
| 5312 | testType: serverTest, |
| 5313 | name: "MajorVersionTolerance-DTLS", |
| 5314 | config: Config{ |
| 5315 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5316 | SendClientVersion: 0xfdff, |
| 5317 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5318 | }, |
| 5319 | }, |
| 5320 | expectedVersion: VersionTLS12, |
| 5321 | }) |
| 5322 | |
| 5323 | // Test that versions below 3.0 are rejected. |
| 5324 | testCases = append(testCases, testCase{ |
| 5325 | testType: serverTest, |
| 5326 | name: "VersionTooLow", |
| 5327 | config: Config{ |
| 5328 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5329 | SendClientVersion: 0x0200, |
| 5330 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5331 | }, |
| 5332 | }, |
| 5333 | shouldFail: true, |
| 5334 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5335 | }) |
| 5336 | testCases = append(testCases, testCase{ |
| 5337 | protocol: dtls, |
| 5338 | testType: serverTest, |
| 5339 | name: "VersionTooLow-DTLS", |
| 5340 | config: Config{ |
| 5341 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5342 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5343 | }, |
| 5344 | }, |
| 5345 | shouldFail: true, |
| 5346 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5347 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5348 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5349 | testCases = append(testCases, testCase{ |
| 5350 | name: "ServerBogusVersion", |
| 5351 | config: Config{ |
| 5352 | Bugs: ProtocolBugs{ |
| 5353 | SendServerHelloVersion: 0x1234, |
| 5354 | }, |
| 5355 | }, |
| 5356 | shouldFail: true, |
| 5357 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5358 | }) |
| 5359 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5360 | // Test TLS 1.3's downgrade signal. |
| 5361 | testCases = append(testCases, testCase{ |
| 5362 | name: "Downgrade-TLS12-Client", |
| 5363 | config: Config{ |
| 5364 | Bugs: ProtocolBugs{ |
| 5365 | NegotiateVersion: VersionTLS12, |
| 5366 | }, |
| 5367 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5368 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5369 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5370 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5371 | }) |
| 5372 | testCases = append(testCases, testCase{ |
| 5373 | testType: serverTest, |
| 5374 | name: "Downgrade-TLS12-Server", |
| 5375 | config: Config{ |
| 5376 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5377 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5378 | }, |
| 5379 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5380 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5381 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5382 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5383 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5384 | } |
| 5385 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5386 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5387 | for _, protocol := range []protocol{tls, dtls} { |
| 5388 | for _, shimVers := range allVersions(protocol) { |
| 5389 | // Assemble flags to disable all older versions on the shim. |
| 5390 | var flags []string |
| 5391 | for _, vers := range allVersions(protocol) { |
| 5392 | if vers.version < shimVers.version { |
| 5393 | flags = append(flags, vers.excludeFlag) |
| 5394 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5395 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5396 | |
| 5397 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5398 | |
| 5399 | if shimVers.tls13Variant != 0 { |
| 5400 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5401 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5402 | } |
| 5403 | |
| 5404 | for _, runnerVers := range allVersions(protocol) { |
| 5405 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5406 | // produce consistent minimum versions. |
| 5407 | // |
| 5408 | // TODO(davidben): Fold these tests (the main value is in the |
| 5409 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5410 | // on intended shim behavior, not the shim + runner combination. |
| 5411 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5412 | continue |
| 5413 | } |
| 5414 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5415 | suffix := shimVers.name + "-" + runnerVers.name |
| 5416 | if protocol == dtls { |
| 5417 | suffix += "-DTLS" |
| 5418 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5419 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5420 | var expectedVersion uint16 |
| 5421 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5422 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5423 | if runnerVers.version >= shimVers.version { |
| 5424 | expectedVersion = runnerVers.version |
| 5425 | } else { |
| 5426 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5427 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5428 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5429 | } |
| 5430 | |
| 5431 | testCases = append(testCases, testCase{ |
| 5432 | protocol: protocol, |
| 5433 | testType: clientTest, |
| 5434 | name: "MinimumVersion-Client-" + suffix, |
| 5435 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5436 | MaxVersion: runnerVers.version, |
| 5437 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5438 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5439 | // Ensure the server does not decline to |
| 5440 | // select a version (versions extension) or |
| 5441 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5442 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5443 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5444 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5445 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5446 | flags: flags, |
| 5447 | expectedVersion: expectedVersion, |
| 5448 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5449 | expectedError: expectedError, |
| 5450 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5451 | }) |
| 5452 | testCases = append(testCases, testCase{ |
| 5453 | protocol: protocol, |
| 5454 | testType: clientTest, |
| 5455 | name: "MinimumVersion-Client2-" + suffix, |
| 5456 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5457 | MaxVersion: runnerVers.version, |
| 5458 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5459 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5460 | // Ensure the server does not decline to |
| 5461 | // select a version (versions extension) or |
| 5462 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5463 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5464 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5465 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5466 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5467 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5468 | expectedVersion: expectedVersion, |
| 5469 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5470 | expectedError: expectedError, |
| 5471 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5472 | }) |
| 5473 | |
| 5474 | testCases = append(testCases, testCase{ |
| 5475 | protocol: protocol, |
| 5476 | testType: serverTest, |
| 5477 | name: "MinimumVersion-Server-" + suffix, |
| 5478 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5479 | MaxVersion: runnerVers.version, |
| 5480 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5481 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5482 | flags: flags, |
| 5483 | expectedVersion: expectedVersion, |
| 5484 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5485 | expectedError: expectedError, |
| 5486 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5487 | }) |
| 5488 | testCases = append(testCases, testCase{ |
| 5489 | protocol: protocol, |
| 5490 | testType: serverTest, |
| 5491 | name: "MinimumVersion-Server2-" + suffix, |
| 5492 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5493 | MaxVersion: runnerVers.version, |
| 5494 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5495 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5496 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5497 | expectedVersion: expectedVersion, |
| 5498 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5499 | expectedError: expectedError, |
| 5500 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5501 | }) |
| 5502 | } |
| 5503 | } |
| 5504 | } |
| 5505 | } |
| 5506 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5507 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5508 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5509 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5510 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5511 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5512 | // Repeat extensions tests all versions except SSL 3.0. |
| 5513 | for _, ver := range tlsVersions { |
| 5514 | if ver.version == VersionSSL30 { |
| 5515 | continue |
| 5516 | } |
| 5517 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5518 | // Test that duplicate extensions are rejected. |
| 5519 | testCases = append(testCases, testCase{ |
| 5520 | testType: clientTest, |
| 5521 | name: "DuplicateExtensionClient-" + ver.name, |
| 5522 | config: Config{ |
| 5523 | MaxVersion: ver.version, |
| 5524 | Bugs: ProtocolBugs{ |
| 5525 | DuplicateExtension: true, |
| 5526 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5527 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5528 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5529 | shouldFail: true, |
| 5530 | expectedLocalError: "remote error: error decoding message", |
| 5531 | }) |
| 5532 | testCases = append(testCases, testCase{ |
| 5533 | testType: serverTest, |
| 5534 | name: "DuplicateExtensionServer-" + ver.name, |
| 5535 | config: Config{ |
| 5536 | MaxVersion: ver.version, |
| 5537 | Bugs: ProtocolBugs{ |
| 5538 | DuplicateExtension: true, |
| 5539 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5540 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5541 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5542 | shouldFail: true, |
| 5543 | expectedLocalError: "remote error: error decoding message", |
| 5544 | }) |
| 5545 | |
| 5546 | // Test SNI. |
| 5547 | testCases = append(testCases, testCase{ |
| 5548 | testType: clientTest, |
| 5549 | name: "ServerNameExtensionClient-" + ver.name, |
| 5550 | config: Config{ |
| 5551 | MaxVersion: ver.version, |
| 5552 | Bugs: ProtocolBugs{ |
| 5553 | ExpectServerName: "example.com", |
| 5554 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5555 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5556 | tls13Variant: ver.tls13Variant, |
| 5557 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5558 | }) |
| 5559 | testCases = append(testCases, testCase{ |
| 5560 | testType: clientTest, |
| 5561 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5562 | config: Config{ |
| 5563 | MaxVersion: ver.version, |
| 5564 | Bugs: ProtocolBugs{ |
| 5565 | ExpectServerName: "mismatch.com", |
| 5566 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5567 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5568 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5569 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5570 | shouldFail: true, |
| 5571 | expectedLocalError: "tls: unexpected server name", |
| 5572 | }) |
| 5573 | testCases = append(testCases, testCase{ |
| 5574 | testType: clientTest, |
| 5575 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5576 | config: Config{ |
| 5577 | MaxVersion: ver.version, |
| 5578 | Bugs: ProtocolBugs{ |
| 5579 | ExpectServerName: "missing.com", |
| 5580 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5581 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5582 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5583 | shouldFail: true, |
| 5584 | expectedLocalError: "tls: unexpected server name", |
| 5585 | }) |
| 5586 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5587 | testType: clientTest, |
| 5588 | name: "TolerateServerNameAck-" + ver.name, |
| 5589 | config: Config{ |
| 5590 | MaxVersion: ver.version, |
| 5591 | Bugs: ProtocolBugs{ |
| 5592 | SendServerNameAck: true, |
| 5593 | }, |
| 5594 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5595 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5596 | flags: []string{"-host-name", "example.com"}, |
| 5597 | resumeSession: true, |
| 5598 | }) |
| 5599 | testCases = append(testCases, testCase{ |
| 5600 | testType: clientTest, |
| 5601 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5602 | config: Config{ |
| 5603 | MaxVersion: ver.version, |
| 5604 | Bugs: ProtocolBugs{ |
| 5605 | SendServerNameAck: true, |
| 5606 | }, |
| 5607 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5608 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5609 | shouldFail: true, |
| 5610 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5611 | expectedLocalError: "remote error: unsupported extension", |
| 5612 | }) |
| 5613 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5614 | testType: serverTest, |
| 5615 | name: "ServerNameExtensionServer-" + ver.name, |
| 5616 | config: Config{ |
| 5617 | MaxVersion: ver.version, |
| 5618 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5619 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5620 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5621 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5622 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5623 | }) |
| 5624 | |
| 5625 | // Test ALPN. |
| 5626 | testCases = append(testCases, testCase{ |
| 5627 | testType: clientTest, |
| 5628 | name: "ALPNClient-" + ver.name, |
| 5629 | config: Config{ |
| 5630 | MaxVersion: ver.version, |
| 5631 | NextProtos: []string{"foo"}, |
| 5632 | }, |
| 5633 | flags: []string{ |
| 5634 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5635 | "-expect-alpn", "foo", |
| 5636 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5637 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5638 | expectedNextProto: "foo", |
| 5639 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5640 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5641 | }) |
| 5642 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5643 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5644 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5645 | config: Config{ |
| 5646 | MaxVersion: ver.version, |
| 5647 | Bugs: ProtocolBugs{ |
| 5648 | SendALPN: "baz", |
| 5649 | }, |
| 5650 | }, |
| 5651 | flags: []string{ |
| 5652 | "-advertise-alpn", "\x03foo\x03bar", |
| 5653 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5654 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5655 | shouldFail: true, |
| 5656 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5657 | expectedLocalError: "remote error: illegal parameter", |
| 5658 | }) |
| 5659 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5660 | testType: clientTest, |
| 5661 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5662 | config: Config{ |
| 5663 | MaxVersion: ver.version, |
| 5664 | Bugs: ProtocolBugs{ |
| 5665 | SendALPN: "baz", |
| 5666 | }, |
| 5667 | }, |
| 5668 | flags: []string{ |
| 5669 | "-advertise-alpn", "\x03foo\x03bar", |
| 5670 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5671 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5672 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5673 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5674 | }) |
| 5675 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5676 | testType: serverTest, |
| 5677 | name: "ALPNServer-" + ver.name, |
| 5678 | config: Config{ |
| 5679 | MaxVersion: ver.version, |
| 5680 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5681 | }, |
| 5682 | flags: []string{ |
| 5683 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5684 | "-select-alpn", "foo", |
| 5685 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5686 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5687 | expectedNextProto: "foo", |
| 5688 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5689 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5690 | }) |
| 5691 | testCases = append(testCases, testCase{ |
| 5692 | testType: serverTest, |
| 5693 | name: "ALPNServer-Decline-" + ver.name, |
| 5694 | config: Config{ |
| 5695 | MaxVersion: ver.version, |
| 5696 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5697 | }, |
| 5698 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5699 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5700 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5701 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5702 | }) |
| 5703 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5704 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5705 | // called once. |
| 5706 | testCases = append(testCases, testCase{ |
| 5707 | testType: serverTest, |
| 5708 | name: "ALPNServer-Async-" + ver.name, |
| 5709 | config: Config{ |
| 5710 | MaxVersion: ver.version, |
| 5711 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5712 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5713 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5714 | }, |
| 5715 | flags: []string{ |
| 5716 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5717 | "-select-alpn", "foo", |
| 5718 | "-async", |
| 5719 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5720 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5721 | expectedNextProto: "foo", |
| 5722 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5723 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5724 | }) |
| 5725 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5726 | var emptyString string |
| 5727 | testCases = append(testCases, testCase{ |
| 5728 | testType: clientTest, |
| 5729 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5730 | config: Config{ |
| 5731 | MaxVersion: ver.version, |
| 5732 | NextProtos: []string{""}, |
| 5733 | Bugs: ProtocolBugs{ |
| 5734 | // A server returning an empty ALPN protocol |
| 5735 | // should be rejected. |
| 5736 | ALPNProtocol: &emptyString, |
| 5737 | }, |
| 5738 | }, |
| 5739 | flags: []string{ |
| 5740 | "-advertise-alpn", "\x03foo", |
| 5741 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5742 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5743 | shouldFail: true, |
| 5744 | expectedError: ":PARSE_TLSEXT:", |
| 5745 | }) |
| 5746 | testCases = append(testCases, testCase{ |
| 5747 | testType: serverTest, |
| 5748 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5749 | config: Config{ |
| 5750 | MaxVersion: ver.version, |
| 5751 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5752 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5753 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5754 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5755 | flags: []string{ |
| 5756 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5757 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5758 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5759 | shouldFail: true, |
| 5760 | expectedError: ":PARSE_TLSEXT:", |
| 5761 | }) |
| 5762 | |
| 5763 | // Test NPN and the interaction with ALPN. |
| 5764 | if ver.version < VersionTLS13 { |
| 5765 | // Test that the server prefers ALPN over NPN. |
| 5766 | testCases = append(testCases, testCase{ |
| 5767 | testType: serverTest, |
| 5768 | name: "ALPNServer-Preferred-" + ver.name, |
| 5769 | config: Config{ |
| 5770 | MaxVersion: ver.version, |
| 5771 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5772 | }, |
| 5773 | flags: []string{ |
| 5774 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5775 | "-select-alpn", "foo", |
| 5776 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5777 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5778 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5779 | expectedNextProto: "foo", |
| 5780 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5781 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5782 | }) |
| 5783 | testCases = append(testCases, testCase{ |
| 5784 | testType: serverTest, |
| 5785 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5786 | config: Config{ |
| 5787 | MaxVersion: ver.version, |
| 5788 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5789 | Bugs: ProtocolBugs{ |
| 5790 | SwapNPNAndALPN: true, |
| 5791 | }, |
| 5792 | }, |
| 5793 | flags: []string{ |
| 5794 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5795 | "-select-alpn", "foo", |
| 5796 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5797 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5798 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5799 | expectedNextProto: "foo", |
| 5800 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5801 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5802 | }) |
| 5803 | |
| 5804 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5805 | testCases = append(testCases, testCase{ |
| 5806 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5807 | config: Config{ |
| 5808 | MaxVersion: ver.version, |
| 5809 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5810 | Bugs: ProtocolBugs{ |
| 5811 | NegotiateALPNAndNPN: true, |
| 5812 | }, |
| 5813 | }, |
| 5814 | flags: []string{ |
| 5815 | "-advertise-alpn", "\x03foo", |
| 5816 | "-select-next-proto", "foo", |
| 5817 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5818 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5819 | shouldFail: true, |
| 5820 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5821 | }) |
| 5822 | testCases = append(testCases, testCase{ |
| 5823 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5824 | config: Config{ |
| 5825 | MaxVersion: ver.version, |
| 5826 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5827 | Bugs: ProtocolBugs{ |
| 5828 | NegotiateALPNAndNPN: true, |
| 5829 | SwapNPNAndALPN: true, |
| 5830 | }, |
| 5831 | }, |
| 5832 | flags: []string{ |
| 5833 | "-advertise-alpn", "\x03foo", |
| 5834 | "-select-next-proto", "foo", |
| 5835 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5836 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5837 | shouldFail: true, |
| 5838 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5839 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5840 | } |
| 5841 | |
| 5842 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5843 | |
| 5844 | // Resume with a corrupt ticket. |
| 5845 | testCases = append(testCases, testCase{ |
| 5846 | testType: serverTest, |
| 5847 | name: "CorruptTicket-" + ver.name, |
| 5848 | config: Config{ |
| 5849 | MaxVersion: ver.version, |
| 5850 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5851 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5852 | in[len(in)-1] ^= 1 |
| 5853 | return in, nil |
| 5854 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5855 | }, |
| 5856 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5857 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5858 | resumeSession: true, |
| 5859 | expectResumeRejected: true, |
| 5860 | }) |
| 5861 | // Test the ticket callback, with and without renewal. |
| 5862 | testCases = append(testCases, testCase{ |
| 5863 | testType: serverTest, |
| 5864 | name: "TicketCallback-" + ver.name, |
| 5865 | config: Config{ |
| 5866 | MaxVersion: ver.version, |
| 5867 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5868 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5869 | resumeSession: true, |
| 5870 | flags: []string{"-use-ticket-callback"}, |
| 5871 | }) |
| 5872 | testCases = append(testCases, testCase{ |
| 5873 | testType: serverTest, |
| 5874 | name: "TicketCallback-Renew-" + ver.name, |
| 5875 | config: Config{ |
| 5876 | MaxVersion: ver.version, |
| 5877 | Bugs: ProtocolBugs{ |
| 5878 | ExpectNewTicket: true, |
| 5879 | }, |
| 5880 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5881 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5882 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5883 | resumeSession: true, |
| 5884 | }) |
| 5885 | |
| 5886 | // Test that the ticket callback is only called once when everything before |
| 5887 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5888 | // certificate selection callbacks run. |
| 5889 | testCases = append(testCases, testCase{ |
| 5890 | testType: serverTest, |
| 5891 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5892 | config: Config{ |
| 5893 | MaxVersion: ver.version, |
| 5894 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5895 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5896 | in[len(in)-1] ^= 1 |
| 5897 | return in, nil |
| 5898 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5899 | }, |
| 5900 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5901 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5902 | resumeSession: true, |
| 5903 | expectResumeRejected: true, |
| 5904 | flags: []string{ |
| 5905 | "-use-ticket-callback", |
| 5906 | "-async", |
| 5907 | }, |
| 5908 | }) |
| 5909 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5910 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5911 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5912 | testCases = append(testCases, testCase{ |
| 5913 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5914 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5915 | config: Config{ |
| 5916 | MaxVersion: ver.version, |
| 5917 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5918 | EmptyTicketSessionID: true, |
| 5919 | }, |
| 5920 | }, |
| 5921 | resumeSession: true, |
| 5922 | }) |
| 5923 | testCases = append(testCases, testCase{ |
| 5924 | testType: serverTest, |
| 5925 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5926 | config: Config{ |
| 5927 | MaxVersion: ver.version, |
| 5928 | Bugs: ProtocolBugs{ |
| 5929 | TicketSessionIDLength: 16, |
| 5930 | }, |
| 5931 | }, |
| 5932 | resumeSession: true, |
| 5933 | }) |
| 5934 | testCases = append(testCases, testCase{ |
| 5935 | testType: serverTest, |
| 5936 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5937 | config: Config{ |
| 5938 | MaxVersion: ver.version, |
| 5939 | Bugs: ProtocolBugs{ |
| 5940 | TicketSessionIDLength: 32, |
| 5941 | }, |
| 5942 | }, |
| 5943 | resumeSession: true, |
| 5944 | }) |
| 5945 | testCases = append(testCases, testCase{ |
| 5946 | testType: serverTest, |
| 5947 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5948 | config: Config{ |
| 5949 | MaxVersion: ver.version, |
| 5950 | Bugs: ProtocolBugs{ |
| 5951 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5952 | }, |
| 5953 | }, |
| 5954 | resumeSession: true, |
| 5955 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5956 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5957 | expectedError: ":DECODE_ERROR:", |
| 5958 | }) |
| 5959 | } |
| 5960 | |
| 5961 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5962 | // are ignored. |
| 5963 | if ver.hasDTLS { |
| 5964 | testCases = append(testCases, testCase{ |
| 5965 | protocol: dtls, |
| 5966 | name: "SRTP-Client-" + ver.name, |
| 5967 | config: Config{ |
| 5968 | MaxVersion: ver.version, |
| 5969 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5970 | }, |
| 5971 | flags: []string{ |
| 5972 | "-srtp-profiles", |
| 5973 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5974 | }, |
| 5975 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5976 | }) |
| 5977 | testCases = append(testCases, testCase{ |
| 5978 | protocol: dtls, |
| 5979 | testType: serverTest, |
| 5980 | name: "SRTP-Server-" + ver.name, |
| 5981 | config: Config{ |
| 5982 | MaxVersion: ver.version, |
| 5983 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5984 | }, |
| 5985 | flags: []string{ |
| 5986 | "-srtp-profiles", |
| 5987 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5988 | }, |
| 5989 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5990 | }) |
| 5991 | // Test that the MKI is ignored. |
| 5992 | testCases = append(testCases, testCase{ |
| 5993 | protocol: dtls, |
| 5994 | testType: serverTest, |
| 5995 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5996 | config: Config{ |
| 5997 | MaxVersion: ver.version, |
| 5998 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5999 | Bugs: ProtocolBugs{ |
| 6000 | SRTPMasterKeyIdentifer: "bogus", |
| 6001 | }, |
| 6002 | }, |
| 6003 | flags: []string{ |
| 6004 | "-srtp-profiles", |
| 6005 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6006 | }, |
| 6007 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6008 | }) |
| 6009 | // Test that SRTP isn't negotiated on the server if there were |
| 6010 | // no matching profiles. |
| 6011 | testCases = append(testCases, testCase{ |
| 6012 | protocol: dtls, |
| 6013 | testType: serverTest, |
| 6014 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6015 | config: Config{ |
| 6016 | MaxVersion: ver.version, |
| 6017 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6018 | }, |
| 6019 | flags: []string{ |
| 6020 | "-srtp-profiles", |
| 6021 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6022 | }, |
| 6023 | expectedSRTPProtectionProfile: 0, |
| 6024 | }) |
| 6025 | // Test that the server returning an invalid SRTP profile is |
| 6026 | // flagged as an error by the client. |
| 6027 | testCases = append(testCases, testCase{ |
| 6028 | protocol: dtls, |
| 6029 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6030 | config: Config{ |
| 6031 | MaxVersion: ver.version, |
| 6032 | Bugs: ProtocolBugs{ |
| 6033 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6034 | }, |
| 6035 | }, |
| 6036 | flags: []string{ |
| 6037 | "-srtp-profiles", |
| 6038 | "SRTP_AES128_CM_SHA1_80", |
| 6039 | }, |
| 6040 | shouldFail: true, |
| 6041 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6042 | }) |
| 6043 | } |
| 6044 | |
| 6045 | // Test SCT list. |
| 6046 | testCases = append(testCases, testCase{ |
| 6047 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6048 | testType: clientTest, |
| 6049 | config: Config{ |
| 6050 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6051 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6052 | flags: []string{ |
| 6053 | "-enable-signed-cert-timestamps", |
| 6054 | "-expect-signed-cert-timestamps", |
| 6055 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6056 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6057 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6058 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6059 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6060 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6061 | var differentSCTList []byte |
| 6062 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6063 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6064 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6065 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6066 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6067 | testCases = append(testCases, testCase{ |
| 6068 | name: "SendSCTListOnResume-" + ver.name, |
| 6069 | config: Config{ |
| 6070 | MaxVersion: ver.version, |
| 6071 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6072 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6073 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6074 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6075 | flags: []string{ |
| 6076 | "-enable-signed-cert-timestamps", |
| 6077 | "-expect-signed-cert-timestamps", |
| 6078 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6079 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6080 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6081 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6082 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6083 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6084 | testCases = append(testCases, testCase{ |
| 6085 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6086 | testType: serverTest, |
| 6087 | config: Config{ |
| 6088 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6089 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6090 | flags: []string{ |
| 6091 | "-signed-cert-timestamps", |
| 6092 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6093 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6094 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6095 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6096 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6097 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6098 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6099 | emptySCTListCert := *testCerts[0].cert |
| 6100 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6101 | |
| 6102 | // Test empty SCT list. |
| 6103 | testCases = append(testCases, testCase{ |
| 6104 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6105 | testType: clientTest, |
| 6106 | config: Config{ |
| 6107 | MaxVersion: ver.version, |
| 6108 | Certificates: []Certificate{emptySCTListCert}, |
| 6109 | }, |
| 6110 | flags: []string{ |
| 6111 | "-enable-signed-cert-timestamps", |
| 6112 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6113 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6114 | shouldFail: true, |
| 6115 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6116 | }) |
| 6117 | |
| 6118 | emptySCTCert := *testCerts[0].cert |
| 6119 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6120 | |
| 6121 | // Test empty SCT in non-empty list. |
| 6122 | testCases = append(testCases, testCase{ |
| 6123 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6124 | testType: clientTest, |
| 6125 | config: Config{ |
| 6126 | MaxVersion: ver.version, |
| 6127 | Certificates: []Certificate{emptySCTCert}, |
| 6128 | }, |
| 6129 | flags: []string{ |
| 6130 | "-enable-signed-cert-timestamps", |
| 6131 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6132 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6133 | shouldFail: true, |
| 6134 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6135 | }) |
| 6136 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6137 | // Test that certificate-related extensions are not sent unsolicited. |
| 6138 | testCases = append(testCases, testCase{ |
| 6139 | testType: serverTest, |
| 6140 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6141 | config: Config{ |
| 6142 | MaxVersion: ver.version, |
| 6143 | Bugs: ProtocolBugs{ |
| 6144 | NoOCSPStapling: true, |
| 6145 | NoSignedCertificateTimestamps: true, |
| 6146 | }, |
| 6147 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6148 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6149 | flags: []string{ |
| 6150 | "-ocsp-response", |
| 6151 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6152 | "-signed-cert-timestamps", |
| 6153 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6154 | }, |
| 6155 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6156 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6157 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6158 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6159 | testType: clientTest, |
| 6160 | name: "ClientHelloPadding", |
| 6161 | config: Config{ |
| 6162 | Bugs: ProtocolBugs{ |
| 6163 | RequireClientHelloSize: 512, |
| 6164 | }, |
| 6165 | }, |
| 6166 | // This hostname just needs to be long enough to push the |
| 6167 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6168 | // long. |
| 6169 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6170 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6171 | |
| 6172 | // Extensions should not function in SSL 3.0. |
| 6173 | testCases = append(testCases, testCase{ |
| 6174 | testType: serverTest, |
| 6175 | name: "SSLv3Extensions-NoALPN", |
| 6176 | config: Config{ |
| 6177 | MaxVersion: VersionSSL30, |
| 6178 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6179 | }, |
| 6180 | flags: []string{ |
| 6181 | "-select-alpn", "foo", |
| 6182 | }, |
| 6183 | expectNoNextProto: true, |
| 6184 | }) |
| 6185 | |
| 6186 | // Test session tickets separately as they follow a different codepath. |
| 6187 | testCases = append(testCases, testCase{ |
| 6188 | testType: serverTest, |
| 6189 | name: "SSLv3Extensions-NoTickets", |
| 6190 | config: Config{ |
| 6191 | MaxVersion: VersionSSL30, |
| 6192 | Bugs: ProtocolBugs{ |
| 6193 | // Historically, session tickets in SSL 3.0 |
| 6194 | // failed in different ways depending on whether |
| 6195 | // the client supported renegotiation_info. |
| 6196 | NoRenegotiationInfo: true, |
| 6197 | }, |
| 6198 | }, |
| 6199 | resumeSession: true, |
| 6200 | }) |
| 6201 | testCases = append(testCases, testCase{ |
| 6202 | testType: serverTest, |
| 6203 | name: "SSLv3Extensions-NoTickets2", |
| 6204 | config: Config{ |
| 6205 | MaxVersion: VersionSSL30, |
| 6206 | }, |
| 6207 | resumeSession: true, |
| 6208 | }) |
| 6209 | |
| 6210 | // But SSL 3.0 does send and process renegotiation_info. |
| 6211 | testCases = append(testCases, testCase{ |
| 6212 | testType: serverTest, |
| 6213 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6214 | config: Config{ |
| 6215 | MaxVersion: VersionSSL30, |
| 6216 | Bugs: ProtocolBugs{ |
| 6217 | RequireRenegotiationInfo: true, |
| 6218 | }, |
| 6219 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6220 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6221 | }) |
| 6222 | testCases = append(testCases, testCase{ |
| 6223 | testType: serverTest, |
| 6224 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6225 | config: Config{ |
| 6226 | MaxVersion: VersionSSL30, |
| 6227 | Bugs: ProtocolBugs{ |
| 6228 | NoRenegotiationInfo: true, |
| 6229 | SendRenegotiationSCSV: true, |
| 6230 | RequireRenegotiationInfo: true, |
| 6231 | }, |
| 6232 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6233 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6234 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6235 | |
| 6236 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6237 | // in ServerHello. |
| 6238 | testCases = append(testCases, testCase{ |
| 6239 | name: "NPN-Forbidden-TLS13", |
| 6240 | config: Config{ |
| 6241 | MaxVersion: VersionTLS13, |
| 6242 | NextProtos: []string{"foo"}, |
| 6243 | Bugs: ProtocolBugs{ |
| 6244 | NegotiateNPNAtAllVersions: true, |
| 6245 | }, |
| 6246 | }, |
| 6247 | flags: []string{"-select-next-proto", "foo"}, |
| 6248 | shouldFail: true, |
| 6249 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6250 | }) |
| 6251 | testCases = append(testCases, testCase{ |
| 6252 | name: "EMS-Forbidden-TLS13", |
| 6253 | config: Config{ |
| 6254 | MaxVersion: VersionTLS13, |
| 6255 | Bugs: ProtocolBugs{ |
| 6256 | NegotiateEMSAtAllVersions: true, |
| 6257 | }, |
| 6258 | }, |
| 6259 | shouldFail: true, |
| 6260 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6261 | }) |
| 6262 | testCases = append(testCases, testCase{ |
| 6263 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6264 | config: Config{ |
| 6265 | MaxVersion: VersionTLS13, |
| 6266 | Bugs: ProtocolBugs{ |
| 6267 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6268 | }, |
| 6269 | }, |
| 6270 | shouldFail: true, |
| 6271 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6272 | }) |
| 6273 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6274 | name: "Ticket-Forbidden-TLS13", |
| 6275 | config: Config{ |
| 6276 | MaxVersion: VersionTLS12, |
| 6277 | }, |
| 6278 | resumeConfig: &Config{ |
| 6279 | MaxVersion: VersionTLS13, |
| 6280 | Bugs: ProtocolBugs{ |
| 6281 | AdvertiseTicketExtension: true, |
| 6282 | }, |
| 6283 | }, |
| 6284 | resumeSession: true, |
| 6285 | shouldFail: true, |
| 6286 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6287 | }) |
| 6288 | |
| 6289 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6290 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6291 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6292 | // implicit in every test.) |
| 6293 | testCases = append(testCases, testCase{ |
| 6294 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6295 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6296 | config: Config{ |
| 6297 | MaxVersion: VersionTLS13, |
| 6298 | NextProtos: []string{"bar"}, |
| 6299 | }, |
| 6300 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6301 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6302 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6303 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6304 | // tolerated. |
| 6305 | testCases = append(testCases, testCase{ |
| 6306 | name: "SendOCSPResponseOnResume-TLS12", |
| 6307 | config: Config{ |
| 6308 | MaxVersion: VersionTLS12, |
| 6309 | Bugs: ProtocolBugs{ |
| 6310 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6311 | }, |
| 6312 | }, |
| 6313 | flags: []string{ |
| 6314 | "-enable-ocsp-stapling", |
| 6315 | "-expect-ocsp-response", |
| 6316 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6317 | }, |
| 6318 | resumeSession: true, |
| 6319 | }) |
| 6320 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6321 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6322 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6323 | config: Config{ |
| 6324 | MaxVersion: VersionTLS13, |
| 6325 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6326 | SendExtensionOnCertificate: testOCSPExtension, |
| 6327 | }, |
| 6328 | }, |
| 6329 | shouldFail: true, |
| 6330 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6331 | }) |
| 6332 | |
| 6333 | testCases = append(testCases, testCase{ |
| 6334 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6335 | config: Config{ |
| 6336 | MaxVersion: VersionTLS13, |
| 6337 | Bugs: ProtocolBugs{ |
| 6338 | SendExtensionOnCertificate: testSCTExtension, |
| 6339 | }, |
| 6340 | }, |
| 6341 | shouldFail: true, |
| 6342 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6343 | }) |
| 6344 | |
| 6345 | // Test that extensions on client certificates are never accepted. |
| 6346 | testCases = append(testCases, testCase{ |
| 6347 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6348 | testType: serverTest, |
| 6349 | config: Config{ |
| 6350 | MaxVersion: VersionTLS13, |
| 6351 | Certificates: []Certificate{rsaCertificate}, |
| 6352 | Bugs: ProtocolBugs{ |
| 6353 | SendExtensionOnCertificate: testOCSPExtension, |
| 6354 | }, |
| 6355 | }, |
| 6356 | flags: []string{ |
| 6357 | "-enable-ocsp-stapling", |
| 6358 | "-require-any-client-certificate", |
| 6359 | }, |
| 6360 | shouldFail: true, |
| 6361 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6362 | }) |
| 6363 | |
| 6364 | testCases = append(testCases, testCase{ |
| 6365 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6366 | config: Config{ |
| 6367 | MaxVersion: VersionTLS13, |
| 6368 | Bugs: ProtocolBugs{ |
| 6369 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6370 | }, |
| 6371 | }, |
| 6372 | shouldFail: true, |
| 6373 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6374 | }) |
| 6375 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6376 | var differentSCTList []byte |
| 6377 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6378 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6379 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6380 | // Test that extensions on intermediates are allowed but ignored. |
| 6381 | testCases = append(testCases, testCase{ |
| 6382 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6383 | config: Config{ |
| 6384 | MaxVersion: VersionTLS13, |
| 6385 | Certificates: []Certificate{rsaChainCertificate}, |
| 6386 | Bugs: ProtocolBugs{ |
| 6387 | // Send different values on the intermediate. This tests |
| 6388 | // the intermediate's extensions do not override the |
| 6389 | // leaf's. |
| 6390 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6391 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6392 | }, |
| 6393 | }, |
| 6394 | flags: []string{ |
| 6395 | "-enable-ocsp-stapling", |
| 6396 | "-expect-ocsp-response", |
| 6397 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6398 | "-enable-signed-cert-timestamps", |
| 6399 | "-expect-signed-cert-timestamps", |
| 6400 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6401 | }, |
| 6402 | resumeSession: true, |
| 6403 | }) |
| 6404 | |
| 6405 | // Test that extensions are not sent on intermediates when configured |
| 6406 | // only for a leaf. |
| 6407 | testCases = append(testCases, testCase{ |
| 6408 | testType: serverTest, |
| 6409 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6410 | config: Config{ |
| 6411 | MaxVersion: VersionTLS13, |
| 6412 | Bugs: ProtocolBugs{ |
| 6413 | ExpectNoExtensionsOnIntermediate: true, |
| 6414 | }, |
| 6415 | }, |
| 6416 | flags: []string{ |
| 6417 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6418 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6419 | "-ocsp-response", |
| 6420 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6421 | "-signed-cert-timestamps", |
| 6422 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6423 | }, |
| 6424 | }) |
| 6425 | |
| 6426 | // Test that extensions are not sent on client certificates. |
| 6427 | testCases = append(testCases, testCase{ |
| 6428 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6429 | config: Config{ |
| 6430 | MaxVersion: VersionTLS13, |
| 6431 | ClientAuth: RequireAnyClientCert, |
| 6432 | }, |
| 6433 | flags: []string{ |
| 6434 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6435 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6436 | "-ocsp-response", |
| 6437 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6438 | "-signed-cert-timestamps", |
| 6439 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6440 | }, |
| 6441 | }) |
| 6442 | |
| 6443 | testCases = append(testCases, testCase{ |
| 6444 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6445 | config: Config{ |
| 6446 | MaxVersion: VersionTLS13, |
| 6447 | Bugs: ProtocolBugs{ |
| 6448 | SendDuplicateCertExtensions: true, |
| 6449 | }, |
| 6450 | }, |
| 6451 | flags: []string{ |
| 6452 | "-enable-ocsp-stapling", |
| 6453 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6454 | }, |
| 6455 | resumeSession: true, |
| 6456 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6457 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6458 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6459 | |
| 6460 | testCases = append(testCases, testCase{ |
| 6461 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6462 | testType: serverTest, |
| 6463 | flags: []string{ |
| 6464 | "-signed-cert-timestamps", |
| 6465 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6466 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6467 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6468 | expectedError: ":INVALID_SCT_LIST:", |
| 6469 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6470 | } |
| 6471 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6472 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6473 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6474 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6475 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6476 | // have session IDs, so skip their cross-resumption |
| 6477 | // tests. |
| 6478 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6479 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6480 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6481 | } |
| 6482 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6483 | protocols := []protocol{tls} |
| 6484 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6485 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6486 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6487 | for _, protocol := range protocols { |
| 6488 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6489 | if protocol == dtls { |
| 6490 | suffix += "-DTLS" |
| 6491 | } |
| 6492 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6493 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6494 | // session resumption. |
| 6495 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6496 | continue |
| 6497 | } |
| 6498 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6499 | if sessionVers.version == resumeVers.version { |
| 6500 | testCases = append(testCases, testCase{ |
| 6501 | protocol: protocol, |
| 6502 | name: "Resume-Client" + suffix, |
| 6503 | resumeSession: true, |
| 6504 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6505 | MaxVersion: sessionVers.version, |
| 6506 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6507 | Bugs: ProtocolBugs{ |
| 6508 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6509 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6510 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6511 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6512 | expectedVersion: sessionVers.version, |
| 6513 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6514 | flags: []string{ |
| 6515 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6516 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6517 | }) |
| 6518 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6519 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6520 | |
| 6521 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6522 | // there is no way to convince a non-lookahead client the |
| 6523 | // session was resumed. It will appear to the client that a |
| 6524 | // stray ChangeCipherSpec was sent. |
| 6525 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6526 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6527 | } |
| 6528 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6529 | testCases = append(testCases, testCase{ |
| 6530 | protocol: protocol, |
| 6531 | name: "Resume-Client-Mismatch" + suffix, |
| 6532 | resumeSession: true, |
| 6533 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6534 | MaxVersion: sessionVers.version, |
| 6535 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6536 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6537 | expectedVersion: sessionVers.version, |
| 6538 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6539 | MaxVersion: resumeVers.version, |
| 6540 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6541 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6542 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6543 | }, |
| 6544 | }, |
| 6545 | expectedResumeVersion: resumeVers.version, |
| 6546 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6547 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6548 | flags: []string{ |
| 6549 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6550 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6551 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6552 | }) |
| 6553 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6554 | |
| 6555 | testCases = append(testCases, testCase{ |
| 6556 | protocol: protocol, |
| 6557 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6558 | resumeSession: true, |
| 6559 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6560 | MaxVersion: sessionVers.version, |
| 6561 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6562 | }, |
| 6563 | expectedVersion: sessionVers.version, |
| 6564 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6565 | MaxVersion: resumeVers.version, |
| 6566 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6567 | }, |
| 6568 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6569 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6570 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6571 | flags: []string{ |
| 6572 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6573 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6574 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6575 | }) |
| 6576 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6577 | testCases = append(testCases, testCase{ |
| 6578 | protocol: protocol, |
| 6579 | testType: serverTest, |
| 6580 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6581 | resumeSession: true, |
| 6582 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6583 | MaxVersion: sessionVers.version, |
| 6584 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6585 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6586 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6587 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6588 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6589 | MaxVersion: resumeVers.version, |
| 6590 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6591 | Bugs: ProtocolBugs{ |
| 6592 | SendBothTickets: true, |
| 6593 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6594 | }, |
| 6595 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6596 | flags: []string{ |
| 6597 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6598 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6599 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6600 | }) |
| 6601 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6602 | } |
| 6603 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6604 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6605 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6606 | testCases = append(testCases, testCase{ |
| 6607 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6608 | name: "ShimTicketRewritable", |
| 6609 | resumeSession: true, |
| 6610 | config: Config{ |
| 6611 | MaxVersion: VersionTLS12, |
| 6612 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6613 | Bugs: ProtocolBugs{ |
| 6614 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6615 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6616 | if err != nil { |
| 6617 | return nil, err |
| 6618 | } |
| 6619 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6620 | }, |
| 6621 | }, |
| 6622 | }, |
| 6623 | flags: []string{ |
| 6624 | "-ticket-key", |
| 6625 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6626 | }, |
| 6627 | }) |
| 6628 | |
| 6629 | // Resumptions are declined if the version does not match. |
| 6630 | testCases = append(testCases, testCase{ |
| 6631 | testType: serverTest, |
| 6632 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6633 | resumeSession: true, |
| 6634 | config: Config{ |
| 6635 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6636 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6637 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6638 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6639 | return SetShimTicketVersion(in, VersionTLS13) |
| 6640 | }, |
| 6641 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6642 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6643 | flags: []string{ |
| 6644 | "-ticket-key", |
| 6645 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6646 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6647 | expectResumeRejected: true, |
| 6648 | }) |
| 6649 | |
| 6650 | testCases = append(testCases, testCase{ |
| 6651 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6652 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6653 | resumeSession: true, |
| 6654 | config: Config{ |
| 6655 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6656 | Bugs: ProtocolBugs{ |
| 6657 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6658 | return SetShimTicketVersion(in, VersionTLS12) |
| 6659 | }, |
| 6660 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6661 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6662 | flags: []string{ |
| 6663 | "-ticket-key", |
| 6664 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6665 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6666 | expectResumeRejected: true, |
| 6667 | }) |
| 6668 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6669 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6670 | testCases = append(testCases, testCase{ |
| 6671 | testType: serverTest, |
| 6672 | name: "Resume-Server-DeclineBadCipher", |
| 6673 | resumeSession: true, |
| 6674 | config: Config{ |
| 6675 | MaxVersion: VersionTLS12, |
| 6676 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6677 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6678 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6679 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6680 | }, |
| 6681 | }, |
| 6682 | }, |
| 6683 | flags: []string{ |
| 6684 | "-ticket-key", |
| 6685 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6686 | }, |
| 6687 | expectResumeRejected: true, |
| 6688 | }) |
| 6689 | |
| 6690 | testCases = append(testCases, testCase{ |
| 6691 | testType: serverTest, |
| 6692 | name: "Resume-Server-DeclineBadCipher-2", |
| 6693 | resumeSession: true, |
| 6694 | config: Config{ |
| 6695 | MaxVersion: VersionTLS12, |
| 6696 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6697 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6698 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6699 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6700 | }, |
| 6701 | }, |
| 6702 | }, |
| 6703 | flags: []string{ |
| 6704 | "-cipher", "AES128", |
| 6705 | "-ticket-key", |
| 6706 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6707 | }, |
| 6708 | expectResumeRejected: true, |
| 6709 | }) |
| 6710 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6711 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6712 | testCases = append(testCases, testCase{ |
| 6713 | testType: serverTest, |
| 6714 | name: "Resume-Server-CipherNotPreferred", |
| 6715 | resumeSession: true, |
| 6716 | config: Config{ |
| 6717 | MaxVersion: VersionTLS12, |
| 6718 | Bugs: ProtocolBugs{ |
| 6719 | ExpectNewTicket: true, |
| 6720 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6721 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6722 | }, |
| 6723 | }, |
| 6724 | }, |
| 6725 | flags: []string{ |
| 6726 | "-ticket-key", |
| 6727 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6728 | }, |
| 6729 | shouldFail: false, |
| 6730 | expectResumeRejected: true, |
| 6731 | }) |
| 6732 | |
| 6733 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6734 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6735 | testCases = append(testCases, testCase{ |
| 6736 | testType: serverTest, |
| 6737 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6738 | resumeSession: true, |
| 6739 | config: Config{ |
| 6740 | MaxVersion: VersionTLS13, |
| 6741 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6742 | Bugs: ProtocolBugs{ |
| 6743 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6744 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6745 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6746 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6747 | }, |
| 6748 | }, |
| 6749 | }, |
| 6750 | flags: []string{ |
| 6751 | "-ticket-key", |
| 6752 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6753 | }, |
| 6754 | shouldFail: false, |
| 6755 | expectResumeRejected: true, |
| 6756 | }) |
| 6757 | |
| 6758 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6759 | testCases = append(testCases, testCase{ |
| 6760 | testType: serverTest, |
| 6761 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6762 | resumeSession: true, |
| 6763 | config: Config{ |
| 6764 | MaxVersion: VersionTLS13, |
| 6765 | Bugs: ProtocolBugs{ |
| 6766 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6767 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6768 | }, |
| 6769 | }, |
| 6770 | }, |
| 6771 | flags: []string{ |
| 6772 | "-ticket-key", |
| 6773 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6774 | }, |
| 6775 | expectResumeRejected: true, |
| 6776 | }) |
| 6777 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6778 | // If the client does not offer the cipher from the session, decline to |
| 6779 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6780 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6781 | testCases = append(testCases, testCase{ |
| 6782 | testType: serverTest, |
| 6783 | name: "Resume-Server-UnofferedCipher", |
| 6784 | resumeSession: true, |
| 6785 | config: Config{ |
| 6786 | MaxVersion: VersionTLS12, |
| 6787 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6788 | }, |
| 6789 | resumeConfig: &Config{ |
| 6790 | MaxVersion: VersionTLS12, |
| 6791 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6792 | Bugs: ProtocolBugs{ |
| 6793 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6794 | }, |
| 6795 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6796 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6797 | }) |
| 6798 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6799 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6800 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6801 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6802 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6803 | testCases = append(testCases, testCase{ |
| 6804 | testType: serverTest, |
| 6805 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6806 | resumeSession: true, |
| 6807 | config: Config{ |
| 6808 | MaxVersion: VersionTLS13, |
| 6809 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6810 | }, |
| 6811 | resumeConfig: &Config{ |
| 6812 | MaxVersion: VersionTLS13, |
| 6813 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6814 | Bugs: ProtocolBugs{ |
| 6815 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6816 | }, |
| 6817 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6818 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6819 | }) |
| 6820 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6821 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6822 | testCases = append(testCases, testCase{ |
| 6823 | name: "Resume-Client-CipherMismatch", |
| 6824 | resumeSession: true, |
| 6825 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6826 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6827 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6828 | }, |
| 6829 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6830 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6831 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6832 | Bugs: ProtocolBugs{ |
| 6833 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6834 | }, |
| 6835 | }, |
| 6836 | shouldFail: true, |
| 6837 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6838 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6839 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6840 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6841 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6842 | testCases = append(testCases, testCase{ |
| 6843 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6844 | resumeSession: true, |
| 6845 | config: Config{ |
| 6846 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6847 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6848 | }, |
| 6849 | resumeConfig: &Config{ |
| 6850 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6851 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6852 | }, |
| 6853 | }) |
| 6854 | |
| 6855 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6856 | testCases = append(testCases, testCase{ |
| 6857 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6858 | resumeSession: true, |
| 6859 | config: Config{ |
| 6860 | MaxVersion: VersionTLS13, |
| 6861 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6862 | }, |
| 6863 | resumeConfig: &Config{ |
| 6864 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6865 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6866 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6867 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6868 | }, |
| 6869 | }, |
| 6870 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6871 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6872 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6873 | |
| 6874 | testCases = append(testCases, testCase{ |
| 6875 | testType: serverTest, |
| 6876 | name: "Resume-Server-BinderWrongLength", |
| 6877 | resumeSession: true, |
| 6878 | config: Config{ |
| 6879 | MaxVersion: VersionTLS13, |
| 6880 | Bugs: ProtocolBugs{ |
| 6881 | SendShortPSKBinder: true, |
| 6882 | }, |
| 6883 | }, |
| 6884 | shouldFail: true, |
| 6885 | expectedLocalError: "remote error: error decrypting message", |
| 6886 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6887 | }) |
| 6888 | |
| 6889 | testCases = append(testCases, testCase{ |
| 6890 | testType: serverTest, |
| 6891 | name: "Resume-Server-NoPSKBinder", |
| 6892 | resumeSession: true, |
| 6893 | config: Config{ |
| 6894 | MaxVersion: VersionTLS13, |
| 6895 | Bugs: ProtocolBugs{ |
| 6896 | SendNoPSKBinder: true, |
| 6897 | }, |
| 6898 | }, |
| 6899 | shouldFail: true, |
| 6900 | expectedLocalError: "remote error: error decoding message", |
| 6901 | expectedError: ":DECODE_ERROR:", |
| 6902 | }) |
| 6903 | |
| 6904 | testCases = append(testCases, testCase{ |
| 6905 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6906 | name: "Resume-Server-ExtraPSKBinder", |
| 6907 | resumeSession: true, |
| 6908 | config: Config{ |
| 6909 | MaxVersion: VersionTLS13, |
| 6910 | Bugs: ProtocolBugs{ |
| 6911 | SendExtraPSKBinder: true, |
| 6912 | }, |
| 6913 | }, |
| 6914 | shouldFail: true, |
| 6915 | expectedLocalError: "remote error: illegal parameter", |
| 6916 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6917 | }) |
| 6918 | |
| 6919 | testCases = append(testCases, testCase{ |
| 6920 | testType: serverTest, |
| 6921 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6922 | resumeSession: true, |
| 6923 | config: Config{ |
| 6924 | MaxVersion: VersionTLS13, |
| 6925 | Bugs: ProtocolBugs{ |
| 6926 | ExtraPSKIdentity: true, |
| 6927 | }, |
| 6928 | }, |
| 6929 | shouldFail: true, |
| 6930 | expectedLocalError: "remote error: illegal parameter", |
| 6931 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6932 | }) |
| 6933 | |
| 6934 | testCases = append(testCases, testCase{ |
| 6935 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6936 | name: "Resume-Server-InvalidPSKBinder", |
| 6937 | resumeSession: true, |
| 6938 | config: Config{ |
| 6939 | MaxVersion: VersionTLS13, |
| 6940 | Bugs: ProtocolBugs{ |
| 6941 | SendInvalidPSKBinder: true, |
| 6942 | }, |
| 6943 | }, |
| 6944 | shouldFail: true, |
| 6945 | expectedLocalError: "remote error: error decrypting message", |
| 6946 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6947 | }) |
| 6948 | |
| 6949 | testCases = append(testCases, testCase{ |
| 6950 | testType: serverTest, |
| 6951 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6952 | resumeSession: true, |
| 6953 | config: Config{ |
| 6954 | MaxVersion: VersionTLS13, |
| 6955 | Bugs: ProtocolBugs{ |
| 6956 | PSKBinderFirst: true, |
| 6957 | }, |
| 6958 | }, |
| 6959 | shouldFail: true, |
| 6960 | expectedLocalError: "remote error: illegal parameter", |
| 6961 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6962 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6963 | } |
| 6964 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6965 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6966 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6967 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6968 | testType: serverTest, |
| 6969 | name: "Renegotiate-Server-Forbidden", |
| 6970 | config: Config{ |
| 6971 | MaxVersion: VersionTLS12, |
| 6972 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6973 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6974 | shouldFail: true, |
| 6975 | expectedError: ":NO_RENEGOTIATION:", |
| 6976 | expectedLocalError: "remote error: no renegotiation", |
| 6977 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6978 | // The server shouldn't echo the renegotiation extension unless |
| 6979 | // requested by the client. |
| 6980 | testCases = append(testCases, testCase{ |
| 6981 | testType: serverTest, |
| 6982 | name: "Renegotiate-Server-NoExt", |
| 6983 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6984 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6985 | Bugs: ProtocolBugs{ |
| 6986 | NoRenegotiationInfo: true, |
| 6987 | RequireRenegotiationInfo: true, |
| 6988 | }, |
| 6989 | }, |
| 6990 | shouldFail: true, |
| 6991 | expectedLocalError: "renegotiation extension missing", |
| 6992 | }) |
| 6993 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6994 | // the extension. |
| 6995 | testCases = append(testCases, testCase{ |
| 6996 | testType: serverTest, |
| 6997 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6998 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6999 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7000 | Bugs: ProtocolBugs{ |
| 7001 | NoRenegotiationInfo: true, |
| 7002 | SendRenegotiationSCSV: true, |
| 7003 | RequireRenegotiationInfo: true, |
| 7004 | }, |
| 7005 | }, |
| 7006 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7007 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7008 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7010 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7011 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7012 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7013 | }, |
| 7014 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7015 | renegotiate: 1, |
| 7016 | flags: []string{ |
| 7017 | "-renegotiate-freely", |
| 7018 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7019 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7020 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7021 | }) |
| 7022 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7023 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7024 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7025 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7026 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7027 | Bugs: ProtocolBugs{ |
| 7028 | EmptyRenegotiationInfo: true, |
| 7029 | }, |
| 7030 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7031 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7032 | shouldFail: true, |
| 7033 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7034 | }) |
| 7035 | testCases = append(testCases, testCase{ |
| 7036 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7037 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7038 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7039 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7040 | Bugs: ProtocolBugs{ |
| 7041 | BadRenegotiationInfo: true, |
| 7042 | }, |
| 7043 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7044 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7045 | shouldFail: true, |
| 7046 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7047 | }) |
| 7048 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7049 | name: "Renegotiate-Client-BadExt2", |
| 7050 | renegotiate: 1, |
| 7051 | config: Config{ |
| 7052 | MaxVersion: VersionTLS12, |
| 7053 | Bugs: ProtocolBugs{ |
| 7054 | BadRenegotiationInfoEnd: true, |
| 7055 | }, |
| 7056 | }, |
| 7057 | flags: []string{"-renegotiate-freely"}, |
| 7058 | shouldFail: true, |
| 7059 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7060 | }) |
| 7061 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7062 | name: "Renegotiate-Client-Downgrade", |
| 7063 | renegotiate: 1, |
| 7064 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7065 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7066 | Bugs: ProtocolBugs{ |
| 7067 | NoRenegotiationInfoAfterInitial: true, |
| 7068 | }, |
| 7069 | }, |
| 7070 | flags: []string{"-renegotiate-freely"}, |
| 7071 | shouldFail: true, |
| 7072 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7073 | }) |
| 7074 | testCases = append(testCases, testCase{ |
| 7075 | name: "Renegotiate-Client-Upgrade", |
| 7076 | renegotiate: 1, |
| 7077 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7078 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7079 | Bugs: ProtocolBugs{ |
| 7080 | NoRenegotiationInfoInInitial: true, |
| 7081 | }, |
| 7082 | }, |
| 7083 | flags: []string{"-renegotiate-freely"}, |
| 7084 | shouldFail: true, |
| 7085 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7086 | }) |
| 7087 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7088 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7089 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7090 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7091 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7092 | Bugs: ProtocolBugs{ |
| 7093 | NoRenegotiationInfo: true, |
| 7094 | }, |
| 7095 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7096 | flags: []string{ |
| 7097 | "-renegotiate-freely", |
| 7098 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7099 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7100 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7101 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7102 | |
| 7103 | // Test that the server may switch ciphers on renegotiation without |
| 7104 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7105 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7106 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7107 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7108 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7109 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7110 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7111 | }, |
| 7112 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7113 | flags: []string{ |
| 7114 | "-renegotiate-freely", |
| 7115 | "-expect-total-renegotiations", "1", |
| 7116 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7117 | }) |
| 7118 | testCases = append(testCases, testCase{ |
| 7119 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7120 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7121 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7122 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7123 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7124 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7125 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7126 | flags: []string{ |
| 7127 | "-renegotiate-freely", |
| 7128 | "-expect-total-renegotiations", "1", |
| 7129 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7130 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7131 | |
| 7132 | // Test that the server may not switch versions on renegotiation. |
| 7133 | testCases = append(testCases, testCase{ |
| 7134 | name: "Renegotiate-Client-SwitchVersion", |
| 7135 | config: Config{ |
| 7136 | MaxVersion: VersionTLS12, |
| 7137 | // Pick a cipher which exists at both versions. |
| 7138 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7139 | Bugs: ProtocolBugs{ |
| 7140 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7141 | // Avoid failing early at the record layer. |
| 7142 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7143 | }, |
| 7144 | }, |
| 7145 | renegotiate: 1, |
| 7146 | flags: []string{ |
| 7147 | "-renegotiate-freely", |
| 7148 | "-expect-total-renegotiations", "1", |
| 7149 | }, |
| 7150 | shouldFail: true, |
| 7151 | expectedError: ":WRONG_SSL_VERSION:", |
| 7152 | }) |
| 7153 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7154 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7155 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7156 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7157 | config: Config{ |
| 7158 | MaxVersion: VersionTLS10, |
| 7159 | Bugs: ProtocolBugs{ |
| 7160 | RequireSameRenegoClientVersion: true, |
| 7161 | }, |
| 7162 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7163 | flags: []string{ |
| 7164 | "-renegotiate-freely", |
| 7165 | "-expect-total-renegotiations", "1", |
| 7166 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7167 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7168 | testCases = append(testCases, testCase{ |
| 7169 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7170 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7171 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7172 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7173 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7174 | NextProtos: []string{"foo"}, |
| 7175 | }, |
| 7176 | flags: []string{ |
| 7177 | "-false-start", |
| 7178 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7179 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7180 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7181 | }, |
| 7182 | shimWritesFirst: true, |
| 7183 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7184 | |
| 7185 | // Client-side renegotiation controls. |
| 7186 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7187 | name: "Renegotiate-Client-Forbidden-1", |
| 7188 | config: Config{ |
| 7189 | MaxVersion: VersionTLS12, |
| 7190 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7191 | renegotiate: 1, |
| 7192 | shouldFail: true, |
| 7193 | expectedError: ":NO_RENEGOTIATION:", |
| 7194 | expectedLocalError: "remote error: no renegotiation", |
| 7195 | }) |
| 7196 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7197 | name: "Renegotiate-Client-Once-1", |
| 7198 | config: Config{ |
| 7199 | MaxVersion: VersionTLS12, |
| 7200 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7201 | renegotiate: 1, |
| 7202 | flags: []string{ |
| 7203 | "-renegotiate-once", |
| 7204 | "-expect-total-renegotiations", "1", |
| 7205 | }, |
| 7206 | }) |
| 7207 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7208 | name: "Renegotiate-Client-Freely-1", |
| 7209 | config: Config{ |
| 7210 | MaxVersion: VersionTLS12, |
| 7211 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7212 | renegotiate: 1, |
| 7213 | flags: []string{ |
| 7214 | "-renegotiate-freely", |
| 7215 | "-expect-total-renegotiations", "1", |
| 7216 | }, |
| 7217 | }) |
| 7218 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7219 | name: "Renegotiate-Client-Once-2", |
| 7220 | config: Config{ |
| 7221 | MaxVersion: VersionTLS12, |
| 7222 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7223 | renegotiate: 2, |
| 7224 | flags: []string{"-renegotiate-once"}, |
| 7225 | shouldFail: true, |
| 7226 | expectedError: ":NO_RENEGOTIATION:", |
| 7227 | expectedLocalError: "remote error: no renegotiation", |
| 7228 | }) |
| 7229 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7230 | name: "Renegotiate-Client-Freely-2", |
| 7231 | config: Config{ |
| 7232 | MaxVersion: VersionTLS12, |
| 7233 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7234 | renegotiate: 2, |
| 7235 | flags: []string{ |
| 7236 | "-renegotiate-freely", |
| 7237 | "-expect-total-renegotiations", "2", |
| 7238 | }, |
| 7239 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7240 | testCases = append(testCases, testCase{ |
| 7241 | name: "Renegotiate-Client-NoIgnore", |
| 7242 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7243 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7244 | Bugs: ProtocolBugs{ |
| 7245 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7246 | }, |
| 7247 | }, |
| 7248 | shouldFail: true, |
| 7249 | expectedError: ":NO_RENEGOTIATION:", |
| 7250 | }) |
| 7251 | testCases = append(testCases, testCase{ |
| 7252 | name: "Renegotiate-Client-Ignore", |
| 7253 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7254 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7255 | Bugs: ProtocolBugs{ |
| 7256 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7257 | }, |
| 7258 | }, |
| 7259 | flags: []string{ |
| 7260 | "-renegotiate-ignore", |
| 7261 | "-expect-total-renegotiations", "0", |
| 7262 | }, |
| 7263 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7264 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7265 | // Renegotiation is not allowed at SSL 3.0. |
| 7266 | testCases = append(testCases, testCase{ |
| 7267 | name: "Renegotiate-Client-SSL3", |
| 7268 | config: Config{ |
| 7269 | MaxVersion: VersionSSL30, |
| 7270 | }, |
| 7271 | renegotiate: 1, |
| 7272 | flags: []string{ |
| 7273 | "-renegotiate-freely", |
| 7274 | "-expect-total-renegotiations", "1", |
| 7275 | }, |
| 7276 | shouldFail: true, |
| 7277 | expectedError: ":NO_RENEGOTIATION:", |
| 7278 | expectedLocalError: "remote error: no renegotiation", |
| 7279 | }) |
| 7280 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7281 | // Renegotiation is not allowed when there is an unfinished write. |
| 7282 | testCases = append(testCases, testCase{ |
| 7283 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7284 | config: Config{ |
| 7285 | MaxVersion: VersionTLS12, |
| 7286 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7287 | renegotiate: 1, |
| 7288 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7289 | flags: []string{ |
| 7290 | "-async", |
| 7291 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7292 | }, |
| 7293 | shouldFail: true, |
| 7294 | expectedError: ":NO_RENEGOTIATION:", |
| 7295 | // We do not successfully send the no_renegotiation alert in |
| 7296 | // this case. https://crbug.com/boringssl/130 |
| 7297 | }) |
| 7298 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7299 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7300 | testCases = append(testCases, testCase{ |
| 7301 | name: "StrayHelloRequest", |
| 7302 | config: Config{ |
| 7303 | MaxVersion: VersionTLS12, |
| 7304 | Bugs: ProtocolBugs{ |
| 7305 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7306 | }, |
| 7307 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7308 | shouldFail: true, |
| 7309 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7310 | }) |
| 7311 | testCases = append(testCases, testCase{ |
| 7312 | name: "StrayHelloRequest-Packed", |
| 7313 | config: Config{ |
| 7314 | MaxVersion: VersionTLS12, |
| 7315 | Bugs: ProtocolBugs{ |
| 7316 | PackHandshakeFlight: true, |
| 7317 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7318 | }, |
| 7319 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7320 | shouldFail: true, |
| 7321 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7322 | }) |
| 7323 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7324 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7325 | // the same record. |
| 7326 | testCases = append(testCases, testCase{ |
| 7327 | name: "Renegotiate-Client-Packed", |
| 7328 | config: Config{ |
| 7329 | MaxVersion: VersionTLS12, |
| 7330 | Bugs: ProtocolBugs{ |
| 7331 | PackHandshakeFlight: true, |
| 7332 | PackHelloRequestWithFinished: true, |
| 7333 | }, |
| 7334 | }, |
| 7335 | renegotiate: 1, |
| 7336 | flags: []string{ |
| 7337 | "-renegotiate-freely", |
| 7338 | "-expect-total-renegotiations", "1", |
| 7339 | }, |
| 7340 | }) |
| 7341 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7342 | // Renegotiation is forbidden in TLS 1.3. |
| 7343 | testCases = append(testCases, testCase{ |
| 7344 | name: "Renegotiate-Client-TLS13", |
| 7345 | config: Config{ |
| 7346 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7347 | Bugs: ProtocolBugs{ |
| 7348 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7349 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7350 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7351 | flags: []string{ |
| 7352 | "-renegotiate-freely", |
| 7353 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7354 | shouldFail: true, |
| 7355 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7356 | }) |
| 7357 | |
| 7358 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7359 | testCases = append(testCases, testCase{ |
| 7360 | name: "StrayHelloRequest-TLS13", |
| 7361 | config: Config{ |
| 7362 | MaxVersion: VersionTLS13, |
| 7363 | Bugs: ProtocolBugs{ |
| 7364 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7365 | }, |
| 7366 | }, |
| 7367 | shouldFail: true, |
| 7368 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7369 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7370 | |
| 7371 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7372 | // always reads as supporting it, regardless of whether it was |
| 7373 | // negotiated. |
| 7374 | testCases = append(testCases, testCase{ |
| 7375 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7376 | config: Config{ |
| 7377 | MaxVersion: VersionTLS13, |
| 7378 | Bugs: ProtocolBugs{ |
| 7379 | NoRenegotiationInfo: true, |
| 7380 | }, |
| 7381 | }, |
| 7382 | flags: []string{ |
| 7383 | "-expect-secure-renegotiation", |
| 7384 | }, |
| 7385 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7386 | |
| 7387 | // Certificates may not change on renegotiation. |
| 7388 | testCases = append(testCases, testCase{ |
| 7389 | name: "Renegotiation-CertificateChange", |
| 7390 | config: Config{ |
| 7391 | MaxVersion: VersionTLS12, |
| 7392 | Certificates: []Certificate{rsaCertificate}, |
| 7393 | Bugs: ProtocolBugs{ |
| 7394 | RenegotiationCertificate: &rsaChainCertificate, |
| 7395 | }, |
| 7396 | }, |
| 7397 | renegotiate: 1, |
| 7398 | flags: []string{"-renegotiate-freely"}, |
| 7399 | shouldFail: true, |
| 7400 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7401 | }) |
| 7402 | testCases = append(testCases, testCase{ |
| 7403 | name: "Renegotiation-CertificateChange-2", |
| 7404 | config: Config{ |
| 7405 | MaxVersion: VersionTLS12, |
| 7406 | Certificates: []Certificate{rsaCertificate}, |
| 7407 | Bugs: ProtocolBugs{ |
| 7408 | RenegotiationCertificate: &rsa1024Certificate, |
| 7409 | }, |
| 7410 | }, |
| 7411 | renegotiate: 1, |
| 7412 | flags: []string{"-renegotiate-freely"}, |
| 7413 | shouldFail: true, |
| 7414 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7415 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7416 | |
| 7417 | // We do not negotiate ALPN after the initial handshake. This is |
| 7418 | // error-prone and only risks bugs in consumers. |
| 7419 | testCases = append(testCases, testCase{ |
| 7420 | testType: clientTest, |
| 7421 | name: "Renegotiation-ForbidALPN", |
| 7422 | config: Config{ |
| 7423 | MaxVersion: VersionTLS12, |
| 7424 | Bugs: ProtocolBugs{ |
| 7425 | // Forcibly negotiate ALPN on both initial and |
| 7426 | // renegotiation handshakes. The test stack will |
| 7427 | // internally check the client does not offer |
| 7428 | // it. |
| 7429 | SendALPN: "foo", |
| 7430 | }, |
| 7431 | }, |
| 7432 | flags: []string{ |
| 7433 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7434 | "-expect-alpn", "foo", |
| 7435 | "-renegotiate-freely", |
| 7436 | }, |
| 7437 | renegotiate: 1, |
| 7438 | shouldFail: true, |
| 7439 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7440 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7441 | } |
| 7442 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7443 | func addDTLSReplayTests() { |
| 7444 | // Test that sequence number replays are detected. |
| 7445 | testCases = append(testCases, testCase{ |
| 7446 | protocol: dtls, |
| 7447 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7448 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7449 | replayWrites: true, |
| 7450 | }) |
| 7451 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7452 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7453 | // than the retransmit window. |
| 7454 | testCases = append(testCases, testCase{ |
| 7455 | protocol: dtls, |
| 7456 | name: "DTLS-Replay-LargeGaps", |
| 7457 | config: Config{ |
| 7458 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7459 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7460 | return in * 127 |
| 7461 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7462 | }, |
| 7463 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7464 | messageCount: 200, |
| 7465 | replayWrites: true, |
| 7466 | }) |
| 7467 | |
| 7468 | // Test the incoming sequence number changing non-monotonically. |
| 7469 | testCases = append(testCases, testCase{ |
| 7470 | protocol: dtls, |
| 7471 | name: "DTLS-Replay-NonMonotonic", |
| 7472 | config: Config{ |
| 7473 | Bugs: ProtocolBugs{ |
| 7474 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7475 | return in ^ 31 |
| 7476 | }, |
| 7477 | }, |
| 7478 | }, |
| 7479 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7480 | replayWrites: true, |
| 7481 | }) |
| 7482 | } |
| 7483 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7484 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7485 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7486 | id signatureAlgorithm |
| 7487 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7488 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7489 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7490 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7491 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7492 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7493 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7494 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7495 | // hash function doesn't have to match the curve and so the same |
| 7496 | // signature algorithm works with P-224. |
| 7497 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7498 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7499 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7500 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7501 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7502 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7503 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7504 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7505 | // Tests for key types prior to TLS 1.2. |
| 7506 | {"RSA", 0, testCertRSA}, |
| 7507 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7508 | } |
| 7509 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7510 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7511 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7512 | |
| 7513 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7514 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7515 | // versions a signing cipher. |
| 7516 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7517 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7518 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7519 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7520 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7521 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7522 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7523 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7524 | var allAlgorithms []signatureAlgorithm |
| 7525 | for _, alg := range testSignatureAlgorithms { |
| 7526 | if alg.id != 0 { |
| 7527 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7528 | } |
| 7529 | } |
| 7530 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7531 | // Make sure each signature algorithm works. Include some fake values in |
| 7532 | // the list and ensure they're ignored. |
| 7533 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7534 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7535 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7536 | continue |
| 7537 | } |
| 7538 | |
| 7539 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7540 | // or remove it in C. |
| 7541 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7542 | continue |
| 7543 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7544 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7545 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7546 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7547 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7548 | shouldSignFail = true |
| 7549 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7550 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7551 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7552 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7553 | shouldSignFail = true |
| 7554 | shouldVerifyFail = true |
| 7555 | } |
| 7556 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7557 | // the curve has to match the hash size. |
| 7558 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7559 | shouldSignFail = true |
| 7560 | shouldVerifyFail = true |
| 7561 | } |
| 7562 | |
| 7563 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7564 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7565 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7566 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7567 | |
| 7568 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7569 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7570 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7571 | } |
| 7572 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7573 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7574 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7575 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7576 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7577 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7578 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7579 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7580 | config: Config{ |
| 7581 | MaxVersion: ver.version, |
| 7582 | ClientAuth: RequireAnyClientCert, |
| 7583 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7584 | fakeSigAlg1, |
| 7585 | alg.id, |
| 7586 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7587 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7588 | }, |
| 7589 | flags: []string{ |
| 7590 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7591 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7592 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7593 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7594 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7595 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7596 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7597 | expectedError: signError, |
| 7598 | expectedPeerSignatureAlgorithm: alg.id, |
| 7599 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7600 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7601 | testCases = append(testCases, testCase{ |
| 7602 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7603 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7604 | config: Config{ |
| 7605 | MaxVersion: ver.version, |
| 7606 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7607 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7608 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7609 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7610 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7611 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7612 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7613 | // Some signature algorithms may not be advertised. |
| 7614 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7615 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7616 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7617 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7618 | flags: []string{ |
| 7619 | "-require-any-client-certificate", |
| 7620 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7621 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7622 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7623 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7624 | // Resume the session to assert the peer signature |
| 7625 | // algorithm is reported on both handshakes. |
| 7626 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7627 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7628 | expectedError: verifyError, |
| 7629 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7630 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7631 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7632 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7633 | testCases = append(testCases, testCase{ |
| 7634 | testType: serverTest, |
| 7635 | name: "ServerAuth-Sign" + suffix, |
| 7636 | config: Config{ |
| 7637 | MaxVersion: ver.version, |
| 7638 | CipherSuites: signingCiphers, |
| 7639 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7640 | fakeSigAlg1, |
| 7641 | alg.id, |
| 7642 | fakeSigAlg2, |
| 7643 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7644 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7645 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7646 | flags: []string{ |
| 7647 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7648 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7649 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7650 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7651 | }, |
| 7652 | shouldFail: shouldSignFail, |
| 7653 | expectedError: signError, |
| 7654 | expectedPeerSignatureAlgorithm: alg.id, |
| 7655 | }) |
| 7656 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7657 | |
| 7658 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7659 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7660 | config: Config{ |
| 7661 | MaxVersion: ver.version, |
| 7662 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7663 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7664 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7665 | alg.id, |
| 7666 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7667 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7668 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7669 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7670 | // Some signature algorithms may not be advertised. |
| 7671 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7672 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7673 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7674 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7675 | flags: []string{ |
| 7676 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7677 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7678 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7679 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7680 | // Resume the session to assert the peer signature |
| 7681 | // algorithm is reported on both handshakes. |
| 7682 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7683 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7684 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7685 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7686 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7687 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7688 | testCases = append(testCases, testCase{ |
| 7689 | testType: serverTest, |
| 7690 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7691 | config: Config{ |
| 7692 | MaxVersion: ver.version, |
| 7693 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7694 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7695 | alg.id, |
| 7696 | }, |
| 7697 | Bugs: ProtocolBugs{ |
| 7698 | InvalidSignature: true, |
| 7699 | }, |
| 7700 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7701 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7702 | flags: []string{ |
| 7703 | "-require-any-client-certificate", |
| 7704 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7705 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7706 | }, |
| 7707 | shouldFail: true, |
| 7708 | expectedError: ":BAD_SIGNATURE:", |
| 7709 | }) |
| 7710 | |
| 7711 | testCases = append(testCases, testCase{ |
| 7712 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7713 | config: Config{ |
| 7714 | MaxVersion: ver.version, |
| 7715 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7716 | CipherSuites: signingCiphers, |
| 7717 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7718 | alg.id, |
| 7719 | }, |
| 7720 | Bugs: ProtocolBugs{ |
| 7721 | InvalidSignature: true, |
| 7722 | }, |
| 7723 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7724 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7725 | flags: []string{ |
| 7726 | "-enable-all-curves", |
| 7727 | "-enable-ed25519", |
| 7728 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7729 | shouldFail: true, |
| 7730 | expectedError: ":BAD_SIGNATURE:", |
| 7731 | }) |
| 7732 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7733 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7734 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7735 | testCases = append(testCases, testCase{ |
| 7736 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7737 | config: Config{ |
| 7738 | MaxVersion: ver.version, |
| 7739 | ClientAuth: RequireAnyClientCert, |
| 7740 | VerifySignatureAlgorithms: allAlgorithms, |
| 7741 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7742 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7743 | flags: []string{ |
| 7744 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7745 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7746 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7747 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7748 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7749 | }, |
| 7750 | expectedPeerSignatureAlgorithm: alg.id, |
| 7751 | }) |
| 7752 | |
| 7753 | testCases = append(testCases, testCase{ |
| 7754 | testType: serverTest, |
| 7755 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7756 | config: Config{ |
| 7757 | MaxVersion: ver.version, |
| 7758 | CipherSuites: signingCiphers, |
| 7759 | VerifySignatureAlgorithms: allAlgorithms, |
| 7760 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7761 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7762 | flags: []string{ |
| 7763 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7764 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7765 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7766 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7767 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7768 | }, |
| 7769 | expectedPeerSignatureAlgorithm: alg.id, |
| 7770 | }) |
| 7771 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7772 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7773 | } |
| 7774 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7775 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7776 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7777 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7778 | config: Config{ |
| 7779 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7780 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7781 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7782 | signatureECDSAWithP521AndSHA512, |
| 7783 | signatureRSAPKCS1WithSHA384, |
| 7784 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7785 | }, |
| 7786 | }, |
| 7787 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7788 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7789 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7790 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7791 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7792 | }) |
| 7793 | |
| 7794 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7795 | name: "ClientAuth-SignatureType-TLS13", |
| 7796 | config: Config{ |
| 7797 | ClientAuth: RequireAnyClientCert, |
| 7798 | MaxVersion: VersionTLS13, |
| 7799 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7800 | signatureECDSAWithP521AndSHA512, |
| 7801 | signatureRSAPKCS1WithSHA384, |
| 7802 | signatureRSAPSSWithSHA384, |
| 7803 | signatureECDSAWithSHA1, |
| 7804 | }, |
| 7805 | }, |
| 7806 | flags: []string{ |
| 7807 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7808 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7809 | }, |
| 7810 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7811 | }) |
| 7812 | |
| 7813 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7814 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7815 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7816 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7817 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7818 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7819 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7820 | signatureECDSAWithP521AndSHA512, |
| 7821 | signatureRSAPKCS1WithSHA384, |
| 7822 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7823 | }, |
| 7824 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7825 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7826 | }) |
| 7827 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7828 | testCases = append(testCases, testCase{ |
| 7829 | testType: serverTest, |
| 7830 | name: "ServerAuth-SignatureType-TLS13", |
| 7831 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7832 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7833 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7834 | signatureECDSAWithP521AndSHA512, |
| 7835 | signatureRSAPKCS1WithSHA384, |
| 7836 | signatureRSAPSSWithSHA384, |
| 7837 | signatureECDSAWithSHA1, |
| 7838 | }, |
| 7839 | }, |
| 7840 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7841 | }) |
| 7842 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7843 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7844 | testCases = append(testCases, testCase{ |
| 7845 | testType: serverTest, |
| 7846 | name: "Verify-ClientAuth-SignatureType", |
| 7847 | config: Config{ |
| 7848 | MaxVersion: VersionTLS12, |
| 7849 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7850 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7851 | signatureRSAPKCS1WithSHA256, |
| 7852 | }, |
| 7853 | Bugs: ProtocolBugs{ |
| 7854 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7855 | }, |
| 7856 | }, |
| 7857 | flags: []string{ |
| 7858 | "-require-any-client-certificate", |
| 7859 | }, |
| 7860 | shouldFail: true, |
| 7861 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7862 | }) |
| 7863 | |
| 7864 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7865 | testType: serverTest, |
| 7866 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7867 | config: Config{ |
| 7868 | MaxVersion: VersionTLS13, |
| 7869 | Certificates: []Certificate{rsaCertificate}, |
| 7870 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7871 | signatureRSAPSSWithSHA256, |
| 7872 | }, |
| 7873 | Bugs: ProtocolBugs{ |
| 7874 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7875 | }, |
| 7876 | }, |
| 7877 | flags: []string{ |
| 7878 | "-require-any-client-certificate", |
| 7879 | }, |
| 7880 | shouldFail: true, |
| 7881 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7882 | }) |
| 7883 | |
| 7884 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7885 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7886 | config: Config{ |
| 7887 | MaxVersion: VersionTLS12, |
| 7888 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7889 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7890 | signatureRSAPKCS1WithSHA256, |
| 7891 | }, |
| 7892 | Bugs: ProtocolBugs{ |
| 7893 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7894 | }, |
| 7895 | }, |
| 7896 | shouldFail: true, |
| 7897 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7898 | }) |
| 7899 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7900 | testCases = append(testCases, testCase{ |
| 7901 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7902 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7903 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7904 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7905 | signatureRSAPSSWithSHA256, |
| 7906 | }, |
| 7907 | Bugs: ProtocolBugs{ |
| 7908 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7909 | }, |
| 7910 | }, |
| 7911 | shouldFail: true, |
| 7912 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7913 | }) |
| 7914 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7915 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 7916 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7917 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7918 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7919 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7920 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7921 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7922 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7923 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7924 | }, |
| 7925 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7926 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7927 | }, |
| 7928 | }, |
| 7929 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7930 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7931 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7932 | }, |
| 7933 | }) |
| 7934 | |
| 7935 | testCases = append(testCases, testCase{ |
| 7936 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7937 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7938 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7939 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7940 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7941 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7942 | }, |
| 7943 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7944 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7945 | }, |
| 7946 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7947 | flags: []string{ |
| 7948 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7949 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7950 | }, |
| 7951 | }) |
| 7952 | |
| 7953 | testCases = append(testCases, testCase{ |
| 7954 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7955 | config: Config{ |
| 7956 | MaxVersion: VersionTLS12, |
| 7957 | ClientAuth: RequireAnyClientCert, |
| 7958 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7959 | signatureECDSAWithSHA1, |
| 7960 | }, |
| 7961 | Bugs: ProtocolBugs{ |
| 7962 | NoSignatureAlgorithms: true, |
| 7963 | }, |
| 7964 | }, |
| 7965 | flags: []string{ |
| 7966 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7967 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7968 | }, |
| 7969 | }) |
| 7970 | |
| 7971 | testCases = append(testCases, testCase{ |
| 7972 | testType: serverTest, |
| 7973 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 7974 | config: Config{ |
| 7975 | MaxVersion: VersionTLS12, |
| 7976 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7977 | signatureECDSAWithSHA1, |
| 7978 | }, |
| 7979 | Bugs: ProtocolBugs{ |
| 7980 | NoSignatureAlgorithms: true, |
| 7981 | }, |
| 7982 | }, |
| 7983 | flags: []string{ |
| 7984 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7985 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7986 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7987 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7988 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7989 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7990 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7991 | config: Config{ |
| 7992 | MaxVersion: VersionTLS13, |
| 7993 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7994 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7995 | signatureRSAPKCS1WithSHA1, |
| 7996 | }, |
| 7997 | Bugs: ProtocolBugs{ |
| 7998 | NoSignatureAlgorithms: true, |
| 7999 | }, |
| 8000 | }, |
| 8001 | flags: []string{ |
| 8002 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8003 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8004 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8005 | shouldFail: true, |
| 8006 | // An empty CertificateRequest signature algorithm list is a |
| 8007 | // syntax error in TLS 1.3. |
| 8008 | expectedError: ":DECODE_ERROR:", |
| 8009 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8010 | }) |
| 8011 | |
| 8012 | testCases = append(testCases, testCase{ |
| 8013 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8014 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8015 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8016 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8017 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8018 | signatureRSAPKCS1WithSHA1, |
| 8019 | }, |
| 8020 | Bugs: ProtocolBugs{ |
| 8021 | NoSignatureAlgorithms: true, |
| 8022 | }, |
| 8023 | }, |
| 8024 | shouldFail: true, |
| 8025 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8026 | }) |
| 8027 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8028 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8029 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8030 | testCases = append(testCases, testCase{ |
| 8031 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8032 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8033 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8034 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8035 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8036 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8037 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8038 | }, |
| 8039 | Bugs: ProtocolBugs{ |
| 8040 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8041 | }, |
| 8042 | }, |
| 8043 | flags: []string{"-require-any-client-certificate"}, |
| 8044 | shouldFail: true, |
| 8045 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8046 | }) |
| 8047 | |
| 8048 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8049 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8050 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8051 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8052 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8053 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8054 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8055 | }, |
| 8056 | Bugs: ProtocolBugs{ |
| 8057 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8058 | }, |
| 8059 | }, |
| 8060 | shouldFail: true, |
| 8061 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8062 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8063 | testCases = append(testCases, testCase{ |
| 8064 | testType: serverTest, |
| 8065 | name: "ClientAuth-Enforced-TLS13", |
| 8066 | config: Config{ |
| 8067 | MaxVersion: VersionTLS13, |
| 8068 | Certificates: []Certificate{rsaCertificate}, |
| 8069 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8070 | signatureRSAPKCS1WithMD5, |
| 8071 | }, |
| 8072 | Bugs: ProtocolBugs{ |
| 8073 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8074 | IgnoreSignatureVersionChecks: true, |
| 8075 | }, |
| 8076 | }, |
| 8077 | flags: []string{"-require-any-client-certificate"}, |
| 8078 | shouldFail: true, |
| 8079 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8080 | }) |
| 8081 | |
| 8082 | testCases = append(testCases, testCase{ |
| 8083 | name: "ServerAuth-Enforced-TLS13", |
| 8084 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8085 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8086 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8087 | signatureRSAPKCS1WithMD5, |
| 8088 | }, |
| 8089 | Bugs: ProtocolBugs{ |
| 8090 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8091 | IgnoreSignatureVersionChecks: true, |
| 8092 | }, |
| 8093 | }, |
| 8094 | shouldFail: true, |
| 8095 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8096 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8097 | |
| 8098 | // Test that the agreed upon digest respects the client preferences and |
| 8099 | // the server digests. |
| 8100 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8101 | name: "NoCommonAlgorithms-Digests", |
| 8102 | config: Config{ |
| 8103 | MaxVersion: VersionTLS12, |
| 8104 | ClientAuth: RequireAnyClientCert, |
| 8105 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8106 | signatureRSAPKCS1WithSHA512, |
| 8107 | signatureRSAPKCS1WithSHA1, |
| 8108 | }, |
| 8109 | }, |
| 8110 | flags: []string{ |
| 8111 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8112 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8113 | "-digest-prefs", "SHA256", |
| 8114 | }, |
| 8115 | shouldFail: true, |
| 8116 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8117 | }) |
| 8118 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8119 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8120 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8121 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8122 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8123 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8124 | signatureRSAPKCS1WithSHA512, |
| 8125 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8126 | }, |
| 8127 | }, |
| 8128 | flags: []string{ |
| 8129 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8130 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8131 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8132 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8133 | shouldFail: true, |
| 8134 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8135 | }) |
| 8136 | testCases = append(testCases, testCase{ |
| 8137 | name: "NoCommonAlgorithms-TLS13", |
| 8138 | config: Config{ |
| 8139 | MaxVersion: VersionTLS13, |
| 8140 | ClientAuth: RequireAnyClientCert, |
| 8141 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8142 | signatureRSAPSSWithSHA512, |
| 8143 | signatureRSAPSSWithSHA384, |
| 8144 | }, |
| 8145 | }, |
| 8146 | flags: []string{ |
| 8147 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8148 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8149 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 8150 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8151 | shouldFail: true, |
| 8152 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8153 | }) |
| 8154 | testCases = append(testCases, testCase{ |
| 8155 | name: "Agree-Digest-SHA256", |
| 8156 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8157 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8158 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8159 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8160 | signatureRSAPKCS1WithSHA1, |
| 8161 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8162 | }, |
| 8163 | }, |
| 8164 | flags: []string{ |
| 8165 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8166 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8167 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8168 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8169 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8170 | }) |
| 8171 | testCases = append(testCases, testCase{ |
| 8172 | name: "Agree-Digest-SHA1", |
| 8173 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8174 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8175 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8176 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8177 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8178 | }, |
| 8179 | }, |
| 8180 | flags: []string{ |
| 8181 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8182 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8183 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8184 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8185 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8186 | }) |
| 8187 | testCases = append(testCases, testCase{ |
| 8188 | name: "Agree-Digest-Default", |
| 8189 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8190 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8191 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8192 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8193 | signatureRSAPKCS1WithSHA256, |
| 8194 | signatureECDSAWithP256AndSHA256, |
| 8195 | signatureRSAPKCS1WithSHA1, |
| 8196 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8197 | }, |
| 8198 | }, |
| 8199 | flags: []string{ |
| 8200 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8201 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8202 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8203 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8204 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8205 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8206 | // Test that the signing preference list may include extra algorithms |
| 8207 | // without negotiation problems. |
| 8208 | testCases = append(testCases, testCase{ |
| 8209 | testType: serverTest, |
| 8210 | name: "FilterExtraAlgorithms", |
| 8211 | config: Config{ |
| 8212 | MaxVersion: VersionTLS12, |
| 8213 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8214 | signatureRSAPKCS1WithSHA256, |
| 8215 | }, |
| 8216 | }, |
| 8217 | flags: []string{ |
| 8218 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8219 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8220 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8221 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8222 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8223 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8224 | }, |
| 8225 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8226 | }) |
| 8227 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8228 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8229 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8230 | testCases = append(testCases, testCase{ |
| 8231 | name: "CheckLeafCurve", |
| 8232 | config: Config{ |
| 8233 | MaxVersion: VersionTLS12, |
| 8234 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8235 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8236 | }, |
| 8237 | flags: []string{"-p384-only"}, |
| 8238 | shouldFail: true, |
| 8239 | expectedError: ":BAD_ECC_CERT:", |
| 8240 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8241 | |
| 8242 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8243 | testCases = append(testCases, testCase{ |
| 8244 | name: "CheckLeafCurve-TLS13", |
| 8245 | config: Config{ |
| 8246 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8247 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8248 | }, |
| 8249 | flags: []string{"-p384-only"}, |
| 8250 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8251 | |
| 8252 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8253 | testCases = append(testCases, testCase{ |
| 8254 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8255 | config: Config{ |
| 8256 | MaxVersion: VersionTLS12, |
| 8257 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8258 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8259 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8260 | signatureECDSAWithP384AndSHA384, |
| 8261 | }, |
| 8262 | }, |
| 8263 | }) |
| 8264 | |
| 8265 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8266 | testCases = append(testCases, testCase{ |
| 8267 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8268 | config: Config{ |
| 8269 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8270 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8271 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8272 | signatureECDSAWithP384AndSHA384, |
| 8273 | }, |
| 8274 | Bugs: ProtocolBugs{ |
| 8275 | SkipECDSACurveCheck: true, |
| 8276 | }, |
| 8277 | }, |
| 8278 | shouldFail: true, |
| 8279 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8280 | }) |
| 8281 | |
| 8282 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8283 | // account. |
| 8284 | testCases = append(testCases, testCase{ |
| 8285 | testType: serverTest, |
| 8286 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8287 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8288 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8289 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8290 | signatureECDSAWithP384AndSHA384, |
| 8291 | signatureECDSAWithP256AndSHA256, |
| 8292 | }, |
| 8293 | }, |
| 8294 | flags: []string{ |
| 8295 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8296 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8297 | }, |
| 8298 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8299 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8300 | |
| 8301 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8302 | // server does not attempt to sign in that case. |
| 8303 | testCases = append(testCases, testCase{ |
| 8304 | testType: serverTest, |
| 8305 | name: "RSA-PSS-Large", |
| 8306 | config: Config{ |
| 8307 | MaxVersion: VersionTLS13, |
| 8308 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8309 | signatureRSAPSSWithSHA512, |
| 8310 | }, |
| 8311 | }, |
| 8312 | flags: []string{ |
| 8313 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8314 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8315 | }, |
| 8316 | shouldFail: true, |
| 8317 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8318 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8319 | |
| 8320 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8321 | testCases = append(testCases, testCase{ |
| 8322 | testType: clientTest, |
| 8323 | name: "RSA-PSS-Default-Verify", |
| 8324 | config: Config{ |
| 8325 | MaxVersion: VersionTLS12, |
| 8326 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8327 | signatureRSAPSSWithSHA256, |
| 8328 | }, |
| 8329 | }, |
| 8330 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8331 | }) |
| 8332 | |
| 8333 | testCases = append(testCases, testCase{ |
| 8334 | testType: serverTest, |
| 8335 | name: "RSA-PSS-Default-Sign", |
| 8336 | config: Config{ |
| 8337 | MaxVersion: VersionTLS12, |
| 8338 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8339 | signatureRSAPSSWithSHA256, |
| 8340 | }, |
| 8341 | }, |
| 8342 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8343 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8344 | |
| 8345 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8346 | // Ed25519's signature algorithm. |
| 8347 | testCases = append(testCases, testCase{ |
| 8348 | testType: clientTest, |
| 8349 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8350 | config: Config{ |
| 8351 | MaxVersion: VersionTLS11, |
| 8352 | Certificates: []Certificate{ed25519Certificate}, |
| 8353 | Bugs: ProtocolBugs{ |
| 8354 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8355 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8356 | }, |
| 8357 | }, |
| 8358 | flags: []string{"-enable-ed25519"}, |
| 8359 | shouldFail: true, |
| 8360 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8361 | }) |
| 8362 | testCases = append(testCases, testCase{ |
| 8363 | testType: serverTest, |
| 8364 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8365 | config: Config{ |
| 8366 | MaxVersion: VersionTLS11, |
| 8367 | }, |
| 8368 | flags: []string{ |
| 8369 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8370 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8371 | }, |
| 8372 | shouldFail: true, |
| 8373 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8374 | }) |
| 8375 | testCases = append(testCases, testCase{ |
| 8376 | testType: serverTest, |
| 8377 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8378 | config: Config{ |
| 8379 | MaxVersion: VersionTLS11, |
| 8380 | Certificates: []Certificate{ed25519Certificate}, |
| 8381 | Bugs: ProtocolBugs{ |
| 8382 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8383 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8384 | }, |
| 8385 | }, |
| 8386 | flags: []string{ |
| 8387 | "-enable-ed25519", |
| 8388 | "-require-any-client-certificate", |
| 8389 | }, |
| 8390 | shouldFail: true, |
| 8391 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8392 | }) |
| 8393 | testCases = append(testCases, testCase{ |
| 8394 | testType: clientTest, |
| 8395 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8396 | config: Config{ |
| 8397 | MaxVersion: VersionTLS11, |
| 8398 | ClientAuth: RequireAnyClientCert, |
| 8399 | }, |
| 8400 | flags: []string{ |
| 8401 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8402 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8403 | }, |
| 8404 | shouldFail: true, |
| 8405 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8406 | }) |
| 8407 | |
| 8408 | // Test Ed25519 is not advertised by default. |
| 8409 | testCases = append(testCases, testCase{ |
| 8410 | testType: clientTest, |
| 8411 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8412 | config: Config{ |
| 8413 | Certificates: []Certificate{ed25519Certificate}, |
| 8414 | }, |
| 8415 | shouldFail: true, |
| 8416 | expectedLocalError: "tls: no common signature algorithms", |
| 8417 | }) |
| 8418 | |
| 8419 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8420 | // preferences. |
| 8421 | testCases = append(testCases, testCase{ |
| 8422 | testType: clientTest, |
| 8423 | name: "Ed25519DefaultDisable-NoAccept", |
| 8424 | config: Config{ |
| 8425 | Certificates: []Certificate{ed25519Certificate}, |
| 8426 | Bugs: ProtocolBugs{ |
| 8427 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8428 | }, |
| 8429 | }, |
| 8430 | shouldFail: true, |
| 8431 | expectedLocalError: "remote error: illegal parameter", |
| 8432 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8433 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8434 | |
| 8435 | // Test that configuring verify preferences changes what the client |
| 8436 | // advertises. |
| 8437 | testCases = append(testCases, testCase{ |
| 8438 | name: "VerifyPreferences-Advertised", |
| 8439 | config: Config{ |
| 8440 | Certificates: []Certificate{rsaCertificate}, |
| 8441 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8442 | signatureRSAPSSWithSHA256, |
| 8443 | signatureRSAPSSWithSHA384, |
| 8444 | signatureRSAPSSWithSHA512, |
| 8445 | }, |
| 8446 | }, |
| 8447 | flags: []string{ |
| 8448 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8449 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8450 | }, |
| 8451 | }) |
| 8452 | |
| 8453 | // Test that the client advertises a set which the runner can find |
| 8454 | // nothing in common with. |
| 8455 | testCases = append(testCases, testCase{ |
| 8456 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8457 | config: Config{ |
| 8458 | Certificates: []Certificate{rsaCertificate}, |
| 8459 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8460 | signatureRSAPSSWithSHA256, |
| 8461 | signatureRSAPSSWithSHA512, |
| 8462 | }, |
| 8463 | }, |
| 8464 | flags: []string{ |
| 8465 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8466 | }, |
| 8467 | shouldFail: true, |
| 8468 | expectedLocalError: "tls: no common signature algorithms", |
| 8469 | }) |
| 8470 | |
| 8471 | // Test that the client enforces its preferences when configured. |
| 8472 | testCases = append(testCases, testCase{ |
| 8473 | name: "VerifyPreferences-Enforced", |
| 8474 | config: Config{ |
| 8475 | Certificates: []Certificate{rsaCertificate}, |
| 8476 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8477 | signatureRSAPSSWithSHA256, |
| 8478 | signatureRSAPSSWithSHA512, |
| 8479 | }, |
| 8480 | Bugs: ProtocolBugs{ |
| 8481 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8482 | }, |
| 8483 | }, |
| 8484 | flags: []string{ |
| 8485 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8486 | }, |
| 8487 | shouldFail: true, |
| 8488 | expectedLocalError: "remote error: illegal parameter", |
| 8489 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8490 | }) |
| 8491 | |
| 8492 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8493 | // boolean toggle. |
| 8494 | testCases = append(testCases, testCase{ |
| 8495 | name: "VerifyPreferences-Ed25519", |
| 8496 | config: Config{ |
| 8497 | Certificates: []Certificate{ed25519Certificate}, |
| 8498 | }, |
| 8499 | flags: []string{ |
| 8500 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8501 | }, |
| 8502 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8503 | } |
| 8504 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8505 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8506 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8507 | var timeouts = []time.Duration{ |
| 8508 | 1 * time.Second, |
| 8509 | 2 * time.Second, |
| 8510 | 4 * time.Second, |
| 8511 | 8 * time.Second, |
| 8512 | 16 * time.Second, |
| 8513 | 32 * time.Second, |
| 8514 | 60 * time.Second, |
| 8515 | 60 * time.Second, |
| 8516 | 60 * time.Second, |
| 8517 | 60 * time.Second, |
| 8518 | 60 * time.Second, |
| 8519 | 60 * time.Second, |
| 8520 | 60 * time.Second, |
| 8521 | } |
| 8522 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8523 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8524 | // initial timeout duration was set to 250ms. |
| 8525 | var shortTimeouts = []time.Duration{ |
| 8526 | 250 * time.Millisecond, |
| 8527 | 500 * time.Millisecond, |
| 8528 | 1 * time.Second, |
| 8529 | 2 * time.Second, |
| 8530 | 4 * time.Second, |
| 8531 | 8 * time.Second, |
| 8532 | 16 * time.Second, |
| 8533 | 32 * time.Second, |
| 8534 | 60 * time.Second, |
| 8535 | 60 * time.Second, |
| 8536 | 60 * time.Second, |
| 8537 | 60 * time.Second, |
| 8538 | 60 * time.Second, |
| 8539 | } |
| 8540 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8541 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8542 | // These tests work by coordinating some behavior on both the shim and |
| 8543 | // the runner. |
| 8544 | // |
| 8545 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8546 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8547 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8548 | // timeout in the shim and acts as a synchronization point to help the |
| 8549 | // runner bracket each handshake flight. |
| 8550 | // |
| 8551 | // We assume the shim does not read from the channel eagerly. It must |
| 8552 | // first wait until it has sent flight N and is ready to receive |
| 8553 | // handshake flight N+1. At this point, it will process the timeout |
| 8554 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8555 | // as if the shim was idle for the specified amount of time. |
| 8556 | // |
| 8557 | // The runner then drops all packets received before the ACK and |
| 8558 | // continues waiting for flight N. This ordering results in one attempt |
| 8559 | // at sending flight N to be dropped. For the test to complete, the |
| 8560 | // shim must send flight N again, testing that the shim implements DTLS |
| 8561 | // retransmit on a timeout. |
| 8562 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8563 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8564 | // likely be more epochs to cross and the final message's retransmit may |
| 8565 | // be more complex. |
| 8566 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8567 | // Test that this is indeed the timeout schedule. Stress all |
| 8568 | // four patterns of handshake. |
| 8569 | for i := 1; i < len(timeouts); i++ { |
| 8570 | number := strconv.Itoa(i) |
| 8571 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8572 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8573 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8574 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8575 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8576 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8577 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8578 | }, |
| 8579 | }, |
| 8580 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8581 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8582 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8583 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8584 | protocol: dtls, |
| 8585 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8586 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8587 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8588 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8589 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8590 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8591 | }, |
| 8592 | }, |
| 8593 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8594 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8595 | }) |
| 8596 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8597 | |
| 8598 | // Test that exceeding the timeout schedule hits a read |
| 8599 | // timeout. |
| 8600 | testCases = append(testCases, testCase{ |
| 8601 | protocol: dtls, |
| 8602 | name: "DTLS-Retransmit-Timeout", |
| 8603 | config: Config{ |
| 8604 | MaxVersion: VersionTLS12, |
| 8605 | Bugs: ProtocolBugs{ |
| 8606 | TimeoutSchedule: timeouts, |
| 8607 | }, |
| 8608 | }, |
| 8609 | resumeSession: true, |
| 8610 | flags: []string{"-async"}, |
| 8611 | shouldFail: true, |
| 8612 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8613 | }) |
| 8614 | |
| 8615 | // Test that timeout handling has a fudge factor, due to API |
| 8616 | // problems. |
| 8617 | testCases = append(testCases, testCase{ |
| 8618 | protocol: dtls, |
| 8619 | name: "DTLS-Retransmit-Fudge", |
| 8620 | config: Config{ |
| 8621 | MaxVersion: VersionTLS12, |
| 8622 | Bugs: ProtocolBugs{ |
| 8623 | TimeoutSchedule: []time.Duration{ |
| 8624 | timeouts[0] - 10*time.Millisecond, |
| 8625 | }, |
| 8626 | }, |
| 8627 | }, |
| 8628 | resumeSession: true, |
| 8629 | flags: []string{"-async"}, |
| 8630 | }) |
| 8631 | |
| 8632 | // Test that the final Finished retransmitting isn't |
| 8633 | // duplicated if the peer badly fragments everything. |
| 8634 | testCases = append(testCases, testCase{ |
| 8635 | testType: serverTest, |
| 8636 | protocol: dtls, |
| 8637 | name: "DTLS-Retransmit-Fragmented", |
| 8638 | config: Config{ |
| 8639 | MaxVersion: VersionTLS12, |
| 8640 | Bugs: ProtocolBugs{ |
| 8641 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8642 | MaxHandshakeRecordLength: 2, |
| 8643 | }, |
| 8644 | }, |
| 8645 | flags: []string{"-async"}, |
| 8646 | }) |
| 8647 | |
| 8648 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8649 | testCases = append(testCases, testCase{ |
| 8650 | protocol: dtls, |
| 8651 | name: "DTLS-Retransmit-Short-Client", |
| 8652 | config: Config{ |
| 8653 | MaxVersion: VersionTLS12, |
| 8654 | Bugs: ProtocolBugs{ |
| 8655 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8656 | }, |
| 8657 | }, |
| 8658 | resumeSession: true, |
| 8659 | flags: []string{ |
| 8660 | "-async", |
| 8661 | "-initial-timeout-duration-ms", "250", |
| 8662 | }, |
| 8663 | }) |
| 8664 | testCases = append(testCases, testCase{ |
| 8665 | protocol: dtls, |
| 8666 | testType: serverTest, |
| 8667 | name: "DTLS-Retransmit-Short-Server", |
| 8668 | config: Config{ |
| 8669 | MaxVersion: VersionTLS12, |
| 8670 | Bugs: ProtocolBugs{ |
| 8671 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8672 | }, |
| 8673 | }, |
| 8674 | resumeSession: true, |
| 8675 | flags: []string{ |
| 8676 | "-async", |
| 8677 | "-initial-timeout-duration-ms", "250", |
| 8678 | }, |
| 8679 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8680 | } |
| 8681 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8682 | func addExportKeyingMaterialTests() { |
| 8683 | for _, vers := range tlsVersions { |
| 8684 | if vers.version == VersionSSL30 { |
| 8685 | continue |
| 8686 | } |
| 8687 | testCases = append(testCases, testCase{ |
| 8688 | name: "ExportKeyingMaterial-" + vers.name, |
| 8689 | config: Config{ |
| 8690 | MaxVersion: vers.version, |
| 8691 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8692 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8693 | exportKeyingMaterial: 1024, |
| 8694 | exportLabel: "label", |
| 8695 | exportContext: "context", |
| 8696 | useExportContext: true, |
| 8697 | }) |
| 8698 | testCases = append(testCases, testCase{ |
| 8699 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8700 | config: Config{ |
| 8701 | MaxVersion: vers.version, |
| 8702 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8703 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8704 | exportKeyingMaterial: 1024, |
| 8705 | }) |
| 8706 | testCases = append(testCases, testCase{ |
| 8707 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8708 | config: Config{ |
| 8709 | MaxVersion: vers.version, |
| 8710 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8711 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8712 | exportKeyingMaterial: 1024, |
| 8713 | useExportContext: true, |
| 8714 | }) |
| 8715 | testCases = append(testCases, testCase{ |
| 8716 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8717 | config: Config{ |
| 8718 | MaxVersion: vers.version, |
| 8719 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8720 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8721 | exportKeyingMaterial: 1, |
| 8722 | exportLabel: "label", |
| 8723 | exportContext: "context", |
| 8724 | useExportContext: true, |
| 8725 | }) |
| 8726 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8727 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8728 | testCases = append(testCases, testCase{ |
| 8729 | name: "ExportKeyingMaterial-SSL3", |
| 8730 | config: Config{ |
| 8731 | MaxVersion: VersionSSL30, |
| 8732 | }, |
| 8733 | exportKeyingMaterial: 1024, |
| 8734 | exportLabel: "label", |
| 8735 | exportContext: "context", |
| 8736 | useExportContext: true, |
| 8737 | shouldFail: true, |
| 8738 | expectedError: "failed to export keying material", |
| 8739 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8740 | |
| 8741 | // Exporters work during a False Start. |
| 8742 | testCases = append(testCases, testCase{ |
| 8743 | name: "ExportKeyingMaterial-FalseStart", |
| 8744 | config: Config{ |
| 8745 | MaxVersion: VersionTLS12, |
| 8746 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8747 | NextProtos: []string{"foo"}, |
| 8748 | Bugs: ProtocolBugs{ |
| 8749 | ExpectFalseStart: true, |
| 8750 | }, |
| 8751 | }, |
| 8752 | flags: []string{ |
| 8753 | "-false-start", |
| 8754 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8755 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8756 | }, |
| 8757 | shimWritesFirst: true, |
| 8758 | exportKeyingMaterial: 1024, |
| 8759 | exportLabel: "label", |
| 8760 | exportContext: "context", |
| 8761 | useExportContext: true, |
| 8762 | }) |
| 8763 | |
| 8764 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8765 | // triggering the exporter after every SSL_read call and configuring the |
| 8766 | // shim to run asynchronously. |
| 8767 | testCases = append(testCases, testCase{ |
| 8768 | name: "ExportKeyingMaterial-Renegotiate", |
| 8769 | config: Config{ |
| 8770 | MaxVersion: VersionTLS12, |
| 8771 | }, |
| 8772 | renegotiate: 1, |
| 8773 | flags: []string{ |
| 8774 | "-async", |
| 8775 | "-use-exporter-between-reads", |
| 8776 | "-renegotiate-freely", |
| 8777 | "-expect-total-renegotiations", "1", |
| 8778 | }, |
| 8779 | shouldFail: true, |
| 8780 | expectedError: "failed to export keying material", |
| 8781 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8782 | } |
| 8783 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8784 | func addTLSUniqueTests() { |
| 8785 | for _, isClient := range []bool{false, true} { |
| 8786 | for _, isResumption := range []bool{false, true} { |
| 8787 | for _, hasEMS := range []bool{false, true} { |
| 8788 | var suffix string |
| 8789 | if isResumption { |
| 8790 | suffix = "Resume-" |
| 8791 | } else { |
| 8792 | suffix = "Full-" |
| 8793 | } |
| 8794 | |
| 8795 | if hasEMS { |
| 8796 | suffix += "EMS-" |
| 8797 | } else { |
| 8798 | suffix += "NoEMS-" |
| 8799 | } |
| 8800 | |
| 8801 | if isClient { |
| 8802 | suffix += "Client" |
| 8803 | } else { |
| 8804 | suffix += "Server" |
| 8805 | } |
| 8806 | |
| 8807 | test := testCase{ |
| 8808 | name: "TLSUnique-" + suffix, |
| 8809 | testTLSUnique: true, |
| 8810 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8811 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8812 | Bugs: ProtocolBugs{ |
| 8813 | NoExtendedMasterSecret: !hasEMS, |
| 8814 | }, |
| 8815 | }, |
| 8816 | } |
| 8817 | |
| 8818 | if isResumption { |
| 8819 | test.resumeSession = true |
| 8820 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8821 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8822 | Bugs: ProtocolBugs{ |
| 8823 | NoExtendedMasterSecret: !hasEMS, |
| 8824 | }, |
| 8825 | } |
| 8826 | } |
| 8827 | |
| 8828 | if isResumption && !hasEMS { |
| 8829 | test.shouldFail = true |
| 8830 | test.expectedError = "failed to get tls-unique" |
| 8831 | } |
| 8832 | |
| 8833 | testCases = append(testCases, test) |
| 8834 | } |
| 8835 | } |
| 8836 | } |
| 8837 | } |
| 8838 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8839 | func addCustomExtensionTests() { |
| 8840 | expectedContents := "custom extension" |
| 8841 | emptyString := "" |
| 8842 | |
| 8843 | for _, isClient := range []bool{false, true} { |
| 8844 | suffix := "Server" |
| 8845 | flag := "-enable-server-custom-extension" |
| 8846 | testType := serverTest |
| 8847 | if isClient { |
| 8848 | suffix = "Client" |
| 8849 | flag = "-enable-client-custom-extension" |
| 8850 | testType = clientTest |
| 8851 | } |
| 8852 | |
| 8853 | testCases = append(testCases, testCase{ |
| 8854 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8855 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8856 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8857 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8858 | Bugs: ProtocolBugs{ |
| 8859 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8860 | ExpectedCustomExtension: &expectedContents, |
| 8861 | }, |
| 8862 | }, |
| 8863 | flags: []string{flag}, |
| 8864 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8865 | testCases = append(testCases, testCase{ |
| 8866 | testType: testType, |
| 8867 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8868 | config: Config{ |
| 8869 | MaxVersion: VersionTLS13, |
| 8870 | Bugs: ProtocolBugs{ |
| 8871 | CustomExtension: expectedContents, |
| 8872 | ExpectedCustomExtension: &expectedContents, |
| 8873 | }, |
| 8874 | }, |
| 8875 | flags: []string{flag}, |
| 8876 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8877 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 8878 | // 0-RTT is not currently supported with Custom Extensions. |
| 8879 | testCases = append(testCases, testCase{ |
| 8880 | testType: testType, |
| 8881 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 8882 | config: Config{ |
| 8883 | MaxVersion: VersionTLS13, |
| 8884 | Bugs: ProtocolBugs{ |
| 8885 | CustomExtension: expectedContents, |
| 8886 | ExpectedCustomExtension: &expectedContents, |
| 8887 | }, |
| 8888 | }, |
| 8889 | shouldFail: true, |
| 8890 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8891 | flags: []string{flag, "-enable-early-data"}, |
| 8892 | }) |
| 8893 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8894 | // If the parse callback fails, the handshake should also fail. |
| 8895 | testCases = append(testCases, testCase{ |
| 8896 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8897 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8898 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8899 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8900 | Bugs: ProtocolBugs{ |
| 8901 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8902 | ExpectedCustomExtension: &expectedContents, |
| 8903 | }, |
| 8904 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8905 | flags: []string{flag}, |
| 8906 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8907 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8908 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8909 | testCases = append(testCases, testCase{ |
| 8910 | testType: testType, |
| 8911 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 8912 | config: Config{ |
| 8913 | MaxVersion: VersionTLS13, |
| 8914 | Bugs: ProtocolBugs{ |
| 8915 | CustomExtension: expectedContents + "foo", |
| 8916 | ExpectedCustomExtension: &expectedContents, |
| 8917 | }, |
| 8918 | }, |
| 8919 | flags: []string{flag}, |
| 8920 | shouldFail: true, |
| 8921 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8922 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8923 | |
| 8924 | // If the add callback fails, the handshake should also fail. |
| 8925 | testCases = append(testCases, testCase{ |
| 8926 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8927 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8928 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8929 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8930 | Bugs: ProtocolBugs{ |
| 8931 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8932 | ExpectedCustomExtension: &expectedContents, |
| 8933 | }, |
| 8934 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8935 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8936 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8937 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8938 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8939 | testCases = append(testCases, testCase{ |
| 8940 | testType: testType, |
| 8941 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 8942 | config: Config{ |
| 8943 | MaxVersion: VersionTLS13, |
| 8944 | Bugs: ProtocolBugs{ |
| 8945 | CustomExtension: expectedContents, |
| 8946 | ExpectedCustomExtension: &expectedContents, |
| 8947 | }, |
| 8948 | }, |
| 8949 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8950 | shouldFail: true, |
| 8951 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8952 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8953 | |
| 8954 | // If the add callback returns zero, no extension should be |
| 8955 | // added. |
| 8956 | skipCustomExtension := expectedContents |
| 8957 | if isClient { |
| 8958 | // For the case where the client skips sending the |
| 8959 | // custom extension, the server must not “echo” it. |
| 8960 | skipCustomExtension = "" |
| 8961 | } |
| 8962 | testCases = append(testCases, testCase{ |
| 8963 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8964 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8965 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8966 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8967 | Bugs: ProtocolBugs{ |
| 8968 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8969 | ExpectedCustomExtension: &emptyString, |
| 8970 | }, |
| 8971 | }, |
| 8972 | flags: []string{flag, "-custom-extension-skip"}, |
| 8973 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8974 | testCases = append(testCases, testCase{ |
| 8975 | testType: testType, |
| 8976 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 8977 | config: Config{ |
| 8978 | MaxVersion: VersionTLS13, |
| 8979 | Bugs: ProtocolBugs{ |
| 8980 | CustomExtension: skipCustomExtension, |
| 8981 | ExpectedCustomExtension: &emptyString, |
| 8982 | }, |
| 8983 | }, |
| 8984 | flags: []string{flag, "-custom-extension-skip"}, |
| 8985 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8986 | } |
| 8987 | |
| 8988 | // The custom extension add callback should not be called if the client |
| 8989 | // doesn't send the extension. |
| 8990 | testCases = append(testCases, testCase{ |
| 8991 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8992 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8993 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8994 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8995 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8996 | ExpectedCustomExtension: &emptyString, |
| 8997 | }, |
| 8998 | }, |
| 8999 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9000 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9001 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9002 | testCases = append(testCases, testCase{ |
| 9003 | testType: serverTest, |
| 9004 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9005 | config: Config{ |
| 9006 | MaxVersion: VersionTLS13, |
| 9007 | Bugs: ProtocolBugs{ |
| 9008 | ExpectedCustomExtension: &emptyString, |
| 9009 | }, |
| 9010 | }, |
| 9011 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9012 | }) |
| 9013 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9014 | // Test an unknown extension from the server. |
| 9015 | testCases = append(testCases, testCase{ |
| 9016 | testType: clientTest, |
| 9017 | name: "UnknownExtension-Client", |
| 9018 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9019 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9020 | Bugs: ProtocolBugs{ |
| 9021 | CustomExtension: expectedContents, |
| 9022 | }, |
| 9023 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9024 | shouldFail: true, |
| 9025 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9026 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9027 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9028 | testCases = append(testCases, testCase{ |
| 9029 | testType: clientTest, |
| 9030 | name: "UnknownExtension-Client-TLS13", |
| 9031 | config: Config{ |
| 9032 | MaxVersion: VersionTLS13, |
| 9033 | Bugs: ProtocolBugs{ |
| 9034 | CustomExtension: expectedContents, |
| 9035 | }, |
| 9036 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9037 | shouldFail: true, |
| 9038 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9039 | expectedLocalError: "remote error: unsupported extension", |
| 9040 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9041 | testCases = append(testCases, testCase{ |
| 9042 | testType: clientTest, |
| 9043 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9044 | config: Config{ |
| 9045 | MaxVersion: VersionTLS13, |
| 9046 | Bugs: ProtocolBugs{ |
| 9047 | CustomUnencryptedExtension: expectedContents, |
| 9048 | }, |
| 9049 | }, |
| 9050 | shouldFail: true, |
| 9051 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9052 | // The shim must send an alert, but alerts at this point do not |
| 9053 | // get successfully decrypted by the runner. |
| 9054 | expectedLocalError: "local error: bad record MAC", |
| 9055 | }) |
| 9056 | testCases = append(testCases, testCase{ |
| 9057 | testType: clientTest, |
| 9058 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9059 | config: Config{ |
| 9060 | MaxVersion: VersionTLS13, |
| 9061 | Bugs: ProtocolBugs{ |
| 9062 | SendUnencryptedALPN: "foo", |
| 9063 | }, |
| 9064 | }, |
| 9065 | flags: []string{ |
| 9066 | "-advertise-alpn", "\x03foo\x03bar", |
| 9067 | }, |
| 9068 | shouldFail: true, |
| 9069 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9070 | // The shim must send an alert, but alerts at this point do not |
| 9071 | // get successfully decrypted by the runner. |
| 9072 | expectedLocalError: "local error: bad record MAC", |
| 9073 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9074 | |
| 9075 | // Test a known but unoffered extension from the server. |
| 9076 | testCases = append(testCases, testCase{ |
| 9077 | testType: clientTest, |
| 9078 | name: "UnofferedExtension-Client", |
| 9079 | config: Config{ |
| 9080 | MaxVersion: VersionTLS12, |
| 9081 | Bugs: ProtocolBugs{ |
| 9082 | SendALPN: "alpn", |
| 9083 | }, |
| 9084 | }, |
| 9085 | shouldFail: true, |
| 9086 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9087 | expectedLocalError: "remote error: unsupported extension", |
| 9088 | }) |
| 9089 | testCases = append(testCases, testCase{ |
| 9090 | testType: clientTest, |
| 9091 | name: "UnofferedExtension-Client-TLS13", |
| 9092 | config: Config{ |
| 9093 | MaxVersion: VersionTLS13, |
| 9094 | Bugs: ProtocolBugs{ |
| 9095 | SendALPN: "alpn", |
| 9096 | }, |
| 9097 | }, |
| 9098 | shouldFail: true, |
| 9099 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9100 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9101 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9102 | } |
| 9103 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9104 | func addRSAClientKeyExchangeTests() { |
| 9105 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9106 | testCases = append(testCases, testCase{ |
| 9107 | testType: serverTest, |
| 9108 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9109 | config: Config{ |
| 9110 | // Ensure the ClientHello version and final |
| 9111 | // version are different, to detect if the |
| 9112 | // server uses the wrong one. |
| 9113 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9114 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9115 | Bugs: ProtocolBugs{ |
| 9116 | BadRSAClientKeyExchange: bad, |
| 9117 | }, |
| 9118 | }, |
| 9119 | shouldFail: true, |
| 9120 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9121 | }) |
| 9122 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9123 | |
| 9124 | // The server must compare whatever was in ClientHello.version for the |
| 9125 | // RSA premaster. |
| 9126 | testCases = append(testCases, testCase{ |
| 9127 | testType: serverTest, |
| 9128 | name: "SendClientVersion-RSA", |
| 9129 | config: Config{ |
| 9130 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9131 | Bugs: ProtocolBugs{ |
| 9132 | SendClientVersion: 0x1234, |
| 9133 | }, |
| 9134 | }, |
| 9135 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9136 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9137 | } |
| 9138 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9139 | var testCurves = []struct { |
| 9140 | name string |
| 9141 | id CurveID |
| 9142 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9143 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9144 | {"P-256", CurveP256}, |
| 9145 | {"P-384", CurveP384}, |
| 9146 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9147 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9148 | } |
| 9149 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9150 | const bogusCurve = 0x1234 |
| 9151 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9152 | func addCurveTests() { |
| 9153 | for _, curve := range testCurves { |
| 9154 | testCases = append(testCases, testCase{ |
| 9155 | name: "CurveTest-Client-" + curve.name, |
| 9156 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9157 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9158 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9159 | CurvePreferences: []CurveID{curve.id}, |
| 9160 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9161 | flags: []string{ |
| 9162 | "-enable-all-curves", |
| 9163 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9164 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9165 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9166 | }) |
| 9167 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9168 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9169 | config: Config{ |
| 9170 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9171 | CurvePreferences: []CurveID{curve.id}, |
| 9172 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9173 | flags: []string{ |
| 9174 | "-enable-all-curves", |
| 9175 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9176 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9177 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9178 | }) |
| 9179 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9180 | testType: serverTest, |
| 9181 | name: "CurveTest-Server-" + curve.name, |
| 9182 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9183 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9184 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9185 | CurvePreferences: []CurveID{curve.id}, |
| 9186 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9187 | flags: []string{ |
| 9188 | "-enable-all-curves", |
| 9189 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9190 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9191 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9192 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9193 | testCases = append(testCases, testCase{ |
| 9194 | testType: serverTest, |
| 9195 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9196 | config: Config{ |
| 9197 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9198 | CurvePreferences: []CurveID{curve.id}, |
| 9199 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9200 | flags: []string{ |
| 9201 | "-enable-all-curves", |
| 9202 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9203 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9204 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9205 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9206 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9207 | |
| 9208 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9209 | testCases = append(testCases, testCase{ |
| 9210 | testType: serverTest, |
| 9211 | name: "UnknownCurve", |
| 9212 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9213 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9214 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9215 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9216 | }, |
| 9217 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9218 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9219 | // The server must be tolerant to bogus curves. |
| 9220 | testCases = append(testCases, testCase{ |
| 9221 | testType: serverTest, |
| 9222 | name: "UnknownCurve-TLS13", |
| 9223 | config: Config{ |
| 9224 | MaxVersion: VersionTLS13, |
| 9225 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9226 | }, |
| 9227 | }) |
| 9228 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9229 | // The server must not consider ECDHE ciphers when there are no |
| 9230 | // supported curves. |
| 9231 | testCases = append(testCases, testCase{ |
| 9232 | testType: serverTest, |
| 9233 | name: "NoSupportedCurves", |
| 9234 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9235 | MaxVersion: VersionTLS12, |
| 9236 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9237 | Bugs: ProtocolBugs{ |
| 9238 | NoSupportedCurves: true, |
| 9239 | }, |
| 9240 | }, |
| 9241 | shouldFail: true, |
| 9242 | expectedError: ":NO_SHARED_CIPHER:", |
| 9243 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9244 | testCases = append(testCases, testCase{ |
| 9245 | testType: serverTest, |
| 9246 | name: "NoSupportedCurves-TLS13", |
| 9247 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9248 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9249 | Bugs: ProtocolBugs{ |
| 9250 | NoSupportedCurves: true, |
| 9251 | }, |
| 9252 | }, |
| 9253 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9254 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9255 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9256 | |
| 9257 | // The server must fall back to another cipher when there are no |
| 9258 | // supported curves. |
| 9259 | testCases = append(testCases, testCase{ |
| 9260 | testType: serverTest, |
| 9261 | name: "NoCommonCurves", |
| 9262 | config: Config{ |
| 9263 | MaxVersion: VersionTLS12, |
| 9264 | CipherSuites: []uint16{ |
| 9265 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9266 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9267 | }, |
| 9268 | CurvePreferences: []CurveID{CurveP224}, |
| 9269 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9270 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9271 | }) |
| 9272 | |
| 9273 | // The client must reject bogus curves and disabled curves. |
| 9274 | testCases = append(testCases, testCase{ |
| 9275 | name: "BadECDHECurve", |
| 9276 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9277 | MaxVersion: VersionTLS12, |
| 9278 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9279 | Bugs: ProtocolBugs{ |
| 9280 | SendCurve: bogusCurve, |
| 9281 | }, |
| 9282 | }, |
| 9283 | shouldFail: true, |
| 9284 | expectedError: ":WRONG_CURVE:", |
| 9285 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9286 | testCases = append(testCases, testCase{ |
| 9287 | name: "BadECDHECurve-TLS13", |
| 9288 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9289 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9290 | Bugs: ProtocolBugs{ |
| 9291 | SendCurve: bogusCurve, |
| 9292 | }, |
| 9293 | }, |
| 9294 | shouldFail: true, |
| 9295 | expectedError: ":WRONG_CURVE:", |
| 9296 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9297 | |
| 9298 | testCases = append(testCases, testCase{ |
| 9299 | name: "UnsupportedCurve", |
| 9300 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9301 | MaxVersion: VersionTLS12, |
| 9302 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9303 | CurvePreferences: []CurveID{CurveP256}, |
| 9304 | Bugs: ProtocolBugs{ |
| 9305 | IgnorePeerCurvePreferences: true, |
| 9306 | }, |
| 9307 | }, |
| 9308 | flags: []string{"-p384-only"}, |
| 9309 | shouldFail: true, |
| 9310 | expectedError: ":WRONG_CURVE:", |
| 9311 | }) |
| 9312 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9313 | testCases = append(testCases, testCase{ |
| 9314 | // TODO(davidben): Add a TLS 1.3 version where |
| 9315 | // HelloRetryRequest requests an unsupported curve. |
| 9316 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9317 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9318 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9319 | CurvePreferences: []CurveID{CurveP384}, |
| 9320 | Bugs: ProtocolBugs{ |
| 9321 | SendCurve: CurveP256, |
| 9322 | }, |
| 9323 | }, |
| 9324 | flags: []string{"-p384-only"}, |
| 9325 | shouldFail: true, |
| 9326 | expectedError: ":WRONG_CURVE:", |
| 9327 | }) |
| 9328 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9329 | // Test invalid curve points. |
| 9330 | testCases = append(testCases, testCase{ |
| 9331 | name: "InvalidECDHPoint-Client", |
| 9332 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9333 | MaxVersion: VersionTLS12, |
| 9334 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9335 | CurvePreferences: []CurveID{CurveP256}, |
| 9336 | Bugs: ProtocolBugs{ |
| 9337 | InvalidECDHPoint: true, |
| 9338 | }, |
| 9339 | }, |
| 9340 | shouldFail: true, |
| 9341 | expectedError: ":INVALID_ENCODING:", |
| 9342 | }) |
| 9343 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9344 | name: "InvalidECDHPoint-Client-TLS13", |
| 9345 | config: Config{ |
| 9346 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9347 | CurvePreferences: []CurveID{CurveP256}, |
| 9348 | Bugs: ProtocolBugs{ |
| 9349 | InvalidECDHPoint: true, |
| 9350 | }, |
| 9351 | }, |
| 9352 | shouldFail: true, |
| 9353 | expectedError: ":INVALID_ENCODING:", |
| 9354 | }) |
| 9355 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9356 | testType: serverTest, |
| 9357 | name: "InvalidECDHPoint-Server", |
| 9358 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9359 | MaxVersion: VersionTLS12, |
| 9360 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9361 | CurvePreferences: []CurveID{CurveP256}, |
| 9362 | Bugs: ProtocolBugs{ |
| 9363 | InvalidECDHPoint: true, |
| 9364 | }, |
| 9365 | }, |
| 9366 | shouldFail: true, |
| 9367 | expectedError: ":INVALID_ENCODING:", |
| 9368 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9369 | testCases = append(testCases, testCase{ |
| 9370 | testType: serverTest, |
| 9371 | name: "InvalidECDHPoint-Server-TLS13", |
| 9372 | config: Config{ |
| 9373 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9374 | CurvePreferences: []CurveID{CurveP256}, |
| 9375 | Bugs: ProtocolBugs{ |
| 9376 | InvalidECDHPoint: true, |
| 9377 | }, |
| 9378 | }, |
| 9379 | shouldFail: true, |
| 9380 | expectedError: ":INVALID_ENCODING:", |
| 9381 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9382 | |
| 9383 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9384 | testCases = append(testCases, testCase{ |
| 9385 | name: "CurveID-Resume-Client", |
| 9386 | config: Config{ |
| 9387 | MaxVersion: VersionTLS12, |
| 9388 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9389 | CurvePreferences: []CurveID{CurveX25519}, |
| 9390 | }, |
| 9391 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9392 | resumeSession: true, |
| 9393 | }) |
| 9394 | testCases = append(testCases, testCase{ |
| 9395 | testType: serverTest, |
| 9396 | name: "CurveID-Resume-Server", |
| 9397 | config: Config{ |
| 9398 | MaxVersion: VersionTLS12, |
| 9399 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9400 | CurvePreferences: []CurveID{CurveX25519}, |
| 9401 | }, |
| 9402 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9403 | resumeSession: true, |
| 9404 | }) |
| 9405 | |
| 9406 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9407 | // one should be reported. |
| 9408 | testCases = append(testCases, testCase{ |
| 9409 | name: "CurveID-Resume-Client-TLS13", |
| 9410 | config: Config{ |
| 9411 | MaxVersion: VersionTLS13, |
| 9412 | CurvePreferences: []CurveID{CurveX25519}, |
| 9413 | }, |
| 9414 | resumeConfig: &Config{ |
| 9415 | MaxVersion: VersionTLS13, |
| 9416 | CurvePreferences: []CurveID{CurveP256}, |
| 9417 | }, |
| 9418 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9419 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9420 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9421 | }, |
| 9422 | resumeSession: true, |
| 9423 | }) |
| 9424 | testCases = append(testCases, testCase{ |
| 9425 | testType: serverTest, |
| 9426 | name: "CurveID-Resume-Server-TLS13", |
| 9427 | config: Config{ |
| 9428 | MaxVersion: VersionTLS13, |
| 9429 | CurvePreferences: []CurveID{CurveX25519}, |
| 9430 | }, |
| 9431 | resumeConfig: &Config{ |
| 9432 | MaxVersion: VersionTLS13, |
| 9433 | CurvePreferences: []CurveID{CurveP256}, |
| 9434 | }, |
| 9435 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9436 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9437 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9438 | }, |
| 9439 | resumeSession: true, |
| 9440 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9441 | |
| 9442 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9443 | testCases = append(testCases, testCase{ |
| 9444 | name: "PointFormat-ServerHello-TLS12", |
| 9445 | config: Config{ |
| 9446 | MaxVersion: VersionTLS12, |
| 9447 | Bugs: ProtocolBugs{ |
| 9448 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9449 | }, |
| 9450 | }, |
| 9451 | }) |
| 9452 | testCases = append(testCases, testCase{ |
| 9453 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9454 | config: Config{ |
| 9455 | MaxVersion: VersionTLS13, |
| 9456 | Bugs: ProtocolBugs{ |
| 9457 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9458 | }, |
| 9459 | }, |
| 9460 | shouldFail: true, |
| 9461 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9462 | }) |
| 9463 | |
| 9464 | // Test that we tolerate unknown point formats, as long as |
| 9465 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9466 | // check they are still functional. |
| 9467 | testCases = append(testCases, testCase{ |
| 9468 | name: "PointFormat-Client-Tolerance", |
| 9469 | config: Config{ |
| 9470 | MaxVersion: VersionTLS12, |
| 9471 | Bugs: ProtocolBugs{ |
| 9472 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9473 | }, |
| 9474 | }, |
| 9475 | }) |
| 9476 | testCases = append(testCases, testCase{ |
| 9477 | testType: serverTest, |
| 9478 | name: "PointFormat-Server-Tolerance", |
| 9479 | config: Config{ |
| 9480 | MaxVersion: VersionTLS12, |
| 9481 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9482 | Bugs: ProtocolBugs{ |
| 9483 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9484 | }, |
| 9485 | }, |
| 9486 | }) |
| 9487 | |
| 9488 | // Test TLS 1.2 does not require the point format extension to be |
| 9489 | // present. |
| 9490 | testCases = append(testCases, testCase{ |
| 9491 | name: "PointFormat-Client-Missing", |
| 9492 | config: Config{ |
| 9493 | MaxVersion: VersionTLS12, |
| 9494 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9495 | Bugs: ProtocolBugs{ |
| 9496 | SendSupportedPointFormats: []byte{}, |
| 9497 | }, |
| 9498 | }, |
| 9499 | }) |
| 9500 | testCases = append(testCases, testCase{ |
| 9501 | testType: serverTest, |
| 9502 | name: "PointFormat-Server-Missing", |
| 9503 | config: Config{ |
| 9504 | MaxVersion: VersionTLS12, |
| 9505 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9506 | Bugs: ProtocolBugs{ |
| 9507 | SendSupportedPointFormats: []byte{}, |
| 9508 | }, |
| 9509 | }, |
| 9510 | }) |
| 9511 | |
| 9512 | // If the point format extension is present, uncompressed points must be |
| 9513 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9514 | testCases = append(testCases, testCase{ |
| 9515 | name: "PointFormat-Client-MissingUncompressed", |
| 9516 | config: Config{ |
| 9517 | MaxVersion: VersionTLS12, |
| 9518 | Bugs: ProtocolBugs{ |
| 9519 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9520 | }, |
| 9521 | }, |
| 9522 | shouldFail: true, |
| 9523 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9524 | }) |
| 9525 | testCases = append(testCases, testCase{ |
| 9526 | testType: serverTest, |
| 9527 | name: "PointFormat-Server-MissingUncompressed", |
| 9528 | config: Config{ |
| 9529 | MaxVersion: VersionTLS12, |
| 9530 | Bugs: ProtocolBugs{ |
| 9531 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9532 | }, |
| 9533 | }, |
| 9534 | shouldFail: true, |
| 9535 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9536 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9537 | } |
| 9538 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9539 | func addTLS13RecordTests() { |
| 9540 | testCases = append(testCases, testCase{ |
| 9541 | name: "TLS13-RecordPadding", |
| 9542 | config: Config{ |
| 9543 | MaxVersion: VersionTLS13, |
| 9544 | MinVersion: VersionTLS13, |
| 9545 | Bugs: ProtocolBugs{ |
| 9546 | RecordPadding: 10, |
| 9547 | }, |
| 9548 | }, |
| 9549 | }) |
| 9550 | |
| 9551 | testCases = append(testCases, testCase{ |
| 9552 | name: "TLS13-EmptyRecords", |
| 9553 | config: Config{ |
| 9554 | MaxVersion: VersionTLS13, |
| 9555 | MinVersion: VersionTLS13, |
| 9556 | Bugs: ProtocolBugs{ |
| 9557 | OmitRecordContents: true, |
| 9558 | }, |
| 9559 | }, |
| 9560 | shouldFail: true, |
| 9561 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9562 | }) |
| 9563 | |
| 9564 | testCases = append(testCases, testCase{ |
| 9565 | name: "TLS13-OnlyPadding", |
| 9566 | config: Config{ |
| 9567 | MaxVersion: VersionTLS13, |
| 9568 | MinVersion: VersionTLS13, |
| 9569 | Bugs: ProtocolBugs{ |
| 9570 | OmitRecordContents: true, |
| 9571 | RecordPadding: 10, |
| 9572 | }, |
| 9573 | }, |
| 9574 | shouldFail: true, |
| 9575 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9576 | }) |
| 9577 | |
| 9578 | testCases = append(testCases, testCase{ |
| 9579 | name: "TLS13-WrongOuterRecord", |
| 9580 | config: Config{ |
| 9581 | MaxVersion: VersionTLS13, |
| 9582 | MinVersion: VersionTLS13, |
| 9583 | Bugs: ProtocolBugs{ |
| 9584 | OuterRecordType: recordTypeHandshake, |
| 9585 | }, |
| 9586 | }, |
| 9587 | shouldFail: true, |
| 9588 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9589 | }) |
| 9590 | } |
| 9591 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9592 | func addSessionTicketTests() { |
| 9593 | testCases = append(testCases, testCase{ |
| 9594 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9595 | // mean the server changed its mind on sending a ticket. |
| 9596 | name: "SendEmptySessionTicket", |
| 9597 | config: Config{ |
| 9598 | MaxVersion: VersionTLS12, |
| 9599 | Bugs: ProtocolBugs{ |
| 9600 | SendEmptySessionTicket: true, |
| 9601 | }, |
| 9602 | }, |
| 9603 | flags: []string{"-expect-no-session"}, |
| 9604 | }) |
| 9605 | |
| 9606 | // Test that the server ignores unknown PSK modes. |
| 9607 | testCases = append(testCases, testCase{ |
| 9608 | testType: serverTest, |
| 9609 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9610 | config: Config{ |
| 9611 | MaxVersion: VersionTLS13, |
| 9612 | Bugs: ProtocolBugs{ |
| 9613 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9614 | }, |
| 9615 | }, |
| 9616 | resumeSession: true, |
| 9617 | expectedResumeVersion: VersionTLS13, |
| 9618 | }) |
| 9619 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9620 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9621 | testCases = append(testCases, testCase{ |
| 9622 | testType: serverTest, |
| 9623 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9624 | config: Config{ |
| 9625 | MaxVersion: VersionTLS13, |
| 9626 | Bugs: ProtocolBugs{ |
| 9627 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9628 | ExpectNoNewSessionTicket: true, |
| 9629 | }, |
| 9630 | }, |
| 9631 | }) |
| 9632 | |
| 9633 | // 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] | 9634 | testCases = append(testCases, testCase{ |
| 9635 | testType: serverTest, |
| 9636 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9637 | config: Config{ |
| 9638 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9639 | }, |
| 9640 | resumeConfig: &Config{ |
| 9641 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9642 | Bugs: ProtocolBugs{ |
| 9643 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9644 | }, |
| 9645 | }, |
| 9646 | resumeSession: true, |
| 9647 | expectResumeRejected: true, |
| 9648 | }) |
| 9649 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9650 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9651 | testCases = append(testCases, testCase{ |
| 9652 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9653 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9654 | config: Config{ |
| 9655 | MaxVersion: VersionTLS13, |
| 9656 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9657 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9658 | }, |
| 9659 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9660 | resumeSession: true, |
| 9661 | flags: []string{ |
| 9662 | "-resumption-delay", "10", |
| 9663 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9664 | }) |
| 9665 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9666 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9667 | testCases = append(testCases, testCase{ |
| 9668 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9669 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9670 | config: Config{ |
| 9671 | MaxVersion: VersionTLS13, |
| 9672 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9673 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9674 | }, |
| 9675 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9676 | resumeSession: true, |
| 9677 | shouldFail: true, |
| 9678 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9679 | }) |
| 9680 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9681 | // Test that the server's ticket age skew reporting works. |
| 9682 | testCases = append(testCases, testCase{ |
| 9683 | testType: serverTest, |
| 9684 | name: "TLS13-TicketAgeSkew-Forward", |
| 9685 | config: Config{ |
| 9686 | MaxVersion: VersionTLS13, |
| 9687 | Bugs: ProtocolBugs{ |
| 9688 | SendTicketAge: 15 * time.Second, |
| 9689 | }, |
| 9690 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9691 | resumeSession: true, |
| 9692 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9693 | flags: []string{ |
| 9694 | "-resumption-delay", "10", |
| 9695 | "-expect-ticket-age-skew", "5", |
| 9696 | }, |
| 9697 | }) |
| 9698 | testCases = append(testCases, testCase{ |
| 9699 | testType: serverTest, |
| 9700 | name: "TLS13-TicketAgeSkew-Backward", |
| 9701 | config: Config{ |
| 9702 | MaxVersion: VersionTLS13, |
| 9703 | Bugs: ProtocolBugs{ |
| 9704 | SendTicketAge: 5 * time.Second, |
| 9705 | }, |
| 9706 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9707 | resumeSession: true, |
| 9708 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9709 | flags: []string{ |
| 9710 | "-resumption-delay", "10", |
| 9711 | "-expect-ticket-age-skew", "-5", |
| 9712 | }, |
| 9713 | }) |
| 9714 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9715 | testCases = append(testCases, testCase{ |
| 9716 | testType: clientTest, |
| 9717 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9718 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9719 | MaxVersion: VersionTLS13, |
| 9720 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9721 | }, |
| 9722 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9723 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9724 | "-expect-early-data-info", |
| 9725 | }, |
| 9726 | }) |
| 9727 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9728 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9729 | testCases = append(testCases, testCase{ |
| 9730 | testType: clientTest, |
| 9731 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9732 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9733 | MaxVersion: VersionTLS13, |
| 9734 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9735 | }, |
| 9736 | }) |
| 9737 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9738 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9739 | testType: clientTest, |
| 9740 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9741 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9742 | MaxVersion: VersionTLS13, |
| 9743 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9744 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9745 | DuplicateTicketEarlyDataInfo: true, |
| 9746 | }, |
| 9747 | }, |
| 9748 | shouldFail: true, |
| 9749 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9750 | expectedLocalError: "remote error: illegal parameter", |
| 9751 | }) |
| 9752 | |
| 9753 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9754 | testType: serverTest, |
| 9755 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9756 | config: Config{ |
| 9757 | MaxVersion: VersionTLS13, |
| 9758 | Bugs: ProtocolBugs{ |
| 9759 | ExpectTicketEarlyDataInfo: true, |
| 9760 | }, |
| 9761 | }, |
| 9762 | flags: []string{ |
| 9763 | "-enable-early-data", |
| 9764 | }, |
| 9765 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9766 | |
| 9767 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9768 | // is honored. |
| 9769 | testCases = append(testCases, testCase{ |
| 9770 | testType: clientTest, |
| 9771 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9772 | config: Config{ |
| 9773 | MaxVersion: VersionTLS13, |
| 9774 | Bugs: ProtocolBugs{ |
| 9775 | SendTicketLifetime: 20 * time.Second, |
| 9776 | }, |
| 9777 | }, |
| 9778 | flags: []string{ |
| 9779 | "-resumption-delay", "19", |
| 9780 | }, |
| 9781 | resumeSession: true, |
| 9782 | }) |
| 9783 | testCases = append(testCases, testCase{ |
| 9784 | testType: clientTest, |
| 9785 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9786 | config: Config{ |
| 9787 | MaxVersion: VersionTLS13, |
| 9788 | Bugs: ProtocolBugs{ |
| 9789 | SendTicketLifetime: 20 * time.Second, |
| 9790 | // The client should not offer the expired session. |
| 9791 | ExpectNoTLS13PSK: true, |
| 9792 | }, |
| 9793 | }, |
| 9794 | flags: []string{ |
| 9795 | "-resumption-delay", "21", |
| 9796 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9797 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9798 | expectResumeRejected: true, |
| 9799 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9800 | } |
| 9801 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9802 | func addChangeCipherSpecTests() { |
| 9803 | // Test missing ChangeCipherSpecs. |
| 9804 | testCases = append(testCases, testCase{ |
| 9805 | name: "SkipChangeCipherSpec-Client", |
| 9806 | config: Config{ |
| 9807 | MaxVersion: VersionTLS12, |
| 9808 | Bugs: ProtocolBugs{ |
| 9809 | SkipChangeCipherSpec: true, |
| 9810 | }, |
| 9811 | }, |
| 9812 | shouldFail: true, |
| 9813 | expectedError: ":UNEXPECTED_RECORD:", |
| 9814 | }) |
| 9815 | testCases = append(testCases, testCase{ |
| 9816 | testType: serverTest, |
| 9817 | name: "SkipChangeCipherSpec-Server", |
| 9818 | config: Config{ |
| 9819 | MaxVersion: VersionTLS12, |
| 9820 | Bugs: ProtocolBugs{ |
| 9821 | SkipChangeCipherSpec: true, |
| 9822 | }, |
| 9823 | }, |
| 9824 | shouldFail: true, |
| 9825 | expectedError: ":UNEXPECTED_RECORD:", |
| 9826 | }) |
| 9827 | testCases = append(testCases, testCase{ |
| 9828 | testType: serverTest, |
| 9829 | name: "SkipChangeCipherSpec-Server-NPN", |
| 9830 | config: Config{ |
| 9831 | MaxVersion: VersionTLS12, |
| 9832 | NextProtos: []string{"bar"}, |
| 9833 | Bugs: ProtocolBugs{ |
| 9834 | SkipChangeCipherSpec: true, |
| 9835 | }, |
| 9836 | }, |
| 9837 | flags: []string{ |
| 9838 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9839 | }, |
| 9840 | shouldFail: true, |
| 9841 | expectedError: ":UNEXPECTED_RECORD:", |
| 9842 | }) |
| 9843 | |
| 9844 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 9845 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 9846 | // rejected. Test both with and without handshake packing to handle both |
| 9847 | // when the partial post-CCS message is in its own record and when it is |
| 9848 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9849 | for _, packed := range []bool{false, true} { |
| 9850 | var suffix string |
| 9851 | if packed { |
| 9852 | suffix = "-Packed" |
| 9853 | } |
| 9854 | |
| 9855 | testCases = append(testCases, testCase{ |
| 9856 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 9857 | config: Config{ |
| 9858 | MaxVersion: VersionTLS12, |
| 9859 | Bugs: ProtocolBugs{ |
| 9860 | FragmentAcrossChangeCipherSpec: true, |
| 9861 | PackHandshakeFlight: packed, |
| 9862 | }, |
| 9863 | }, |
| 9864 | shouldFail: true, |
| 9865 | expectedError: ":UNEXPECTED_RECORD:", |
| 9866 | }) |
| 9867 | testCases = append(testCases, testCase{ |
| 9868 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 9869 | config: Config{ |
| 9870 | MaxVersion: VersionTLS12, |
| 9871 | }, |
| 9872 | resumeSession: true, |
| 9873 | resumeConfig: &Config{ |
| 9874 | MaxVersion: VersionTLS12, |
| 9875 | Bugs: ProtocolBugs{ |
| 9876 | FragmentAcrossChangeCipherSpec: true, |
| 9877 | PackHandshakeFlight: packed, |
| 9878 | }, |
| 9879 | }, |
| 9880 | shouldFail: true, |
| 9881 | expectedError: ":UNEXPECTED_RECORD:", |
| 9882 | }) |
| 9883 | testCases = append(testCases, testCase{ |
| 9884 | testType: serverTest, |
| 9885 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 9886 | config: Config{ |
| 9887 | MaxVersion: VersionTLS12, |
| 9888 | Bugs: ProtocolBugs{ |
| 9889 | FragmentAcrossChangeCipherSpec: true, |
| 9890 | PackHandshakeFlight: packed, |
| 9891 | }, |
| 9892 | }, |
| 9893 | shouldFail: true, |
| 9894 | expectedError: ":UNEXPECTED_RECORD:", |
| 9895 | }) |
| 9896 | testCases = append(testCases, testCase{ |
| 9897 | testType: serverTest, |
| 9898 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 9899 | config: Config{ |
| 9900 | MaxVersion: VersionTLS12, |
| 9901 | }, |
| 9902 | resumeSession: true, |
| 9903 | resumeConfig: &Config{ |
| 9904 | MaxVersion: VersionTLS12, |
| 9905 | Bugs: ProtocolBugs{ |
| 9906 | FragmentAcrossChangeCipherSpec: true, |
| 9907 | PackHandshakeFlight: packed, |
| 9908 | }, |
| 9909 | }, |
| 9910 | shouldFail: true, |
| 9911 | expectedError: ":UNEXPECTED_RECORD:", |
| 9912 | }) |
| 9913 | testCases = append(testCases, testCase{ |
| 9914 | testType: serverTest, |
| 9915 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 9916 | config: Config{ |
| 9917 | MaxVersion: VersionTLS12, |
| 9918 | NextProtos: []string{"bar"}, |
| 9919 | Bugs: ProtocolBugs{ |
| 9920 | FragmentAcrossChangeCipherSpec: true, |
| 9921 | PackHandshakeFlight: packed, |
| 9922 | }, |
| 9923 | }, |
| 9924 | flags: []string{ |
| 9925 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9926 | }, |
| 9927 | shouldFail: true, |
| 9928 | expectedError: ":UNEXPECTED_RECORD:", |
| 9929 | }) |
| 9930 | } |
| 9931 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 9932 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 9933 | // messages in the handshake queue. Do this by testing the server |
| 9934 | // reading the client Finished, reversing the flight so Finished comes |
| 9935 | // first. |
| 9936 | testCases = append(testCases, testCase{ |
| 9937 | protocol: dtls, |
| 9938 | testType: serverTest, |
| 9939 | name: "SendUnencryptedFinished-DTLS", |
| 9940 | config: Config{ |
| 9941 | MaxVersion: VersionTLS12, |
| 9942 | Bugs: ProtocolBugs{ |
| 9943 | SendUnencryptedFinished: true, |
| 9944 | ReverseHandshakeFragments: true, |
| 9945 | }, |
| 9946 | }, |
| 9947 | shouldFail: true, |
| 9948 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9949 | }) |
| 9950 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9951 | // Test synchronization between encryption changes and the handshake in |
| 9952 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 9953 | testCases = append(testCases, testCase{ |
| 9954 | name: "PartialEncryptedExtensionsWithServerHello", |
| 9955 | config: Config{ |
| 9956 | MaxVersion: VersionTLS13, |
| 9957 | Bugs: ProtocolBugs{ |
| 9958 | PartialEncryptedExtensionsWithServerHello: true, |
| 9959 | }, |
| 9960 | }, |
| 9961 | shouldFail: true, |
| 9962 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9963 | }) |
| 9964 | testCases = append(testCases, testCase{ |
| 9965 | testType: serverTest, |
| 9966 | name: "PartialClientFinishedWithClientHello", |
| 9967 | config: Config{ |
| 9968 | MaxVersion: VersionTLS13, |
| 9969 | Bugs: ProtocolBugs{ |
| 9970 | PartialClientFinishedWithClientHello: true, |
| 9971 | }, |
| 9972 | }, |
| 9973 | shouldFail: true, |
| 9974 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9975 | }) |
| 9976 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9977 | // Test that early ChangeCipherSpecs are handled correctly. |
| 9978 | testCases = append(testCases, testCase{ |
| 9979 | testType: serverTest, |
| 9980 | name: "EarlyChangeCipherSpec-server-1", |
| 9981 | config: Config{ |
| 9982 | MaxVersion: VersionTLS12, |
| 9983 | Bugs: ProtocolBugs{ |
| 9984 | EarlyChangeCipherSpec: 1, |
| 9985 | }, |
| 9986 | }, |
| 9987 | shouldFail: true, |
| 9988 | expectedError: ":UNEXPECTED_RECORD:", |
| 9989 | }) |
| 9990 | testCases = append(testCases, testCase{ |
| 9991 | testType: serverTest, |
| 9992 | name: "EarlyChangeCipherSpec-server-2", |
| 9993 | config: Config{ |
| 9994 | MaxVersion: VersionTLS12, |
| 9995 | Bugs: ProtocolBugs{ |
| 9996 | EarlyChangeCipherSpec: 2, |
| 9997 | }, |
| 9998 | }, |
| 9999 | shouldFail: true, |
| 10000 | expectedError: ":UNEXPECTED_RECORD:", |
| 10001 | }) |
| 10002 | testCases = append(testCases, testCase{ |
| 10003 | protocol: dtls, |
| 10004 | name: "StrayChangeCipherSpec", |
| 10005 | config: Config{ |
| 10006 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10007 | // that stray ChangeCipherSpec messages are |
| 10008 | // rejected. |
| 10009 | MaxVersion: VersionTLS12, |
| 10010 | Bugs: ProtocolBugs{ |
| 10011 | StrayChangeCipherSpec: true, |
| 10012 | }, |
| 10013 | }, |
| 10014 | }) |
| 10015 | |
| 10016 | // Test that the contents of ChangeCipherSpec are checked. |
| 10017 | testCases = append(testCases, testCase{ |
| 10018 | name: "BadChangeCipherSpec-1", |
| 10019 | config: Config{ |
| 10020 | MaxVersion: VersionTLS12, |
| 10021 | Bugs: ProtocolBugs{ |
| 10022 | BadChangeCipherSpec: []byte{2}, |
| 10023 | }, |
| 10024 | }, |
| 10025 | shouldFail: true, |
| 10026 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10027 | }) |
| 10028 | testCases = append(testCases, testCase{ |
| 10029 | name: "BadChangeCipherSpec-2", |
| 10030 | config: Config{ |
| 10031 | MaxVersion: VersionTLS12, |
| 10032 | Bugs: ProtocolBugs{ |
| 10033 | BadChangeCipherSpec: []byte{1, 1}, |
| 10034 | }, |
| 10035 | }, |
| 10036 | shouldFail: true, |
| 10037 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10038 | }) |
| 10039 | testCases = append(testCases, testCase{ |
| 10040 | protocol: dtls, |
| 10041 | name: "BadChangeCipherSpec-DTLS-1", |
| 10042 | config: Config{ |
| 10043 | MaxVersion: VersionTLS12, |
| 10044 | Bugs: ProtocolBugs{ |
| 10045 | BadChangeCipherSpec: []byte{2}, |
| 10046 | }, |
| 10047 | }, |
| 10048 | shouldFail: true, |
| 10049 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10050 | }) |
| 10051 | testCases = append(testCases, testCase{ |
| 10052 | protocol: dtls, |
| 10053 | name: "BadChangeCipherSpec-DTLS-2", |
| 10054 | config: Config{ |
| 10055 | MaxVersion: VersionTLS12, |
| 10056 | Bugs: ProtocolBugs{ |
| 10057 | BadChangeCipherSpec: []byte{1, 1}, |
| 10058 | }, |
| 10059 | }, |
| 10060 | shouldFail: true, |
| 10061 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10062 | }) |
| 10063 | } |
| 10064 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10065 | type perMessageTest struct { |
| 10066 | messageType uint8 |
| 10067 | test testCase |
| 10068 | } |
| 10069 | |
| 10070 | // makePerMessageTests returns a series of test templates which cover each |
| 10071 | // message in the TLS handshake. These may be used with bugs like |
| 10072 | // WrongMessageType to fully test a per-message bug. |
| 10073 | func makePerMessageTests() []perMessageTest { |
| 10074 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10075 | for _, protocol := range []protocol{tls, dtls} { |
| 10076 | var suffix string |
| 10077 | if protocol == dtls { |
| 10078 | suffix = "-DTLS" |
| 10079 | } |
| 10080 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10081 | ret = append(ret, perMessageTest{ |
| 10082 | messageType: typeClientHello, |
| 10083 | test: testCase{ |
| 10084 | protocol: protocol, |
| 10085 | testType: serverTest, |
| 10086 | name: "ClientHello" + suffix, |
| 10087 | config: Config{ |
| 10088 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10089 | }, |
| 10090 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10091 | }) |
| 10092 | |
| 10093 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10094 | ret = append(ret, perMessageTest{ |
| 10095 | messageType: typeHelloVerifyRequest, |
| 10096 | test: testCase{ |
| 10097 | protocol: protocol, |
| 10098 | name: "HelloVerifyRequest" + suffix, |
| 10099 | config: Config{ |
| 10100 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10101 | }, |
| 10102 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10103 | }) |
| 10104 | } |
| 10105 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10106 | ret = append(ret, perMessageTest{ |
| 10107 | messageType: typeServerHello, |
| 10108 | test: testCase{ |
| 10109 | protocol: protocol, |
| 10110 | name: "ServerHello" + suffix, |
| 10111 | config: Config{ |
| 10112 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10113 | }, |
| 10114 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10115 | }) |
| 10116 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10117 | ret = append(ret, perMessageTest{ |
| 10118 | messageType: typeCertificate, |
| 10119 | test: testCase{ |
| 10120 | protocol: protocol, |
| 10121 | name: "ServerCertificate" + suffix, |
| 10122 | config: Config{ |
| 10123 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10124 | }, |
| 10125 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10126 | }) |
| 10127 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10128 | ret = append(ret, perMessageTest{ |
| 10129 | messageType: typeCertificateStatus, |
| 10130 | test: testCase{ |
| 10131 | protocol: protocol, |
| 10132 | name: "CertificateStatus" + suffix, |
| 10133 | config: Config{ |
| 10134 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10135 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10136 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10137 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10138 | }) |
| 10139 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10140 | ret = append(ret, perMessageTest{ |
| 10141 | messageType: typeServerKeyExchange, |
| 10142 | test: testCase{ |
| 10143 | protocol: protocol, |
| 10144 | name: "ServerKeyExchange" + suffix, |
| 10145 | config: Config{ |
| 10146 | MaxVersion: VersionTLS12, |
| 10147 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10148 | }, |
| 10149 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10150 | }) |
| 10151 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10152 | ret = append(ret, perMessageTest{ |
| 10153 | messageType: typeCertificateRequest, |
| 10154 | test: testCase{ |
| 10155 | protocol: protocol, |
| 10156 | name: "CertificateRequest" + suffix, |
| 10157 | config: Config{ |
| 10158 | MaxVersion: VersionTLS12, |
| 10159 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10160 | }, |
| 10161 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10162 | }) |
| 10163 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10164 | ret = append(ret, perMessageTest{ |
| 10165 | messageType: typeServerHelloDone, |
| 10166 | test: testCase{ |
| 10167 | protocol: protocol, |
| 10168 | name: "ServerHelloDone" + suffix, |
| 10169 | config: Config{ |
| 10170 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10171 | }, |
| 10172 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10173 | }) |
| 10174 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10175 | ret = append(ret, perMessageTest{ |
| 10176 | messageType: typeCertificate, |
| 10177 | test: testCase{ |
| 10178 | testType: serverTest, |
| 10179 | protocol: protocol, |
| 10180 | name: "ClientCertificate" + suffix, |
| 10181 | config: Config{ |
| 10182 | Certificates: []Certificate{rsaCertificate}, |
| 10183 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10184 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10185 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10186 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10187 | }) |
| 10188 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10189 | ret = append(ret, perMessageTest{ |
| 10190 | messageType: typeCertificateVerify, |
| 10191 | test: testCase{ |
| 10192 | testType: serverTest, |
| 10193 | protocol: protocol, |
| 10194 | name: "CertificateVerify" + suffix, |
| 10195 | config: Config{ |
| 10196 | Certificates: []Certificate{rsaCertificate}, |
| 10197 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10198 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10199 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10200 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10201 | }) |
| 10202 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10203 | ret = append(ret, perMessageTest{ |
| 10204 | messageType: typeClientKeyExchange, |
| 10205 | test: testCase{ |
| 10206 | testType: serverTest, |
| 10207 | protocol: protocol, |
| 10208 | name: "ClientKeyExchange" + suffix, |
| 10209 | config: Config{ |
| 10210 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10211 | }, |
| 10212 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10213 | }) |
| 10214 | |
| 10215 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10216 | ret = append(ret, perMessageTest{ |
| 10217 | messageType: typeNextProtocol, |
| 10218 | test: testCase{ |
| 10219 | testType: serverTest, |
| 10220 | protocol: protocol, |
| 10221 | name: "NextProtocol" + suffix, |
| 10222 | config: Config{ |
| 10223 | MaxVersion: VersionTLS12, |
| 10224 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10225 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10226 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10227 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10228 | }) |
| 10229 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10230 | ret = append(ret, perMessageTest{ |
| 10231 | messageType: typeChannelID, |
| 10232 | test: testCase{ |
| 10233 | testType: serverTest, |
| 10234 | protocol: protocol, |
| 10235 | name: "ChannelID" + suffix, |
| 10236 | config: Config{ |
| 10237 | MaxVersion: VersionTLS12, |
| 10238 | ChannelID: channelIDKey, |
| 10239 | }, |
| 10240 | flags: []string{ |
| 10241 | "-expect-channel-id", |
| 10242 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10243 | }, |
| 10244 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10245 | }) |
| 10246 | } |
| 10247 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10248 | ret = append(ret, perMessageTest{ |
| 10249 | messageType: typeFinished, |
| 10250 | test: testCase{ |
| 10251 | testType: serverTest, |
| 10252 | protocol: protocol, |
| 10253 | name: "ClientFinished" + suffix, |
| 10254 | config: Config{ |
| 10255 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10256 | }, |
| 10257 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10258 | }) |
| 10259 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10260 | ret = append(ret, perMessageTest{ |
| 10261 | messageType: typeNewSessionTicket, |
| 10262 | test: testCase{ |
| 10263 | protocol: protocol, |
| 10264 | name: "NewSessionTicket" + suffix, |
| 10265 | config: Config{ |
| 10266 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10267 | }, |
| 10268 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10269 | }) |
| 10270 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10271 | ret = append(ret, perMessageTest{ |
| 10272 | messageType: typeFinished, |
| 10273 | test: testCase{ |
| 10274 | protocol: protocol, |
| 10275 | name: "ServerFinished" + suffix, |
| 10276 | config: Config{ |
| 10277 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10278 | }, |
| 10279 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10280 | }) |
| 10281 | |
| 10282 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10283 | |
| 10284 | ret = append(ret, perMessageTest{ |
| 10285 | messageType: typeClientHello, |
| 10286 | test: testCase{ |
| 10287 | testType: serverTest, |
| 10288 | name: "TLS13-ClientHello", |
| 10289 | config: Config{ |
| 10290 | MaxVersion: VersionTLS13, |
| 10291 | }, |
| 10292 | }, |
| 10293 | }) |
| 10294 | |
| 10295 | ret = append(ret, perMessageTest{ |
| 10296 | messageType: typeServerHello, |
| 10297 | test: testCase{ |
| 10298 | name: "TLS13-ServerHello", |
| 10299 | config: Config{ |
| 10300 | MaxVersion: VersionTLS13, |
| 10301 | }, |
| 10302 | }, |
| 10303 | }) |
| 10304 | |
| 10305 | ret = append(ret, perMessageTest{ |
| 10306 | messageType: typeEncryptedExtensions, |
| 10307 | test: testCase{ |
| 10308 | name: "TLS13-EncryptedExtensions", |
| 10309 | config: Config{ |
| 10310 | MaxVersion: VersionTLS13, |
| 10311 | }, |
| 10312 | }, |
| 10313 | }) |
| 10314 | |
| 10315 | ret = append(ret, perMessageTest{ |
| 10316 | messageType: typeCertificateRequest, |
| 10317 | test: testCase{ |
| 10318 | name: "TLS13-CertificateRequest", |
| 10319 | config: Config{ |
| 10320 | MaxVersion: VersionTLS13, |
| 10321 | ClientAuth: RequireAnyClientCert, |
| 10322 | }, |
| 10323 | }, |
| 10324 | }) |
| 10325 | |
| 10326 | ret = append(ret, perMessageTest{ |
| 10327 | messageType: typeCertificate, |
| 10328 | test: testCase{ |
| 10329 | name: "TLS13-ServerCertificate", |
| 10330 | config: Config{ |
| 10331 | MaxVersion: VersionTLS13, |
| 10332 | }, |
| 10333 | }, |
| 10334 | }) |
| 10335 | |
| 10336 | ret = append(ret, perMessageTest{ |
| 10337 | messageType: typeCertificateVerify, |
| 10338 | test: testCase{ |
| 10339 | name: "TLS13-ServerCertificateVerify", |
| 10340 | config: Config{ |
| 10341 | MaxVersion: VersionTLS13, |
| 10342 | }, |
| 10343 | }, |
| 10344 | }) |
| 10345 | |
| 10346 | ret = append(ret, perMessageTest{ |
| 10347 | messageType: typeFinished, |
| 10348 | test: testCase{ |
| 10349 | name: "TLS13-ServerFinished", |
| 10350 | config: Config{ |
| 10351 | MaxVersion: VersionTLS13, |
| 10352 | }, |
| 10353 | }, |
| 10354 | }) |
| 10355 | |
| 10356 | ret = append(ret, perMessageTest{ |
| 10357 | messageType: typeCertificate, |
| 10358 | test: testCase{ |
| 10359 | testType: serverTest, |
| 10360 | name: "TLS13-ClientCertificate", |
| 10361 | config: Config{ |
| 10362 | Certificates: []Certificate{rsaCertificate}, |
| 10363 | MaxVersion: VersionTLS13, |
| 10364 | }, |
| 10365 | flags: []string{"-require-any-client-certificate"}, |
| 10366 | }, |
| 10367 | }) |
| 10368 | |
| 10369 | ret = append(ret, perMessageTest{ |
| 10370 | messageType: typeCertificateVerify, |
| 10371 | test: testCase{ |
| 10372 | testType: serverTest, |
| 10373 | name: "TLS13-ClientCertificateVerify", |
| 10374 | config: Config{ |
| 10375 | Certificates: []Certificate{rsaCertificate}, |
| 10376 | MaxVersion: VersionTLS13, |
| 10377 | }, |
| 10378 | flags: []string{"-require-any-client-certificate"}, |
| 10379 | }, |
| 10380 | }) |
| 10381 | |
| 10382 | ret = append(ret, perMessageTest{ |
| 10383 | messageType: typeFinished, |
| 10384 | test: testCase{ |
| 10385 | testType: serverTest, |
| 10386 | name: "TLS13-ClientFinished", |
| 10387 | config: Config{ |
| 10388 | MaxVersion: VersionTLS13, |
| 10389 | }, |
| 10390 | }, |
| 10391 | }) |
| 10392 | |
| 10393 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10394 | } |
| 10395 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10396 | func addWrongMessageTypeTests() { |
| 10397 | for _, t := range makePerMessageTests() { |
| 10398 | t.test.name = "WrongMessageType-" + t.test.name |
| 10399 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10400 | t.test.shouldFail = true |
| 10401 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10402 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10403 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10404 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10405 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10406 | // an unencrypted alert while the server expects |
| 10407 | // encryption, so the alert is not readable by runner. |
| 10408 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10409 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10410 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10411 | testCases = append(testCases, t.test) |
| 10412 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10413 | |
| 10414 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10415 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10416 | // TLS 1.2. Test that we do not do this. |
| 10417 | testCases = append(testCases, testCase{ |
| 10418 | name: "SendServerHelloAsHelloRetryRequest", |
| 10419 | config: Config{ |
| 10420 | MaxVersion: VersionTLS12, |
| 10421 | Bugs: ProtocolBugs{ |
| 10422 | SendServerHelloAsHelloRetryRequest: true, |
| 10423 | }, |
| 10424 | }, |
| 10425 | shouldFail: true, |
| 10426 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10427 | expectedLocalError: "remote error: unexpected message", |
| 10428 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10429 | } |
| 10430 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10431 | func addTrailingMessageDataTests() { |
| 10432 | for _, t := range makePerMessageTests() { |
| 10433 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10434 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10435 | t.test.shouldFail = true |
| 10436 | t.test.expectedError = ":DECODE_ERROR:" |
| 10437 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10438 | |
| 10439 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10440 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10441 | // an unencrypted alert while the server expects |
| 10442 | // encryption, so the alert is not readable by runner. |
| 10443 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10444 | } |
| 10445 | |
| 10446 | if t.messageType == typeFinished { |
| 10447 | // Bad Finished messages read as the verify data having |
| 10448 | // the wrong length. |
| 10449 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10450 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10451 | } |
| 10452 | |
| 10453 | testCases = append(testCases, t.test) |
| 10454 | } |
| 10455 | } |
| 10456 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10457 | func addTLS13HandshakeTests() { |
| 10458 | testCases = append(testCases, testCase{ |
| 10459 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10460 | name: "NegotiatePSKResumption-TLS13", |
| 10461 | config: Config{ |
| 10462 | MaxVersion: VersionTLS13, |
| 10463 | Bugs: ProtocolBugs{ |
| 10464 | NegotiatePSKResumption: true, |
| 10465 | }, |
| 10466 | }, |
| 10467 | resumeSession: true, |
| 10468 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10469 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10470 | }) |
| 10471 | |
| 10472 | testCases = append(testCases, testCase{ |
| 10473 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10474 | name: "MissingKeyShare-Client", |
| 10475 | config: Config{ |
| 10476 | MaxVersion: VersionTLS13, |
| 10477 | Bugs: ProtocolBugs{ |
| 10478 | MissingKeyShare: true, |
| 10479 | }, |
| 10480 | }, |
| 10481 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10482 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10483 | }) |
| 10484 | |
| 10485 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10486 | testType: serverTest, |
| 10487 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10488 | config: Config{ |
| 10489 | MaxVersion: VersionTLS13, |
| 10490 | Bugs: ProtocolBugs{ |
| 10491 | MissingKeyShare: true, |
| 10492 | }, |
| 10493 | }, |
| 10494 | shouldFail: true, |
| 10495 | expectedError: ":MISSING_KEY_SHARE:", |
| 10496 | }) |
| 10497 | |
| 10498 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10499 | testType: serverTest, |
| 10500 | name: "DuplicateKeyShares", |
| 10501 | config: Config{ |
| 10502 | MaxVersion: VersionTLS13, |
| 10503 | Bugs: ProtocolBugs{ |
| 10504 | DuplicateKeyShares: true, |
| 10505 | }, |
| 10506 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10507 | shouldFail: true, |
| 10508 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10509 | }) |
| 10510 | |
| 10511 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10512 | testType: serverTest, |
| 10513 | name: "SkipEarlyData", |
| 10514 | config: Config{ |
| 10515 | MaxVersion: VersionTLS13, |
| 10516 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10517 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10518 | }, |
| 10519 | }, |
| 10520 | }) |
| 10521 | |
| 10522 | testCases = append(testCases, testCase{ |
| 10523 | testType: serverTest, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 10524 | name: "SkipEarlyData-TLS13Experiment", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10525 | config: Config{ |
| 10526 | MaxVersion: VersionTLS13, |
| 10527 | TLS13Variant: TLS13Experiment, |
| 10528 | Bugs: ProtocolBugs{ |
| 10529 | SendFakeEarlyDataLength: 4, |
| 10530 | }, |
| 10531 | }, |
| 10532 | flags: []string{"-tls13-variant", "1"}, |
| 10533 | }) |
| 10534 | |
| 10535 | testCases = append(testCases, testCase{ |
| 10536 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10537 | name: "SkipEarlyData-TLS13RecordTypeExperiment", |
| 10538 | config: Config{ |
| 10539 | MaxVersion: VersionTLS13, |
| 10540 | TLS13Variant: TLS13RecordTypeExperiment, |
| 10541 | Bugs: ProtocolBugs{ |
| 10542 | SendFakeEarlyDataLength: 4, |
| 10543 | }, |
| 10544 | }, |
| 10545 | flags: []string{"-tls13-variant", "2"}, |
| 10546 | }) |
| 10547 | |
| 10548 | testCases = append(testCases, testCase{ |
| 10549 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10550 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10551 | config: Config{ |
| 10552 | MaxVersion: VersionTLS13, |
| 10553 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10554 | SendFakeEarlyDataLength: 4, |
| 10555 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10556 | }, |
| 10557 | }, |
| 10558 | shouldFail: true, |
| 10559 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10560 | }) |
| 10561 | |
| 10562 | testCases = append(testCases, testCase{ |
| 10563 | testType: serverTest, |
| 10564 | name: "SkipEarlyData-TooMuchData", |
| 10565 | config: Config{ |
| 10566 | MaxVersion: VersionTLS13, |
| 10567 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10568 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10569 | }, |
| 10570 | }, |
| 10571 | shouldFail: true, |
| 10572 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10573 | }) |
| 10574 | |
| 10575 | testCases = append(testCases, testCase{ |
| 10576 | testType: serverTest, |
| 10577 | name: "SkipEarlyData-Interleaved", |
| 10578 | config: Config{ |
| 10579 | MaxVersion: VersionTLS13, |
| 10580 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10581 | SendFakeEarlyDataLength: 4, |
| 10582 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10583 | }, |
| 10584 | }, |
| 10585 | shouldFail: true, |
| 10586 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10587 | }) |
| 10588 | |
| 10589 | testCases = append(testCases, testCase{ |
| 10590 | testType: serverTest, |
| 10591 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10592 | config: Config{ |
| 10593 | MaxVersion: VersionTLS13, |
| 10594 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10595 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10596 | }, |
| 10597 | }, |
| 10598 | shouldFail: true, |
| 10599 | expectedError: ":UNEXPECTED_RECORD:", |
| 10600 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10601 | }) |
| 10602 | |
| 10603 | testCases = append(testCases, testCase{ |
| 10604 | testType: serverTest, |
| 10605 | name: "SkipEarlyData-HRR", |
| 10606 | config: Config{ |
| 10607 | MaxVersion: VersionTLS13, |
| 10608 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10609 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10610 | }, |
| 10611 | DefaultCurves: []CurveID{}, |
| 10612 | }, |
| 10613 | }) |
| 10614 | |
| 10615 | testCases = append(testCases, testCase{ |
| 10616 | testType: serverTest, |
| 10617 | name: "SkipEarlyData-HRR-Interleaved", |
| 10618 | config: Config{ |
| 10619 | MaxVersion: VersionTLS13, |
| 10620 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10621 | SendFakeEarlyDataLength: 4, |
| 10622 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10623 | }, |
| 10624 | DefaultCurves: []CurveID{}, |
| 10625 | }, |
| 10626 | shouldFail: true, |
| 10627 | expectedError: ":UNEXPECTED_RECORD:", |
| 10628 | }) |
| 10629 | |
| 10630 | testCases = append(testCases, testCase{ |
| 10631 | testType: serverTest, |
| 10632 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10633 | config: Config{ |
| 10634 | MaxVersion: VersionTLS13, |
| 10635 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10636 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10637 | }, |
| 10638 | DefaultCurves: []CurveID{}, |
| 10639 | }, |
| 10640 | shouldFail: true, |
| 10641 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10642 | }) |
| 10643 | |
| 10644 | // Test that skipping early data looking for cleartext correctly |
| 10645 | // processes an alert record. |
| 10646 | testCases = append(testCases, testCase{ |
| 10647 | testType: serverTest, |
| 10648 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10649 | config: Config{ |
| 10650 | MaxVersion: VersionTLS13, |
| 10651 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10652 | SendEarlyAlert: true, |
| 10653 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10654 | }, |
| 10655 | DefaultCurves: []CurveID{}, |
| 10656 | }, |
| 10657 | shouldFail: true, |
| 10658 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10659 | }) |
| 10660 | |
| 10661 | testCases = append(testCases, testCase{ |
| 10662 | testType: serverTest, |
| 10663 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10664 | config: Config{ |
| 10665 | MaxVersion: VersionTLS13, |
| 10666 | Bugs: ProtocolBugs{ |
| 10667 | SendEarlyDataOnSecondClientHello: true, |
| 10668 | }, |
| 10669 | DefaultCurves: []CurveID{}, |
| 10670 | }, |
| 10671 | shouldFail: true, |
| 10672 | expectedLocalError: "remote error: bad record MAC", |
| 10673 | }) |
| 10674 | |
| 10675 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10676 | testType: clientTest, |
| 10677 | name: "EmptyEncryptedExtensions", |
| 10678 | config: Config{ |
| 10679 | MaxVersion: VersionTLS13, |
| 10680 | Bugs: ProtocolBugs{ |
| 10681 | EmptyEncryptedExtensions: true, |
| 10682 | }, |
| 10683 | }, |
| 10684 | shouldFail: true, |
| 10685 | expectedLocalError: "remote error: error decoding message", |
| 10686 | }) |
| 10687 | |
| 10688 | testCases = append(testCases, testCase{ |
| 10689 | testType: clientTest, |
| 10690 | name: "EncryptedExtensionsWithKeyShare", |
| 10691 | config: Config{ |
| 10692 | MaxVersion: VersionTLS13, |
| 10693 | Bugs: ProtocolBugs{ |
| 10694 | EncryptedExtensionsWithKeyShare: true, |
| 10695 | }, |
| 10696 | }, |
| 10697 | shouldFail: true, |
| 10698 | expectedLocalError: "remote error: unsupported extension", |
| 10699 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10700 | |
| 10701 | testCases = append(testCases, testCase{ |
| 10702 | testType: serverTest, |
| 10703 | name: "SendHelloRetryRequest", |
| 10704 | config: Config{ |
| 10705 | MaxVersion: VersionTLS13, |
| 10706 | // Require a HelloRetryRequest for every curve. |
| 10707 | DefaultCurves: []CurveID{}, |
| 10708 | }, |
| 10709 | expectedCurveID: CurveX25519, |
| 10710 | }) |
| 10711 | |
| 10712 | testCases = append(testCases, testCase{ |
| 10713 | testType: serverTest, |
| 10714 | name: "SendHelloRetryRequest-2", |
| 10715 | config: Config{ |
| 10716 | MaxVersion: VersionTLS13, |
| 10717 | DefaultCurves: []CurveID{CurveP384}, |
| 10718 | }, |
| 10719 | // Although the ClientHello did not predict our preferred curve, |
| 10720 | // we always select it whether it is predicted or not. |
| 10721 | expectedCurveID: CurveX25519, |
| 10722 | }) |
| 10723 | |
| 10724 | testCases = append(testCases, testCase{ |
| 10725 | name: "UnknownCurve-HelloRetryRequest", |
| 10726 | config: Config{ |
| 10727 | MaxVersion: VersionTLS13, |
| 10728 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10729 | CurvePreferences: []CurveID{CurveP384}, |
| 10730 | Bugs: ProtocolBugs{ |
| 10731 | SendHelloRetryRequestCurve: bogusCurve, |
| 10732 | }, |
| 10733 | }, |
| 10734 | shouldFail: true, |
| 10735 | expectedError: ":WRONG_CURVE:", |
| 10736 | }) |
| 10737 | |
| 10738 | testCases = append(testCases, testCase{ |
| 10739 | name: "DisabledCurve-HelloRetryRequest", |
| 10740 | config: Config{ |
| 10741 | MaxVersion: VersionTLS13, |
| 10742 | CurvePreferences: []CurveID{CurveP256}, |
| 10743 | Bugs: ProtocolBugs{ |
| 10744 | IgnorePeerCurvePreferences: true, |
| 10745 | }, |
| 10746 | }, |
| 10747 | flags: []string{"-p384-only"}, |
| 10748 | shouldFail: true, |
| 10749 | expectedError: ":WRONG_CURVE:", |
| 10750 | }) |
| 10751 | |
| 10752 | testCases = append(testCases, testCase{ |
| 10753 | name: "UnnecessaryHelloRetryRequest", |
| 10754 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10755 | MaxVersion: VersionTLS13, |
| 10756 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10757 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10758 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10759 | }, |
| 10760 | }, |
| 10761 | shouldFail: true, |
| 10762 | expectedError: ":WRONG_CURVE:", |
| 10763 | }) |
| 10764 | |
| 10765 | testCases = append(testCases, testCase{ |
| 10766 | name: "SecondHelloRetryRequest", |
| 10767 | config: Config{ |
| 10768 | MaxVersion: VersionTLS13, |
| 10769 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10770 | CurvePreferences: []CurveID{CurveP384}, |
| 10771 | Bugs: ProtocolBugs{ |
| 10772 | SecondHelloRetryRequest: true, |
| 10773 | }, |
| 10774 | }, |
| 10775 | shouldFail: true, |
| 10776 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10777 | }) |
| 10778 | |
| 10779 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10780 | name: "HelloRetryRequest-Empty", |
| 10781 | config: Config{ |
| 10782 | MaxVersion: VersionTLS13, |
| 10783 | Bugs: ProtocolBugs{ |
| 10784 | AlwaysSendHelloRetryRequest: true, |
| 10785 | }, |
| 10786 | }, |
| 10787 | shouldFail: true, |
| 10788 | expectedError: ":DECODE_ERROR:", |
| 10789 | }) |
| 10790 | |
| 10791 | testCases = append(testCases, testCase{ |
| 10792 | name: "HelloRetryRequest-DuplicateCurve", |
| 10793 | config: Config{ |
| 10794 | MaxVersion: VersionTLS13, |
| 10795 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 10796 | // configuration. Assert this ExpectMissingKeyShare. |
| 10797 | CurvePreferences: []CurveID{CurveP384}, |
| 10798 | Bugs: ProtocolBugs{ |
| 10799 | ExpectMissingKeyShare: true, |
| 10800 | DuplicateHelloRetryRequestExtensions: true, |
| 10801 | }, |
| 10802 | }, |
| 10803 | shouldFail: true, |
| 10804 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10805 | expectedLocalError: "remote error: illegal parameter", |
| 10806 | }) |
| 10807 | |
| 10808 | testCases = append(testCases, testCase{ |
| 10809 | name: "HelloRetryRequest-Cookie", |
| 10810 | config: Config{ |
| 10811 | MaxVersion: VersionTLS13, |
| 10812 | Bugs: ProtocolBugs{ |
| 10813 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10814 | }, |
| 10815 | }, |
| 10816 | }) |
| 10817 | |
| 10818 | testCases = append(testCases, testCase{ |
| 10819 | name: "HelloRetryRequest-DuplicateCookie", |
| 10820 | config: Config{ |
| 10821 | MaxVersion: VersionTLS13, |
| 10822 | Bugs: ProtocolBugs{ |
| 10823 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10824 | DuplicateHelloRetryRequestExtensions: true, |
| 10825 | }, |
| 10826 | }, |
| 10827 | shouldFail: true, |
| 10828 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10829 | expectedLocalError: "remote error: illegal parameter", |
| 10830 | }) |
| 10831 | |
| 10832 | testCases = append(testCases, testCase{ |
| 10833 | name: "HelloRetryRequest-EmptyCookie", |
| 10834 | config: Config{ |
| 10835 | MaxVersion: VersionTLS13, |
| 10836 | Bugs: ProtocolBugs{ |
| 10837 | SendHelloRetryRequestCookie: []byte{}, |
| 10838 | }, |
| 10839 | }, |
| 10840 | shouldFail: true, |
| 10841 | expectedError: ":DECODE_ERROR:", |
| 10842 | }) |
| 10843 | |
| 10844 | testCases = append(testCases, testCase{ |
| 10845 | name: "HelloRetryRequest-Cookie-Curve", |
| 10846 | config: Config{ |
| 10847 | MaxVersion: VersionTLS13, |
| 10848 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10849 | CurvePreferences: []CurveID{CurveP384}, |
| 10850 | Bugs: ProtocolBugs{ |
| 10851 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10852 | ExpectMissingKeyShare: true, |
| 10853 | }, |
| 10854 | }, |
| 10855 | }) |
| 10856 | |
| 10857 | testCases = append(testCases, testCase{ |
| 10858 | name: "HelloRetryRequest-Unknown", |
| 10859 | config: Config{ |
| 10860 | MaxVersion: VersionTLS13, |
| 10861 | Bugs: ProtocolBugs{ |
| 10862 | CustomHelloRetryRequestExtension: "extension", |
| 10863 | }, |
| 10864 | }, |
| 10865 | shouldFail: true, |
| 10866 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10867 | expectedLocalError: "remote error: unsupported extension", |
| 10868 | }) |
| 10869 | |
| 10870 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10871 | testType: serverTest, |
| 10872 | name: "SecondClientHelloMissingKeyShare", |
| 10873 | config: Config{ |
| 10874 | MaxVersion: VersionTLS13, |
| 10875 | DefaultCurves: []CurveID{}, |
| 10876 | Bugs: ProtocolBugs{ |
| 10877 | SecondClientHelloMissingKeyShare: true, |
| 10878 | }, |
| 10879 | }, |
| 10880 | shouldFail: true, |
| 10881 | expectedError: ":MISSING_KEY_SHARE:", |
| 10882 | }) |
| 10883 | |
| 10884 | testCases = append(testCases, testCase{ |
| 10885 | testType: serverTest, |
| 10886 | name: "SecondClientHelloWrongCurve", |
| 10887 | config: Config{ |
| 10888 | MaxVersion: VersionTLS13, |
| 10889 | DefaultCurves: []CurveID{}, |
| 10890 | Bugs: ProtocolBugs{ |
| 10891 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 10892 | }, |
| 10893 | }, |
| 10894 | shouldFail: true, |
| 10895 | expectedError: ":WRONG_CURVE:", |
| 10896 | }) |
| 10897 | |
| 10898 | testCases = append(testCases, testCase{ |
| 10899 | name: "HelloRetryRequestVersionMismatch", |
| 10900 | config: Config{ |
| 10901 | MaxVersion: VersionTLS13, |
| 10902 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10903 | CurvePreferences: []CurveID{CurveP384}, |
| 10904 | Bugs: ProtocolBugs{ |
| 10905 | SendServerHelloVersion: 0x0305, |
| 10906 | }, |
| 10907 | }, |
| 10908 | shouldFail: true, |
| 10909 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10910 | }) |
| 10911 | |
| 10912 | testCases = append(testCases, testCase{ |
| 10913 | name: "HelloRetryRequestCurveMismatch", |
| 10914 | config: Config{ |
| 10915 | MaxVersion: VersionTLS13, |
| 10916 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10917 | CurvePreferences: []CurveID{CurveP384}, |
| 10918 | Bugs: ProtocolBugs{ |
| 10919 | // Send P-384 (correct) in the HelloRetryRequest. |
| 10920 | SendHelloRetryRequestCurve: CurveP384, |
| 10921 | // But send P-256 in the ServerHello. |
| 10922 | SendCurve: CurveP256, |
| 10923 | }, |
| 10924 | }, |
| 10925 | shouldFail: true, |
| 10926 | expectedError: ":WRONG_CURVE:", |
| 10927 | }) |
| 10928 | |
| 10929 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 10930 | // without sending it. |
| 10931 | testCases = append(testCases, testCase{ |
| 10932 | name: "SkipHelloRetryRequest", |
| 10933 | config: Config{ |
| 10934 | MaxVersion: VersionTLS13, |
| 10935 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10936 | CurvePreferences: []CurveID{CurveP384}, |
| 10937 | Bugs: ProtocolBugs{ |
| 10938 | SkipHelloRetryRequest: true, |
| 10939 | }, |
| 10940 | }, |
| 10941 | shouldFail: true, |
| 10942 | expectedError: ":WRONG_CURVE:", |
| 10943 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 10944 | |
| 10945 | testCases = append(testCases, testCase{ |
| 10946 | name: "TLS13-RequestContextInHandshake", |
| 10947 | config: Config{ |
| 10948 | MaxVersion: VersionTLS13, |
| 10949 | MinVersion: VersionTLS13, |
| 10950 | ClientAuth: RequireAnyClientCert, |
| 10951 | Bugs: ProtocolBugs{ |
| 10952 | SendRequestContext: []byte("request context"), |
| 10953 | }, |
| 10954 | }, |
| 10955 | flags: []string{ |
| 10956 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 10957 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 10958 | }, |
| 10959 | shouldFail: true, |
| 10960 | expectedError: ":DECODE_ERROR:", |
| 10961 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10962 | |
| 10963 | testCases = append(testCases, testCase{ |
| 10964 | testType: serverTest, |
| 10965 | name: "TLS13-TrailingKeyShareData", |
| 10966 | config: Config{ |
| 10967 | MaxVersion: VersionTLS13, |
| 10968 | Bugs: ProtocolBugs{ |
| 10969 | TrailingKeyShareData: true, |
| 10970 | }, |
| 10971 | }, |
| 10972 | shouldFail: true, |
| 10973 | expectedError: ":DECODE_ERROR:", |
| 10974 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 10975 | |
| 10976 | testCases = append(testCases, testCase{ |
| 10977 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 10978 | config: Config{ |
| 10979 | MaxVersion: VersionTLS13, |
| 10980 | Bugs: ProtocolBugs{ |
| 10981 | AlwaysSelectPSKIdentity: true, |
| 10982 | }, |
| 10983 | }, |
| 10984 | shouldFail: true, |
| 10985 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10986 | }) |
| 10987 | |
| 10988 | testCases = append(testCases, testCase{ |
| 10989 | name: "TLS13-InvalidPSKIdentity", |
| 10990 | config: Config{ |
| 10991 | MaxVersion: VersionTLS13, |
| 10992 | Bugs: ProtocolBugs{ |
| 10993 | SelectPSKIdentityOnResume: 1, |
| 10994 | }, |
| 10995 | }, |
| 10996 | resumeSession: true, |
| 10997 | shouldFail: true, |
| 10998 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 10999 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11000 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11001 | testCases = append(testCases, testCase{ |
| 11002 | testType: serverTest, |
| 11003 | name: "TLS13-ExtraPSKIdentity", |
| 11004 | config: Config{ |
| 11005 | MaxVersion: VersionTLS13, |
| 11006 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11007 | ExtraPSKIdentity: true, |
| 11008 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11009 | }, |
| 11010 | }, |
| 11011 | resumeSession: true, |
| 11012 | }) |
| 11013 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11014 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11015 | testCases = append(testCases, testCase{ |
| 11016 | name: "TLS13-CustomTicketExtension", |
| 11017 | config: Config{ |
| 11018 | MaxVersion: VersionTLS13, |
| 11019 | Bugs: ProtocolBugs{ |
| 11020 | CustomTicketExtension: "1234", |
| 11021 | }, |
| 11022 | }, |
| 11023 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11024 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11025 | testCases = append(testCases, testCase{ |
| 11026 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11027 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11028 | config: Config{ |
| 11029 | MaxVersion: VersionTLS13, |
| 11030 | MaxEarlyDataSize: 16384, |
| 11031 | }, |
| 11032 | resumeConfig: &Config{ |
| 11033 | MaxVersion: VersionTLS13, |
| 11034 | MaxEarlyDataSize: 16384, |
| 11035 | Bugs: ProtocolBugs{ |
| 11036 | AlwaysRejectEarlyData: true, |
| 11037 | }, |
| 11038 | }, |
| 11039 | resumeSession: true, |
| 11040 | flags: []string{ |
| 11041 | "-enable-early-data", |
| 11042 | "-expect-early-data-info", |
| 11043 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11044 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11045 | }, |
| 11046 | }) |
| 11047 | |
| 11048 | testCases = append(testCases, testCase{ |
| 11049 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11050 | name: "TLS13Experiment-EarlyData-Reject-Client", |
| 11051 | config: Config{ |
| 11052 | MaxVersion: VersionTLS13, |
| 11053 | MaxEarlyDataSize: 16384, |
| 11054 | TLS13Variant: TLS13Experiment, |
| 11055 | }, |
| 11056 | resumeConfig: &Config{ |
| 11057 | MaxVersion: VersionTLS13, |
| 11058 | TLS13Variant: TLS13Experiment, |
| 11059 | MaxEarlyDataSize: 16384, |
| 11060 | Bugs: ProtocolBugs{ |
| 11061 | AlwaysRejectEarlyData: true, |
| 11062 | }, |
| 11063 | }, |
| 11064 | resumeSession: true, |
| 11065 | flags: []string{ |
| 11066 | "-enable-early-data", |
| 11067 | "-expect-early-data-info", |
| 11068 | "-expect-reject-early-data", |
| 11069 | "-on-resume-shim-writes-first", |
| 11070 | "-tls13-variant", "1", |
| 11071 | }, |
| 11072 | }) |
| 11073 | |
| 11074 | testCases = append(testCases, testCase{ |
| 11075 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11076 | name: "TLS13RecordTypeExperiment-EarlyData-Reject-Client", |
| 11077 | config: Config{ |
| 11078 | MaxVersion: VersionTLS13, |
| 11079 | MaxEarlyDataSize: 16384, |
| 11080 | TLS13Variant: TLS13RecordTypeExperiment, |
| 11081 | }, |
| 11082 | resumeConfig: &Config{ |
| 11083 | MaxVersion: VersionTLS13, |
| 11084 | TLS13Variant: TLS13RecordTypeExperiment, |
| 11085 | MaxEarlyDataSize: 16384, |
| 11086 | Bugs: ProtocolBugs{ |
| 11087 | AlwaysRejectEarlyData: true, |
| 11088 | }, |
| 11089 | }, |
| 11090 | resumeSession: true, |
| 11091 | flags: []string{ |
| 11092 | "-enable-early-data", |
| 11093 | "-expect-early-data-info", |
| 11094 | "-expect-reject-early-data", |
| 11095 | "-on-resume-shim-writes-first", |
| 11096 | "-tls13-variant", "2", |
| 11097 | }, |
| 11098 | }) |
| 11099 | |
| 11100 | testCases = append(testCases, testCase{ |
| 11101 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11102 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11103 | config: Config{ |
| 11104 | MaxVersion: VersionTLS13, |
| 11105 | MaxEarlyDataSize: 16384, |
| 11106 | Certificates: []Certificate{rsaCertificate}, |
| 11107 | }, |
| 11108 | resumeConfig: &Config{ |
| 11109 | MaxVersion: VersionTLS13, |
| 11110 | MaxEarlyDataSize: 16384, |
| 11111 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11112 | SessionTicketsDisabled: true, |
| 11113 | }, |
| 11114 | resumeSession: true, |
| 11115 | expectResumeRejected: true, |
| 11116 | flags: []string{ |
| 11117 | "-enable-early-data", |
| 11118 | "-expect-early-data-info", |
| 11119 | "-expect-reject-early-data", |
| 11120 | "-on-resume-shim-writes-first", |
| 11121 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11122 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11123 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11124 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11125 | "-on-retry-expect-no-session", |
| 11126 | }, |
| 11127 | }) |
| 11128 | |
| 11129 | testCases = append(testCases, testCase{ |
| 11130 | testType: clientTest, |
| 11131 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11132 | config: Config{ |
| 11133 | MaxVersion: VersionTLS13, |
| 11134 | MaxEarlyDataSize: 16384, |
| 11135 | }, |
| 11136 | resumeConfig: &Config{ |
| 11137 | MaxVersion: VersionTLS13, |
| 11138 | MaxEarlyDataSize: 16384, |
| 11139 | Bugs: ProtocolBugs{ |
| 11140 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11141 | }, |
| 11142 | }, |
| 11143 | resumeSession: true, |
| 11144 | flags: []string{ |
| 11145 | "-enable-early-data", |
| 11146 | "-expect-early-data-info", |
| 11147 | "-expect-reject-early-data", |
| 11148 | }, |
| 11149 | }) |
| 11150 | |
| 11151 | // The client must check the server does not send the early_data |
| 11152 | // extension while rejecting the session. |
| 11153 | testCases = append(testCases, testCase{ |
| 11154 | testType: clientTest, |
| 11155 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11156 | config: Config{ |
| 11157 | MaxVersion: VersionTLS13, |
| 11158 | MaxEarlyDataSize: 16384, |
| 11159 | }, |
| 11160 | resumeConfig: &Config{ |
| 11161 | MaxVersion: VersionTLS13, |
| 11162 | SessionTicketsDisabled: true, |
| 11163 | Bugs: ProtocolBugs{ |
| 11164 | SendEarlyDataExtension: true, |
| 11165 | }, |
| 11166 | }, |
| 11167 | resumeSession: true, |
| 11168 | flags: []string{ |
| 11169 | "-enable-early-data", |
| 11170 | "-expect-early-data-info", |
| 11171 | }, |
| 11172 | shouldFail: true, |
| 11173 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11174 | }) |
| 11175 | |
| 11176 | // The client must fail with a dedicated error code if the server |
| 11177 | // responds with TLS 1.2 when offering 0-RTT. |
| 11178 | testCases = append(testCases, testCase{ |
| 11179 | testType: clientTest, |
| 11180 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11181 | config: Config{ |
| 11182 | MaxVersion: VersionTLS13, |
| 11183 | MaxEarlyDataSize: 16384, |
| 11184 | }, |
| 11185 | resumeConfig: &Config{ |
| 11186 | MaxVersion: VersionTLS12, |
| 11187 | }, |
| 11188 | resumeSession: true, |
| 11189 | flags: []string{ |
| 11190 | "-enable-early-data", |
| 11191 | "-expect-early-data-info", |
| 11192 | }, |
| 11193 | shouldFail: true, |
| 11194 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11195 | }) |
| 11196 | |
| 11197 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11198 | // the server sent an HRR. |
| 11199 | testCases = append(testCases, testCase{ |
| 11200 | testType: clientTest, |
| 11201 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11202 | config: Config{ |
| 11203 | MaxVersion: VersionTLS13, |
| 11204 | MaxEarlyDataSize: 16384, |
| 11205 | }, |
| 11206 | resumeConfig: &Config{ |
| 11207 | MaxVersion: VersionTLS13, |
| 11208 | MaxEarlyDataSize: 16384, |
| 11209 | Bugs: ProtocolBugs{ |
| 11210 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11211 | SendEarlyDataExtension: true, |
| 11212 | }, |
| 11213 | }, |
| 11214 | resumeSession: true, |
| 11215 | flags: []string{ |
| 11216 | "-enable-early-data", |
| 11217 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11218 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11219 | }, |
| 11220 | shouldFail: true, |
| 11221 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11222 | }) |
| 11223 | |
| 11224 | fooString := "foo" |
| 11225 | barString := "bar" |
| 11226 | |
| 11227 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11228 | // that changed it. |
| 11229 | testCases = append(testCases, testCase{ |
| 11230 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11231 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11232 | config: Config{ |
| 11233 | MaxVersion: VersionTLS13, |
| 11234 | MaxEarlyDataSize: 16384, |
| 11235 | Bugs: ProtocolBugs{ |
| 11236 | ALPNProtocol: &fooString, |
| 11237 | }, |
| 11238 | }, |
| 11239 | resumeConfig: &Config{ |
| 11240 | MaxVersion: VersionTLS13, |
| 11241 | MaxEarlyDataSize: 16384, |
| 11242 | Bugs: ProtocolBugs{ |
| 11243 | ALPNProtocol: &barString, |
| 11244 | }, |
| 11245 | }, |
| 11246 | resumeSession: true, |
| 11247 | flags: []string{ |
| 11248 | "-advertise-alpn", "\x03foo\x03bar", |
| 11249 | "-enable-early-data", |
| 11250 | "-expect-early-data-info", |
| 11251 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11252 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11253 | "-on-resume-expect-alpn", "foo", |
| 11254 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11255 | }, |
| 11256 | }) |
| 11257 | |
| 11258 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11259 | // ALPN was omitted from the first connection. |
| 11260 | testCases = append(testCases, testCase{ |
| 11261 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11262 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11263 | config: Config{ |
| 11264 | MaxVersion: VersionTLS13, |
| 11265 | MaxEarlyDataSize: 16384, |
| 11266 | }, |
| 11267 | resumeConfig: &Config{ |
| 11268 | MaxVersion: VersionTLS13, |
| 11269 | MaxEarlyDataSize: 16384, |
| 11270 | NextProtos: []string{"foo"}, |
| 11271 | }, |
| 11272 | resumeSession: true, |
| 11273 | flags: []string{ |
| 11274 | "-advertise-alpn", "\x03foo\x03bar", |
| 11275 | "-enable-early-data", |
| 11276 | "-expect-early-data-info", |
| 11277 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11278 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11279 | "-on-resume-expect-alpn", "", |
| 11280 | "-on-retry-expect-alpn", "foo", |
| 11281 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11282 | }, |
| 11283 | }) |
| 11284 | |
| 11285 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11286 | // ALPN was omitted from the second connection. |
| 11287 | testCases = append(testCases, testCase{ |
| 11288 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11289 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11290 | config: Config{ |
| 11291 | MaxVersion: VersionTLS13, |
| 11292 | MaxEarlyDataSize: 16384, |
| 11293 | NextProtos: []string{"foo"}, |
| 11294 | }, |
| 11295 | resumeConfig: &Config{ |
| 11296 | MaxVersion: VersionTLS13, |
| 11297 | MaxEarlyDataSize: 16384, |
| 11298 | }, |
| 11299 | resumeSession: true, |
| 11300 | flags: []string{ |
| 11301 | "-advertise-alpn", "\x03foo\x03bar", |
| 11302 | "-enable-early-data", |
| 11303 | "-expect-early-data-info", |
| 11304 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11305 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11306 | "-on-resume-expect-alpn", "foo", |
| 11307 | "-on-retry-expect-alpn", "", |
| 11308 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11309 | }, |
| 11310 | }) |
| 11311 | |
| 11312 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11313 | testCases = append(testCases, testCase{ |
| 11314 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11315 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11316 | config: Config{ |
| 11317 | MaxVersion: VersionTLS13, |
| 11318 | MaxEarlyDataSize: 16384, |
| 11319 | Bugs: ProtocolBugs{ |
| 11320 | ALPNProtocol: &fooString, |
| 11321 | }, |
| 11322 | }, |
| 11323 | resumeConfig: &Config{ |
| 11324 | MaxVersion: VersionTLS13, |
| 11325 | MaxEarlyDataSize: 16384, |
| 11326 | Bugs: ProtocolBugs{ |
| 11327 | AlwaysAcceptEarlyData: true, |
| 11328 | ALPNProtocol: &barString, |
| 11329 | }, |
| 11330 | }, |
| 11331 | resumeSession: true, |
| 11332 | flags: []string{ |
| 11333 | "-advertise-alpn", "\x03foo\x03bar", |
| 11334 | "-enable-early-data", |
| 11335 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11336 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11337 | "-on-resume-expect-alpn", "foo", |
| 11338 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11339 | }, |
| 11340 | shouldFail: true, |
| 11341 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11342 | }) |
| 11343 | |
| 11344 | // Test that the server correctly rejects 0-RTT when the previous |
| 11345 | // session did not allow early data on resumption. |
| 11346 | testCases = append(testCases, testCase{ |
| 11347 | testType: serverTest, |
| 11348 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11349 | config: Config{ |
| 11350 | MaxVersion: VersionTLS13, |
| 11351 | }, |
| 11352 | resumeConfig: &Config{ |
| 11353 | MaxVersion: VersionTLS13, |
| 11354 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11355 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11356 | ExpectEarlyDataAccepted: false, |
| 11357 | }, |
| 11358 | }, |
| 11359 | resumeSession: true, |
| 11360 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11361 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11362 | "-expect-reject-early-data", |
| 11363 | }, |
| 11364 | }) |
| 11365 | |
| 11366 | // Test that we reject early data where ALPN is omitted from the first |
| 11367 | // connection. |
| 11368 | testCases = append(testCases, testCase{ |
| 11369 | testType: serverTest, |
| 11370 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11371 | config: Config{ |
| 11372 | MaxVersion: VersionTLS13, |
| 11373 | NextProtos: []string{}, |
| 11374 | }, |
| 11375 | resumeConfig: &Config{ |
| 11376 | MaxVersion: VersionTLS13, |
| 11377 | NextProtos: []string{"foo"}, |
| 11378 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11379 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11380 | ExpectEarlyDataAccepted: false, |
| 11381 | }, |
| 11382 | }, |
| 11383 | resumeSession: true, |
| 11384 | flags: []string{ |
| 11385 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11386 | "-on-initial-select-alpn", "", |
| 11387 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11388 | }, |
| 11389 | }) |
| 11390 | |
| 11391 | // Test that we reject early data where ALPN is omitted from the second |
| 11392 | // connection. |
| 11393 | testCases = append(testCases, testCase{ |
| 11394 | testType: serverTest, |
| 11395 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11396 | config: Config{ |
| 11397 | MaxVersion: VersionTLS13, |
| 11398 | NextProtos: []string{"foo"}, |
| 11399 | }, |
| 11400 | resumeConfig: &Config{ |
| 11401 | MaxVersion: VersionTLS13, |
| 11402 | NextProtos: []string{}, |
| 11403 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11404 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11405 | ExpectEarlyDataAccepted: false, |
| 11406 | }, |
| 11407 | }, |
| 11408 | resumeSession: true, |
| 11409 | flags: []string{ |
| 11410 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11411 | "-on-initial-select-alpn", "foo", |
| 11412 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11413 | }, |
| 11414 | }) |
| 11415 | |
| 11416 | // Test that we reject early data with mismatched ALPN. |
| 11417 | testCases = append(testCases, testCase{ |
| 11418 | testType: serverTest, |
| 11419 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11420 | config: Config{ |
| 11421 | MaxVersion: VersionTLS13, |
| 11422 | NextProtos: []string{"foo"}, |
| 11423 | }, |
| 11424 | resumeConfig: &Config{ |
| 11425 | MaxVersion: VersionTLS13, |
| 11426 | NextProtos: []string{"bar"}, |
| 11427 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11428 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11429 | ExpectEarlyDataAccepted: false, |
| 11430 | }, |
| 11431 | }, |
| 11432 | resumeSession: true, |
| 11433 | flags: []string{ |
| 11434 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11435 | "-on-initial-select-alpn", "foo", |
| 11436 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11437 | }, |
| 11438 | }) |
| 11439 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11440 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11441 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11442 | testCases = append(testCases, testCase{ |
| 11443 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11444 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11445 | config: Config{ |
| 11446 | MaxVersion: VersionTLS13, |
| 11447 | MaxEarlyDataSize: 16384, |
| 11448 | RequestChannelID: true, |
| 11449 | }, |
| 11450 | resumeSession: true, |
| 11451 | expectChannelID: true, |
| 11452 | shouldFail: true, |
| 11453 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 11454 | flags: []string{ |
| 11455 | "-enable-early-data", |
| 11456 | "-expect-early-data-info", |
| 11457 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11458 | }, |
| 11459 | }) |
| 11460 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11461 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11462 | // to decline 0-RTT. |
| 11463 | testCases = append(testCases, testCase{ |
| 11464 | testType: clientTest, |
| 11465 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11466 | config: Config{ |
| 11467 | MaxVersion: VersionTLS13, |
| 11468 | MaxEarlyDataSize: 16384, |
| 11469 | RequestChannelID: true, |
| 11470 | Bugs: ProtocolBugs{ |
| 11471 | AlwaysRejectEarlyData: true, |
| 11472 | }, |
| 11473 | }, |
| 11474 | resumeSession: true, |
| 11475 | expectChannelID: true, |
| 11476 | flags: []string{ |
| 11477 | "-enable-early-data", |
| 11478 | "-expect-early-data-info", |
| 11479 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11480 | "-expect-reject-early-data", |
| 11481 | }, |
| 11482 | }) |
| 11483 | |
| 11484 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11485 | // to decline Channel ID. |
| 11486 | testCases = append(testCases, testCase{ |
| 11487 | testType: clientTest, |
| 11488 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11489 | config: Config{ |
| 11490 | MaxVersion: VersionTLS13, |
| 11491 | MaxEarlyDataSize: 16384, |
| 11492 | }, |
| 11493 | resumeSession: true, |
| 11494 | flags: []string{ |
| 11495 | "-enable-early-data", |
| 11496 | "-expect-early-data-info", |
| 11497 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11498 | "-expect-accept-early-data", |
| 11499 | }, |
| 11500 | }) |
| 11501 | |
| 11502 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11503 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11504 | testCases = append(testCases, testCase{ |
| 11505 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11506 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11507 | config: Config{ |
| 11508 | MaxVersion: VersionTLS13, |
| 11509 | ChannelID: channelIDKey, |
| 11510 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11511 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11512 | ExpectEarlyDataAccepted: false, |
| 11513 | }, |
| 11514 | }, |
| 11515 | resumeSession: true, |
| 11516 | expectChannelID: true, |
| 11517 | flags: []string{ |
| 11518 | "-enable-early-data", |
| 11519 | "-expect-reject-early-data", |
| 11520 | "-expect-channel-id", |
| 11521 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11522 | }, |
| 11523 | }) |
| 11524 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11525 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11526 | // if not offered Channel ID. |
| 11527 | testCases = append(testCases, testCase{ |
| 11528 | testType: serverTest, |
| 11529 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11530 | config: Config{ |
| 11531 | MaxVersion: VersionTLS13, |
| 11532 | Bugs: ProtocolBugs{ |
| 11533 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11534 | ExpectEarlyDataAccepted: true, |
| 11535 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11536 | }, |
| 11537 | }, |
| 11538 | resumeSession: true, |
| 11539 | expectChannelID: false, |
| 11540 | flags: []string{ |
| 11541 | "-enable-early-data", |
| 11542 | "-expect-accept-early-data", |
| 11543 | "-enable-channel-id", |
| 11544 | }, |
| 11545 | }) |
| 11546 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11547 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11548 | // The subsequent records should fail to decrypt. |
| 11549 | testCases = append(testCases, testCase{ |
| 11550 | testType: serverTest, |
| 11551 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11552 | config: Config{ |
| 11553 | MaxVersion: VersionTLS13, |
| 11554 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11555 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11556 | ExpectEarlyDataAccepted: true, |
| 11557 | SkipEndOfEarlyData: true, |
| 11558 | }, |
| 11559 | }, |
| 11560 | resumeSession: true, |
| 11561 | flags: []string{"-enable-early-data"}, |
| 11562 | shouldFail: true, |
| 11563 | expectedLocalError: "remote error: bad record MAC", |
| 11564 | expectedError: ":BAD_DECRYPT:", |
| 11565 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11566 | |
| 11567 | testCases = append(testCases, testCase{ |
| 11568 | testType: serverTest, |
| 11569 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11570 | config: Config{ |
| 11571 | MaxVersion: VersionTLS13, |
| 11572 | }, |
| 11573 | resumeConfig: &Config{ |
| 11574 | MaxVersion: VersionTLS13, |
| 11575 | Bugs: ProtocolBugs{ |
| 11576 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11577 | SendStrayEarlyHandshake: true, |
| 11578 | ExpectEarlyDataAccepted: true}, |
| 11579 | }, |
| 11580 | resumeSession: true, |
| 11581 | shouldFail: true, |
| 11582 | expectedError: ":UNEXPECTED_RECORD:", |
| 11583 | expectedLocalError: "remote error: unexpected message", |
| 11584 | flags: []string{ |
| 11585 | "-enable-early-data", |
| 11586 | }, |
| 11587 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11588 | |
| 11589 | // Test that the client reports TLS 1.3 as the version while sending |
| 11590 | // early data. |
| 11591 | testCases = append(testCases, testCase{ |
| 11592 | testType: clientTest, |
| 11593 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11594 | config: Config{ |
| 11595 | MaxVersion: VersionTLS13, |
| 11596 | MaxEarlyDataSize: 16384, |
| 11597 | }, |
| 11598 | resumeSession: true, |
| 11599 | flags: []string{ |
| 11600 | "-enable-early-data", |
| 11601 | "-expect-early-data-info", |
| 11602 | "-expect-accept-early-data", |
| 11603 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11604 | }, |
| 11605 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11606 | } |
| 11607 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11608 | func addTLS13CipherPreferenceTests() { |
| 11609 | // Test that client preference is honored if the shim has AES hardware |
| 11610 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 11611 | testCases = append(testCases, testCase{ |
| 11612 | testType: serverTest, |
| 11613 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 11614 | config: Config{ |
| 11615 | MaxVersion: VersionTLS13, |
| 11616 | CipherSuites: []uint16{ |
| 11617 | TLS_CHACHA20_POLY1305_SHA256, |
| 11618 | TLS_AES_128_GCM_SHA256, |
| 11619 | }, |
| 11620 | }, |
| 11621 | flags: []string{ |
| 11622 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11623 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11624 | }, |
| 11625 | }) |
| 11626 | |
| 11627 | testCases = append(testCases, testCase{ |
| 11628 | testType: serverTest, |
| 11629 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 11630 | config: Config{ |
| 11631 | MaxVersion: VersionTLS13, |
| 11632 | CipherSuites: []uint16{ |
| 11633 | TLS_AES_128_GCM_SHA256, |
| 11634 | TLS_CHACHA20_POLY1305_SHA256, |
| 11635 | }, |
| 11636 | }, |
| 11637 | flags: []string{ |
| 11638 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11639 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11640 | }, |
| 11641 | }) |
| 11642 | |
| 11643 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 11644 | // whether it has AES hardware. |
| 11645 | testCases = append(testCases, testCase{ |
| 11646 | name: "TLS13-CipherPreference-Client", |
| 11647 | config: Config{ |
| 11648 | MaxVersion: VersionTLS13, |
| 11649 | // Use the client cipher order. (This is the default but |
| 11650 | // is listed to be explicit.) |
| 11651 | PreferServerCipherSuites: false, |
| 11652 | }, |
| 11653 | flags: []string{ |
| 11654 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11655 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11656 | }, |
| 11657 | }) |
| 11658 | } |
| 11659 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11660 | func addPeekTests() { |
| 11661 | // Test SSL_peek works, including on empty records. |
| 11662 | testCases = append(testCases, testCase{ |
| 11663 | name: "Peek-Basic", |
| 11664 | sendEmptyRecords: 1, |
| 11665 | flags: []string{"-peek-then-read"}, |
| 11666 | }) |
| 11667 | |
| 11668 | // Test SSL_peek can drive the initial handshake. |
| 11669 | testCases = append(testCases, testCase{ |
| 11670 | name: "Peek-ImplicitHandshake", |
| 11671 | flags: []string{ |
| 11672 | "-peek-then-read", |
| 11673 | "-implicit-handshake", |
| 11674 | }, |
| 11675 | }) |
| 11676 | |
| 11677 | // Test SSL_peek can discover and drive a renegotiation. |
| 11678 | testCases = append(testCases, testCase{ |
| 11679 | name: "Peek-Renegotiate", |
| 11680 | config: Config{ |
| 11681 | MaxVersion: VersionTLS12, |
| 11682 | }, |
| 11683 | renegotiate: 1, |
| 11684 | flags: []string{ |
| 11685 | "-peek-then-read", |
| 11686 | "-renegotiate-freely", |
| 11687 | "-expect-total-renegotiations", "1", |
| 11688 | }, |
| 11689 | }) |
| 11690 | |
| 11691 | // Test SSL_peek can discover a close_notify. |
| 11692 | testCases = append(testCases, testCase{ |
| 11693 | name: "Peek-Shutdown", |
| 11694 | config: Config{ |
| 11695 | Bugs: ProtocolBugs{ |
| 11696 | ExpectCloseNotify: true, |
| 11697 | }, |
| 11698 | }, |
| 11699 | flags: []string{ |
| 11700 | "-peek-then-read", |
| 11701 | "-check-close-notify", |
| 11702 | }, |
| 11703 | }) |
| 11704 | |
| 11705 | // Test SSL_peek can discover an alert. |
| 11706 | testCases = append(testCases, testCase{ |
| 11707 | name: "Peek-Alert", |
| 11708 | config: Config{ |
| 11709 | Bugs: ProtocolBugs{ |
| 11710 | SendSpuriousAlert: alertRecordOverflow, |
| 11711 | }, |
| 11712 | }, |
| 11713 | flags: []string{"-peek-then-read"}, |
| 11714 | shouldFail: true, |
| 11715 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 11716 | }) |
| 11717 | |
| 11718 | // Test SSL_peek can handle KeyUpdate. |
| 11719 | testCases = append(testCases, testCase{ |
| 11720 | name: "Peek-KeyUpdate", |
| 11721 | config: Config{ |
| 11722 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11723 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 11724 | sendKeyUpdates: 1, |
| 11725 | keyUpdateRequest: keyUpdateNotRequested, |
| 11726 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11727 | }) |
| 11728 | } |
| 11729 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11730 | func addRecordVersionTests() { |
| 11731 | for _, ver := range tlsVersions { |
| 11732 | // Test that the record version is enforced. |
| 11733 | testCases = append(testCases, testCase{ |
| 11734 | name: "CheckRecordVersion-" + ver.name, |
| 11735 | config: Config{ |
| 11736 | MinVersion: ver.version, |
| 11737 | MaxVersion: ver.version, |
| 11738 | Bugs: ProtocolBugs{ |
| 11739 | SendRecordVersion: 0x03ff, |
| 11740 | }, |
| 11741 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11742 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11743 | shouldFail: true, |
| 11744 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11745 | }) |
| 11746 | |
| 11747 | // Test that the ClientHello may use any record version, for |
| 11748 | // compatibility reasons. |
| 11749 | testCases = append(testCases, testCase{ |
| 11750 | testType: serverTest, |
| 11751 | name: "LooseInitialRecordVersion-" + ver.name, |
| 11752 | config: Config{ |
| 11753 | MinVersion: ver.version, |
| 11754 | MaxVersion: ver.version, |
| 11755 | Bugs: ProtocolBugs{ |
| 11756 | SendInitialRecordVersion: 0x03ff, |
| 11757 | }, |
| 11758 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11759 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11760 | }) |
| 11761 | |
| 11762 | // Test that garbage ClientHello record versions are rejected. |
| 11763 | testCases = append(testCases, testCase{ |
| 11764 | testType: serverTest, |
| 11765 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 11766 | config: Config{ |
| 11767 | MinVersion: ver.version, |
| 11768 | MaxVersion: ver.version, |
| 11769 | Bugs: ProtocolBugs{ |
| 11770 | SendInitialRecordVersion: 0xffff, |
| 11771 | }, |
| 11772 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11773 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11774 | shouldFail: true, |
| 11775 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11776 | }) |
| 11777 | } |
| 11778 | } |
| 11779 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11780 | func addCertificateTests() { |
| 11781 | // Test that a certificate chain with intermediate may be sent and |
| 11782 | // received as both client and server. |
| 11783 | for _, ver := range tlsVersions { |
| 11784 | testCases = append(testCases, testCase{ |
| 11785 | testType: clientTest, |
| 11786 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 11787 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11788 | MinVersion: ver.version, |
| 11789 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11790 | Certificates: []Certificate{rsaChainCertificate}, |
| 11791 | ClientAuth: RequireAnyClientCert, |
| 11792 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11793 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11794 | expectPeerCertificate: &rsaChainCertificate, |
| 11795 | flags: []string{ |
| 11796 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11797 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11798 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11799 | }, |
| 11800 | }) |
| 11801 | |
| 11802 | testCases = append(testCases, testCase{ |
| 11803 | testType: serverTest, |
| 11804 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 11805 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11806 | MinVersion: ver.version, |
| 11807 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11808 | Certificates: []Certificate{rsaChainCertificate}, |
| 11809 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11810 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11811 | expectPeerCertificate: &rsaChainCertificate, |
| 11812 | flags: []string{ |
| 11813 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11814 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11815 | "-require-any-client-certificate", |
| 11816 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11817 | }, |
| 11818 | }) |
| 11819 | } |
| 11820 | } |
| 11821 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11822 | func addRetainOnlySHA256ClientCertTests() { |
| 11823 | for _, ver := range tlsVersions { |
| 11824 | // Test that enabling |
| 11825 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 11826 | // actually requesting a client certificate is a no-op. |
| 11827 | testCases = append(testCases, testCase{ |
| 11828 | testType: serverTest, |
| 11829 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 11830 | config: Config{ |
| 11831 | MinVersion: ver.version, |
| 11832 | MaxVersion: ver.version, |
| 11833 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11834 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11835 | flags: []string{ |
| 11836 | "-retain-only-sha256-client-cert-initial", |
| 11837 | "-retain-only-sha256-client-cert-resume", |
| 11838 | }, |
| 11839 | resumeSession: true, |
| 11840 | }) |
| 11841 | |
| 11842 | // Test that when retaining only a SHA-256 certificate is |
| 11843 | // enabled, the hash appears as expected. |
| 11844 | testCases = append(testCases, testCase{ |
| 11845 | testType: serverTest, |
| 11846 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 11847 | config: Config{ |
| 11848 | MinVersion: ver.version, |
| 11849 | MaxVersion: ver.version, |
| 11850 | Certificates: []Certificate{rsaCertificate}, |
| 11851 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11852 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11853 | flags: []string{ |
| 11854 | "-verify-peer", |
| 11855 | "-retain-only-sha256-client-cert-initial", |
| 11856 | "-retain-only-sha256-client-cert-resume", |
| 11857 | "-expect-sha256-client-cert-initial", |
| 11858 | "-expect-sha256-client-cert-resume", |
| 11859 | }, |
| 11860 | resumeSession: true, |
| 11861 | }) |
| 11862 | |
| 11863 | // Test that when the config changes from on to off, a |
| 11864 | // resumption is rejected because the server now wants the full |
| 11865 | // certificate chain. |
| 11866 | testCases = append(testCases, testCase{ |
| 11867 | testType: serverTest, |
| 11868 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 11869 | config: Config{ |
| 11870 | MinVersion: ver.version, |
| 11871 | MaxVersion: ver.version, |
| 11872 | Certificates: []Certificate{rsaCertificate}, |
| 11873 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11874 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11875 | flags: []string{ |
| 11876 | "-verify-peer", |
| 11877 | "-retain-only-sha256-client-cert-initial", |
| 11878 | "-expect-sha256-client-cert-initial", |
| 11879 | }, |
| 11880 | resumeSession: true, |
| 11881 | expectResumeRejected: true, |
| 11882 | }) |
| 11883 | |
| 11884 | // Test that when the config changes from off to on, a |
| 11885 | // resumption is rejected because the server now wants just the |
| 11886 | // hash. |
| 11887 | testCases = append(testCases, testCase{ |
| 11888 | testType: serverTest, |
| 11889 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 11890 | config: Config{ |
| 11891 | MinVersion: ver.version, |
| 11892 | MaxVersion: ver.version, |
| 11893 | Certificates: []Certificate{rsaCertificate}, |
| 11894 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11895 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11896 | flags: []string{ |
| 11897 | "-verify-peer", |
| 11898 | "-retain-only-sha256-client-cert-resume", |
| 11899 | "-expect-sha256-client-cert-resume", |
| 11900 | }, |
| 11901 | resumeSession: true, |
| 11902 | expectResumeRejected: true, |
| 11903 | }) |
| 11904 | } |
| 11905 | } |
| 11906 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 11907 | func addECDSAKeyUsageTests() { |
| 11908 | p256 := elliptic.P256() |
| 11909 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 11910 | if err != nil { |
| 11911 | panic(err) |
| 11912 | } |
| 11913 | |
| 11914 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 11915 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 11916 | if err != nil { |
| 11917 | panic(err) |
| 11918 | } |
| 11919 | |
| 11920 | template := x509.Certificate{ |
| 11921 | SerialNumber: serialNumber, |
| 11922 | Subject: pkix.Name{ |
| 11923 | Organization: []string{"Acme Co"}, |
| 11924 | }, |
| 11925 | NotBefore: time.Now(), |
| 11926 | NotAfter: time.Now(), |
| 11927 | |
| 11928 | // An ECC certificate with only the keyAgreement key usgae may |
| 11929 | // be used with ECDH, but not ECDSA. |
| 11930 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 11931 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 11932 | BasicConstraintsValid: true, |
| 11933 | } |
| 11934 | |
| 11935 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 11936 | if err != nil { |
| 11937 | panic(err) |
| 11938 | } |
| 11939 | |
| 11940 | cert := Certificate{ |
| 11941 | Certificate: [][]byte{derBytes}, |
| 11942 | PrivateKey: priv, |
| 11943 | } |
| 11944 | |
| 11945 | for _, ver := range tlsVersions { |
| 11946 | if ver.version < VersionTLS12 { |
| 11947 | continue |
| 11948 | } |
| 11949 | |
| 11950 | testCases = append(testCases, testCase{ |
| 11951 | testType: clientTest, |
| 11952 | name: "ECDSAKeyUsage-" + ver.name, |
| 11953 | config: Config{ |
| 11954 | MinVersion: ver.version, |
| 11955 | MaxVersion: ver.version, |
| 11956 | Certificates: []Certificate{cert}, |
| 11957 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11958 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 11959 | shouldFail: true, |
| 11960 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 11961 | }) |
| 11962 | } |
| 11963 | } |
| 11964 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 11965 | func addExtraHandshakeTests() { |
| 11966 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 11967 | // to ensure there is no transport I/O. |
| 11968 | testCases = append(testCases, testCase{ |
| 11969 | testType: clientTest, |
| 11970 | name: "ExtraHandshake-Client-TLS12", |
| 11971 | config: Config{ |
| 11972 | MinVersion: VersionTLS12, |
| 11973 | MaxVersion: VersionTLS12, |
| 11974 | }, |
| 11975 | flags: []string{ |
| 11976 | "-async", |
| 11977 | "-no-op-extra-handshake", |
| 11978 | }, |
| 11979 | }) |
| 11980 | testCases = append(testCases, testCase{ |
| 11981 | testType: serverTest, |
| 11982 | name: "ExtraHandshake-Server-TLS12", |
| 11983 | config: Config{ |
| 11984 | MinVersion: VersionTLS12, |
| 11985 | MaxVersion: VersionTLS12, |
| 11986 | }, |
| 11987 | flags: []string{ |
| 11988 | "-async", |
| 11989 | "-no-op-extra-handshake", |
| 11990 | }, |
| 11991 | }) |
| 11992 | testCases = append(testCases, testCase{ |
| 11993 | testType: clientTest, |
| 11994 | name: "ExtraHandshake-Client-TLS13", |
| 11995 | config: Config{ |
| 11996 | MinVersion: VersionTLS13, |
| 11997 | MaxVersion: VersionTLS13, |
| 11998 | }, |
| 11999 | flags: []string{ |
| 12000 | "-async", |
| 12001 | "-no-op-extra-handshake", |
| 12002 | }, |
| 12003 | }) |
| 12004 | testCases = append(testCases, testCase{ |
| 12005 | testType: serverTest, |
| 12006 | name: "ExtraHandshake-Server-TLS13", |
| 12007 | config: Config{ |
| 12008 | MinVersion: VersionTLS13, |
| 12009 | MaxVersion: VersionTLS13, |
| 12010 | }, |
| 12011 | flags: []string{ |
| 12012 | "-async", |
| 12013 | "-no-op-extra-handshake", |
| 12014 | }, |
| 12015 | }) |
| 12016 | |
| 12017 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12018 | testCases = append(testCases, testCase{ |
| 12019 | testType: serverTest, |
| 12020 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12021 | config: Config{ |
| 12022 | MaxVersion: VersionTLS13, |
| 12023 | MinVersion: VersionTLS13, |
| 12024 | Bugs: ProtocolBugs{ |
| 12025 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12026 | ExpectEarlyDataAccepted: true, |
| 12027 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12028 | }, |
| 12029 | }, |
| 12030 | messageCount: 2, |
| 12031 | resumeSession: true, |
| 12032 | flags: []string{ |
| 12033 | "-async", |
| 12034 | "-enable-early-data", |
| 12035 | "-expect-accept-early-data", |
| 12036 | "-no-op-extra-handshake", |
| 12037 | }, |
| 12038 | }) |
| 12039 | |
| 12040 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12041 | // Start. We test this by handshaking twice and asserting the False |
| 12042 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12043 | // how the test works. |
| 12044 | testCases = append(testCases, testCase{ |
| 12045 | testType: clientTest, |
| 12046 | name: "ExtraHandshake-FalseStart", |
| 12047 | config: Config{ |
| 12048 | MaxVersion: VersionTLS12, |
| 12049 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12050 | NextProtos: []string{"foo"}, |
| 12051 | Bugs: ProtocolBugs{ |
| 12052 | ExpectFalseStart: true, |
| 12053 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12054 | }, |
| 12055 | }, |
| 12056 | flags: []string{ |
| 12057 | "-handshake-twice", |
| 12058 | "-false-start", |
| 12059 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12060 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12061 | }, |
| 12062 | shimWritesFirst: true, |
| 12063 | shouldFail: true, |
| 12064 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12065 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12066 | }) |
| 12067 | } |
| 12068 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12069 | 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] | 12070 | defer wg.Done() |
| 12071 | |
| 12072 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12073 | var err error |
| 12074 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12075 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12076 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12077 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12078 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12079 | if err != nil { |
| 12080 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12081 | } |
| 12082 | break |
| 12083 | } |
| 12084 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12085 | } else if *repeatUntilFailure { |
| 12086 | for err == nil { |
| 12087 | statusChan <- statusMsg{test: test, started: true} |
| 12088 | err = runTest(test, shimPath, -1) |
| 12089 | } |
| 12090 | } else { |
| 12091 | statusChan <- statusMsg{test: test, started: true} |
| 12092 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12093 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12094 | statusChan <- statusMsg{test: test, err: err} |
| 12095 | } |
| 12096 | } |
| 12097 | |
| 12098 | type statusMsg struct { |
| 12099 | test *testCase |
| 12100 | started bool |
| 12101 | err error |
| 12102 | } |
| 12103 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12104 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12105 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12106 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12107 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12108 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12109 | if !*pipe { |
| 12110 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12111 | var erase string |
| 12112 | for i := 0; i < lineLen; i++ { |
| 12113 | erase += "\b \b" |
| 12114 | } |
| 12115 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12116 | } |
| 12117 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12118 | if msg.started { |
| 12119 | started++ |
| 12120 | } else { |
| 12121 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12122 | |
| 12123 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12124 | if msg.err == errUnimplemented { |
| 12125 | if *pipe { |
| 12126 | // Print each test instead of a status line. |
| 12127 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12128 | } |
| 12129 | unimplemented++ |
| 12130 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12131 | } else { |
| 12132 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12133 | failed++ |
| 12134 | testOutput.addResult(msg.test.name, "FAIL") |
| 12135 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12136 | } else { |
| 12137 | if *pipe { |
| 12138 | // Print each test instead of a status line. |
| 12139 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12140 | } |
| 12141 | testOutput.addResult(msg.test.name, "PASS") |
| 12142 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12143 | } |
| 12144 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12145 | if !*pipe { |
| 12146 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12147 | 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] | 12148 | lineLen = len(line) |
| 12149 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12150 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12151 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12152 | |
| 12153 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12154 | } |
| 12155 | |
| 12156 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12157 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12158 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12159 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12160 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12161 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12162 | addCipherSuiteTests() |
| 12163 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12164 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12165 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12166 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12167 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12168 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12169 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12170 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12171 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12172 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12173 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12174 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12175 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12176 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12177 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12178 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12179 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12180 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12181 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12182 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12183 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12184 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12185 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12186 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12187 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12188 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12189 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12190 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12191 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12192 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12193 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12194 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12195 | addExtraHandshakeTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12196 | |
| 12197 | var wg sync.WaitGroup |
| 12198 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12199 | statusChan := make(chan statusMsg, *numWorkers) |
| 12200 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12201 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12202 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12203 | if len(*shimConfigFile) != 0 { |
| 12204 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12205 | if err != nil { |
| 12206 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12207 | os.Exit(1) |
| 12208 | } |
| 12209 | |
| 12210 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12211 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12212 | os.Exit(1) |
| 12213 | } |
| 12214 | } |
| 12215 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12216 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12217 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12218 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12219 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12220 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12221 | } |
| 12222 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12223 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12224 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12225 | matched := true |
| 12226 | if len(*testToRun) != 0 { |
| 12227 | var err error |
| 12228 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12229 | if err != nil { |
| 12230 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12231 | os.Exit(1) |
| 12232 | } |
| 12233 | } |
| 12234 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12235 | if !*includeDisabled { |
| 12236 | for pattern := range shimConfig.DisabledTests { |
| 12237 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12238 | if err != nil { |
| 12239 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12240 | os.Exit(1) |
| 12241 | } |
| 12242 | |
| 12243 | if isDisabled { |
| 12244 | matched = false |
| 12245 | break |
| 12246 | } |
| 12247 | } |
| 12248 | } |
| 12249 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12250 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12251 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12252 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12253 | |
| 12254 | // Only run one test if repeating until failure. |
| 12255 | if *repeatUntilFailure { |
| 12256 | break |
| 12257 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12258 | } |
| 12259 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12260 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12261 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12262 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12263 | os.Exit(1) |
| 12264 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12265 | |
| 12266 | close(testChan) |
| 12267 | wg.Wait() |
| 12268 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12269 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12270 | |
| 12271 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12272 | |
| 12273 | if *jsonOutput != "" { |
| 12274 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12275 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12276 | } |
| 12277 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12278 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12279 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12280 | os.Exit(1) |
| 12281 | } |
| 12282 | |
| 12283 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12284 | os.Exit(1) |
| 12285 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12286 | } |