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) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 491 | if !*useGDB { |
| 492 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 493 | return 0, err |
| 494 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 495 | } |
| 496 | return t.Conn.Read(b) |
| 497 | } |
| 498 | |
| 499 | func (t *timeoutConn) Write(b []byte) (int, error) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 500 | if !*useGDB { |
| 501 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 502 | return 0, err |
| 503 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 504 | } |
| 505 | return t.Conn.Write(b) |
| 506 | } |
| 507 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 508 | 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] | 509 | if !test.noSessionCache { |
| 510 | if config.ClientSessionCache == nil { |
| 511 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 512 | } |
| 513 | if config.ServerSessionCache == nil { |
| 514 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 515 | } |
| 516 | } |
| 517 | if test.testType == clientTest { |
| 518 | if len(config.Certificates) == 0 { |
| 519 | config.Certificates = []Certificate{rsaCertificate} |
| 520 | } |
| 521 | } else { |
| 522 | // Supply a ServerName to ensure a constant session cache key, |
| 523 | // rather than falling back to net.Conn.RemoteAddr. |
| 524 | if len(config.ServerName) == 0 { |
| 525 | config.ServerName = "test" |
| 526 | } |
| 527 | } |
| 528 | if *fuzzer { |
| 529 | config.Bugs.NullAllCiphers = true |
| 530 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 531 | if *deterministic { |
| 532 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 533 | } |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 534 | if test.tls13Variant != 0 { |
| 535 | config.TLS13Variant = test.tls13Variant |
| 536 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 537 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 538 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 539 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 540 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 541 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 542 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 543 | } |
| 544 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 545 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 546 | local, peer := "client", "server" |
| 547 | if test.testType == clientTest { |
| 548 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 549 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 550 | connDebug := &recordingConn{ |
| 551 | Conn: conn, |
| 552 | isDatagram: test.protocol == dtls, |
| 553 | local: local, |
| 554 | peer: peer, |
| 555 | } |
| 556 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 557 | if *flagDebug { |
| 558 | defer connDebug.WriteTo(os.Stdout) |
| 559 | } |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 560 | if len(transcriptPrefix) != 0 { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 561 | defer func() { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 562 | path := transcriptPrefix + strconv.Itoa(num) |
| 563 | writeTranscript(test, path, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 564 | }() |
| 565 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 566 | |
| 567 | if config.Bugs.PacketAdaptor != nil { |
| 568 | config.Bugs.PacketAdaptor.debug = connDebug |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | if test.replayWrites { |
| 573 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 574 | } |
| 575 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 576 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 577 | if test.damageFirstWrite { |
| 578 | connDamage = newDamageAdaptor(conn) |
| 579 | conn = connDamage |
| 580 | } |
| 581 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 582 | if test.sendPrefix != "" { |
| 583 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 584 | return err |
| 585 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 586 | } |
| 587 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 588 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 589 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 590 | if test.protocol == dtls { |
| 591 | tlsConn = DTLSServer(conn, config) |
| 592 | } else { |
| 593 | tlsConn = Server(conn, config) |
| 594 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 595 | } else { |
| 596 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 597 | if test.protocol == dtls { |
| 598 | tlsConn = DTLSClient(conn, config) |
| 599 | } else { |
| 600 | tlsConn = Client(conn, config) |
| 601 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 602 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 603 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 604 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 605 | if err := tlsConn.Handshake(); err != nil { |
| 606 | return err |
| 607 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 608 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 609 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 610 | // expectations struct that can be specified separately for the two |
| 611 | // legs. |
| 612 | expectedVersion := test.expectedVersion |
| 613 | if isResume && test.expectedResumeVersion != 0 { |
| 614 | expectedVersion = test.expectedResumeVersion |
| 615 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 616 | connState := tlsConn.ConnectionState() |
| 617 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 618 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 619 | } |
| 620 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 621 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 622 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 623 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 624 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 625 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 626 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 627 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 628 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 629 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 630 | if channelID == nil { |
| 631 | return fmt.Errorf("no channel ID negotiated") |
| 632 | } |
| 633 | if channelID.Curve != channelIDKey.Curve || |
| 634 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 635 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 636 | return fmt.Errorf("incorrect channel ID") |
| 637 | } |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 638 | } else if connState.ChannelID != nil { |
| 639 | return fmt.Errorf("channel ID unexpectedly negotiated") |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 640 | } |
| 641 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 642 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 643 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 644 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 645 | } |
| 646 | } |
| 647 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 648 | if test.expectNoNextProto { |
| 649 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 650 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 651 | } |
| 652 | } |
| 653 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 654 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 655 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 656 | return fmt.Errorf("next proto type mismatch") |
| 657 | } |
| 658 | } |
| 659 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 660 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 661 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 662 | } |
| 663 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 664 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 665 | 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] | 666 | } |
| 667 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 668 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 669 | return fmt.Errorf("SCT list mismatch") |
| 670 | } |
| 671 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 672 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 673 | 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] | 674 | } |
| 675 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 676 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 677 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 678 | } |
| 679 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 680 | if test.expectPeerCertificate != nil { |
| 681 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 682 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 683 | } |
| 684 | for i, cert := range connState.PeerCertificates { |
| 685 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 686 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 691 | if test.exportKeyingMaterial > 0 { |
| 692 | actual := make([]byte, test.exportKeyingMaterial) |
| 693 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 694 | return err |
| 695 | } |
| 696 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 697 | if err != nil { |
| 698 | return err |
| 699 | } |
| 700 | if !bytes.Equal(actual, expected) { |
| 701 | return fmt.Errorf("keying material mismatch") |
| 702 | } |
| 703 | } |
| 704 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 705 | if test.testTLSUnique { |
| 706 | var peersValue [12]byte |
| 707 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 708 | return err |
| 709 | } |
| 710 | expected := tlsConn.ConnectionState().TLSUnique |
| 711 | if !bytes.Equal(peersValue[:], expected) { |
| 712 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 713 | } |
| 714 | } |
| 715 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 716 | if test.sendHalfHelloRequest { |
| 717 | tlsConn.SendHalfHelloRequest() |
| 718 | } |
| 719 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 720 | shimPrefix := test.shimPrefix |
| 721 | if isResume { |
| 722 | shimPrefix = test.resumeShimPrefix |
| 723 | } |
| 724 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 725 | shimPrefix = "hello" |
| 726 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 727 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 728 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 729 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 730 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 731 | var buf = make([]byte, len(shimPrefix)) |
| 732 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 733 | if err != nil { |
| 734 | return err |
| 735 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 736 | if string(buf) != shimPrefix { |
| 737 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 738 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 739 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 740 | } |
| 741 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 742 | if test.renegotiateCiphers != nil { |
| 743 | config.CipherSuites = test.renegotiateCiphers |
| 744 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 745 | for i := 0; i < test.renegotiate; i++ { |
| 746 | if err := tlsConn.Renegotiate(); err != nil { |
| 747 | return err |
| 748 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 749 | } |
| 750 | } else if test.renegotiateCiphers != nil { |
| 751 | panic("renegotiateCiphers without renegotiate") |
| 752 | } |
| 753 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 754 | if test.damageFirstWrite { |
| 755 | connDamage.setDamage(true) |
| 756 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 757 | connDamage.setDamage(false) |
| 758 | } |
| 759 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 760 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 761 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 762 | if test.protocol == dtls { |
| 763 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 764 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 765 | // Read until EOF. |
| 766 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 767 | return err |
| 768 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 769 | if messageLen == 0 { |
| 770 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 771 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 773 | messageCount := test.messageCount |
| 774 | if messageCount == 0 { |
| 775 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 776 | } |
| 777 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 778 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 779 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 780 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 781 | } |
| 782 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 783 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 784 | tlsConn.Write(nil) |
| 785 | } |
| 786 | |
| 787 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 788 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 789 | } |
| 790 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 791 | if test.sendBogusAlertType { |
| 792 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 793 | } |
| 794 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 795 | testMessage := make([]byte, messageLen) |
| 796 | for i := range testMessage { |
| 797 | testMessage[i] = 0x42 ^ byte(j) |
| 798 | } |
| 799 | tlsConn.Write(testMessage) |
| 800 | |
| 801 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 802 | if shimPrefix != "" { |
| 803 | var buf = make([]byte, len(shimPrefix)) |
| 804 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 805 | if err != nil { |
| 806 | return err |
| 807 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 808 | if string(buf) != shimPrefix { |
| 809 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 810 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 811 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 812 | } |
| 813 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 814 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 815 | // The shim will not respond. |
| 816 | continue |
| 817 | } |
| 818 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 819 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 820 | // sends, the shim should respond only once. |
| 821 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 822 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 823 | return err |
| 824 | } |
| 825 | } |
| 826 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 827 | buf := make([]byte, len(testMessage)) |
| 828 | if test.protocol == dtls { |
| 829 | bufTmp := make([]byte, len(buf)+1) |
| 830 | n, err := tlsConn.Read(bufTmp) |
| 831 | if err != nil { |
| 832 | return err |
| 833 | } |
| 834 | if n != len(buf) { |
| 835 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 836 | } |
| 837 | copy(buf, bufTmp) |
| 838 | } else { |
| 839 | _, err := io.ReadFull(tlsConn, buf) |
| 840 | if err != nil { |
| 841 | return err |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | for i, v := range buf { |
| 846 | if v != testMessage[i]^0xff { |
| 847 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 848 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | |
| 852 | return nil |
| 853 | } |
| 854 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 855 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 856 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 857 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 858 | 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] | 859 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 860 | valgrindArgs = append(valgrindArgs, path) |
| 861 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 862 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 863 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 864 | } |
| 865 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 866 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 867 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 868 | xtermArgs = append(xtermArgs, path) |
| 869 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 870 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 871 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 872 | } |
| 873 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 874 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 875 | xtermArgs := []string{"-e", "lldb", "--"} |
| 876 | xtermArgs = append(xtermArgs, path) |
| 877 | xtermArgs = append(xtermArgs, args...) |
| 878 | |
| 879 | return exec.Command("xterm", xtermArgs...) |
| 880 | } |
| 881 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 882 | var ( |
| 883 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 884 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 885 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 886 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 887 | // accept accepts a connection from listener, unless waitChan signals a process |
| 888 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 889 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 890 | type connOrError struct { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 891 | conn net.Conn |
| 892 | err error |
| 893 | startTime, endTime time.Time |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 894 | } |
| 895 | connChan := make(chan connOrError, 1) |
| 896 | go func() { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 897 | startTime := time.Now() |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 898 | if !*useGDB { |
| 899 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
| 900 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 901 | conn, err := listener.Accept() |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 902 | endTime := time.Now() |
| 903 | connChan <- connOrError{conn, err, startTime, endTime} |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 904 | close(connChan) |
| 905 | }() |
| 906 | select { |
| 907 | case result := <-connChan: |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 908 | if result.err != nil { |
| 909 | // TODO(davidben): Remove this logging when |
| 910 | // https://crbug.com/boringssl/199 is resolved. |
| 911 | fmt.Fprintf(os.Stderr, "acceptOrWait failed, startTime=%v, endTime=%v\n", result.startTime, result.endTime) |
| 912 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 913 | return result.conn, result.err |
| 914 | case childErr := <-waitChan: |
| 915 | waitChan <- childErr |
| 916 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 917 | } |
| 918 | } |
| 919 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 920 | func translateExpectedError(errorStr string) string { |
| 921 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 922 | return translated |
| 923 | } |
| 924 | |
| 925 | if *looseErrors { |
| 926 | return "" |
| 927 | } |
| 928 | |
| 929 | return errorStr |
| 930 | } |
| 931 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 932 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 933 | // Help debugging panics on the Go side. |
| 934 | defer func() { |
| 935 | if r := recover(); r != nil { |
| 936 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 937 | panic(r) |
| 938 | } |
| 939 | }() |
| 940 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 941 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 942 | panic("Error expected without shouldFail in " + test.name) |
| 943 | } |
| 944 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 945 | if test.expectResumeRejected && !test.resumeSession { |
| 946 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 947 | } |
| 948 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 949 | for _, ver := range tlsVersions { |
| 950 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 951 | continue |
| 952 | } |
| 953 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 954 | if test.config.MaxVersion == 0 && test.config.MinVersion == 0 && test.expectedVersion == 0 { |
| 955 | 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] | 956 | } |
| 957 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 958 | if ver.tls13Variant != 0 { |
| 959 | var foundFlag bool |
| 960 | for _, flag := range test.flags { |
| 961 | if flag == "-tls13-variant" { |
| 962 | foundFlag = true |
| 963 | break |
| 964 | } |
| 965 | } |
| 966 | if !foundFlag && test.config.TLS13Variant != ver.tls13Variant && test.tls13Variant != ver.tls13Variant { |
| 967 | 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)) |
| 968 | } |
| 969 | } |
| 970 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 971 | } |
| 972 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 973 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 974 | if err != nil { |
| 975 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 976 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 977 | if err != nil { |
| 978 | panic(err) |
| 979 | } |
| 980 | defer func() { |
| 981 | if listener != nil { |
| 982 | listener.Close() |
| 983 | } |
| 984 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 985 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 986 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 987 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 988 | flags = append(flags, "-server") |
| 989 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 990 | flags = append(flags, "-key-file") |
| 991 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 992 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 993 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 994 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | flags = append(flags, "-cert-file") |
| 998 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 999 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1000 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1001 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1002 | } |
| 1003 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1004 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 1005 | if test.protocol == dtls { |
| 1006 | flags = append(flags, "-dtls") |
| 1007 | } |
| 1008 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1009 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1010 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1011 | resumeCount++ |
| 1012 | if test.resumeRenewedSession { |
| 1013 | resumeCount++ |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | if resumeCount > 0 { |
| 1018 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1019 | } |
| 1020 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 1021 | if test.shimWritesFirst { |
| 1022 | flags = append(flags, "-shim-writes-first") |
| 1023 | } |
| 1024 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 1025 | if test.readWithUnfinishedWrite { |
| 1026 | flags = append(flags, "-read-with-unfinished-write") |
| 1027 | } |
| 1028 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1029 | if test.shimShutsDown { |
| 1030 | flags = append(flags, "-shim-shuts-down") |
| 1031 | } |
| 1032 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1033 | if test.exportKeyingMaterial > 0 { |
| 1034 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 1035 | flags = append(flags, "-export-label", test.exportLabel) |
| 1036 | flags = append(flags, "-export-context", test.exportContext) |
| 1037 | if test.useExportContext { |
| 1038 | flags = append(flags, "-use-export-context") |
| 1039 | } |
| 1040 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 1041 | if test.expectResumeRejected { |
| 1042 | flags = append(flags, "-expect-session-miss") |
| 1043 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1044 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 1045 | if test.testTLSUnique { |
| 1046 | flags = append(flags, "-tls-unique") |
| 1047 | } |
| 1048 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1049 | if test.tls13Variant != 0 { |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1050 | flags = append(flags, "-tls13-variant", strconv.Itoa(test.tls13Variant)) |
| 1051 | } |
| 1052 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1053 | var transcriptPrefix string |
| 1054 | if len(*transcriptDir) != 0 { |
| 1055 | protocol := "tls" |
| 1056 | if test.protocol == dtls { |
| 1057 | protocol = "dtls" |
| 1058 | } |
| 1059 | |
| 1060 | side := "client" |
| 1061 | if test.testType == serverTest { |
| 1062 | side = "server" |
| 1063 | } |
| 1064 | |
| 1065 | dir := filepath.Join(*transcriptDir, protocol, side) |
| 1066 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 1067 | return err |
| 1068 | } |
| 1069 | transcriptPrefix = filepath.Join(dir, test.name+"-") |
| 1070 | flags = append(flags, "-write-settings", transcriptPrefix) |
| 1071 | } |
| 1072 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1073 | flags = append(flags, test.flags...) |
| 1074 | |
| 1075 | var shim *exec.Cmd |
| 1076 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1077 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1078 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1079 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1080 | } else if *useLLDB { |
| 1081 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1082 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1083 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1084 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1085 | shim.Stdin = os.Stdin |
| 1086 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1087 | shim.Stdout = &stdoutBuf |
| 1088 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1089 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1090 | shim.Env = os.Environ() |
| 1091 | 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] | 1092 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1093 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1094 | } |
| 1095 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1096 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1097 | |
| 1098 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | panic(err) |
| 1100 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1101 | waitChan := make(chan error, 1) |
| 1102 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1103 | |
| 1104 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1105 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1106 | if *deterministic { |
| 1107 | config.Rand = &deterministicRand{} |
| 1108 | } |
| 1109 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1110 | conn, err := acceptOrWait(listener, waitChan) |
| 1111 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1112 | err = doExchange(test, &config, conn, false /* not a resumption */, transcriptPrefix, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1113 | conn.Close() |
| 1114 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1115 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1116 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1117 | var resumeConfig Config |
| 1118 | if test.resumeConfig != nil { |
| 1119 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1120 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1121 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1122 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1123 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1124 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1125 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1126 | } else { |
| 1127 | resumeConfig = config |
| 1128 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1129 | var connResume net.Conn |
| 1130 | connResume, err = acceptOrWait(listener, waitChan) |
| 1131 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1132 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, transcriptPrefix, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1133 | connResume.Close() |
| 1134 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1135 | } |
| 1136 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1137 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1138 | // open more connections than expected. |
| 1139 | listener.Close() |
| 1140 | listener = nil |
| 1141 | |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1142 | var shimKilledLock sync.Mutex |
| 1143 | var shimKilled bool |
| 1144 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1145 | shimKilledLock.Lock() |
| 1146 | shimKilled = true |
| 1147 | shimKilledLock.Unlock() |
| 1148 | shim.Process.Kill() |
| 1149 | }) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1150 | childErr := <-waitChan |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1151 | waitTimeout.Stop() |
| 1152 | shimKilledLock.Lock() |
| 1153 | if shimKilled && err == nil { |
| 1154 | err = errors.New("timeout waiting for the shim to exit.") |
| 1155 | } |
| 1156 | shimKilledLock.Unlock() |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1157 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1158 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1159 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1160 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1161 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1162 | case 89: |
| 1163 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1164 | case 99: |
| 1165 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1166 | } |
| 1167 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1168 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1169 | // Account for Windows line endings. |
| 1170 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1171 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1172 | |
| 1173 | // Separate the errors from the shim and those from tools like |
| 1174 | // AddressSanitizer. |
| 1175 | var extraStderr string |
| 1176 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1177 | stderr = stderrParts[0] |
| 1178 | extraStderr = stderrParts[1] |
| 1179 | } |
| 1180 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1181 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1182 | expectedError := translateExpectedError(test.expectedError) |
| 1183 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1184 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1185 | localError := "none" |
| 1186 | if err != nil { |
| 1187 | localError = err.Error() |
| 1188 | } |
| 1189 | if len(test.expectedLocalError) != 0 { |
| 1190 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1191 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1192 | |
| 1193 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1194 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1195 | if childErr != nil { |
| 1196 | childError = childErr.Error() |
| 1197 | } |
| 1198 | |
| 1199 | var msg string |
| 1200 | switch { |
| 1201 | case failed && !test.shouldFail: |
| 1202 | msg = "unexpected failure" |
| 1203 | case !failed && test.shouldFail: |
| 1204 | msg = "unexpected success" |
| 1205 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1206 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1207 | default: |
| 1208 | panic("internal error") |
| 1209 | } |
| 1210 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1211 | 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] | 1212 | } |
| 1213 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1214 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1215 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1216 | } |
| 1217 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1218 | if *useValgrind && isValgrindError { |
| 1219 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1220 | } |
| 1221 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1222 | return nil |
| 1223 | } |
| 1224 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1225 | type tlsVersion struct { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1226 | name string |
| 1227 | // version is the protocol version. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1228 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1229 | // excludeFlag is the legacy shim flag to disable the version. |
| 1230 | excludeFlag string |
| 1231 | hasDTLS bool |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1232 | // versionDTLS, if non-zero, is the DTLS-specific representation of the version. |
| 1233 | versionDTLS uint16 |
| 1234 | // versionWire, if non-zero, is the wire representation of the |
| 1235 | // version. Otherwise the wire version is the protocol version or |
| 1236 | // versionDTLS. |
| 1237 | versionWire uint16 |
| 1238 | tls13Variant int |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1242 | // The shim uses the protocol version in its public API, but uses the |
| 1243 | // DTLS-specific version if it exists. |
| 1244 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1245 | return strconv.Itoa(int(vers.versionDTLS)) |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1246 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1247 | return strconv.Itoa(int(vers.version)) |
| 1248 | } |
| 1249 | |
| 1250 | func (vers tlsVersion) wire(protocol protocol) uint16 { |
| 1251 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1252 | return vers.versionDTLS |
| 1253 | } |
| 1254 | if vers.versionWire != 0 { |
| 1255 | return vers.versionWire |
| 1256 | } |
| 1257 | return vers.version |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | var tlsVersions = []tlsVersion{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1261 | { |
| 1262 | name: "SSL3", |
| 1263 | version: VersionSSL30, |
| 1264 | excludeFlag: "-no-ssl3", |
| 1265 | }, |
| 1266 | { |
| 1267 | name: "TLS1", |
| 1268 | version: VersionTLS10, |
| 1269 | excludeFlag: "-no-tls1", |
| 1270 | hasDTLS: true, |
| 1271 | versionDTLS: VersionDTLS10, |
| 1272 | }, |
| 1273 | { |
| 1274 | name: "TLS11", |
| 1275 | version: VersionTLS11, |
| 1276 | excludeFlag: "-no-tls11", |
| 1277 | }, |
| 1278 | { |
| 1279 | name: "TLS12", |
| 1280 | version: VersionTLS12, |
| 1281 | excludeFlag: "-no-tls12", |
| 1282 | hasDTLS: true, |
| 1283 | versionDTLS: VersionDTLS12, |
| 1284 | }, |
| 1285 | { |
| 1286 | name: "TLS13", |
| 1287 | version: VersionTLS13, |
| 1288 | excludeFlag: "-no-tls13", |
| 1289 | versionWire: tls13DraftVersion, |
| 1290 | tls13Variant: TLS13Default, |
| 1291 | }, |
| 1292 | { |
| 1293 | name: "TLS13Experiment", |
| 1294 | version: VersionTLS13, |
| 1295 | excludeFlag: "-no-tls13", |
| 1296 | versionWire: tls13ExperimentVersion, |
| 1297 | tls13Variant: TLS13Experiment, |
| 1298 | }, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 1299 | { |
| 1300 | name: "TLS13RecordTypeExperiment", |
| 1301 | version: VersionTLS13, |
| 1302 | excludeFlag: "-no-tls13", |
| 1303 | versionWire: tls13RecordTypeExperimentVersion, |
| 1304 | tls13Variant: TLS13RecordTypeExperiment, |
| 1305 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | func allVersions(protocol protocol) []tlsVersion { |
| 1309 | if protocol == tls { |
| 1310 | return tlsVersions |
| 1311 | } |
| 1312 | |
| 1313 | var ret []tlsVersion |
| 1314 | for _, vers := range tlsVersions { |
| 1315 | if vers.hasDTLS { |
| 1316 | ret = append(ret, vers) |
| 1317 | } |
| 1318 | } |
| 1319 | return ret |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1322 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1323 | name string |
| 1324 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1328 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1329 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1330 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1331 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1332 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1333 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1334 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1335 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1336 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1337 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1338 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1339 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1340 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1341 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1342 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1343 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1344 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1345 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1346 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1347 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1348 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1349 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1350 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1351 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1352 | {"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] | 1353 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1354 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1355 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1356 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1357 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1360 | func hasComponent(suiteName, component string) bool { |
| 1361 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1362 | } |
| 1363 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1364 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1365 | return hasComponent(suiteName, "GCM") || |
| 1366 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1367 | hasComponent(suiteName, "SHA384") || |
| 1368 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1369 | } |
| 1370 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1371 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1372 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1373 | } |
| 1374 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1375 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1376 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1377 | } |
| 1378 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1379 | func bigFromHex(hex string) *big.Int { |
| 1380 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1381 | if !ok { |
| 1382 | panic("failed to parse hex number 0x" + hex) |
| 1383 | } |
| 1384 | return ret |
| 1385 | } |
| 1386 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1387 | func addBasicTests() { |
| 1388 | basicTests := []testCase{ |
| 1389 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1390 | name: "NoFallbackSCSV", |
| 1391 | config: Config{ |
| 1392 | Bugs: ProtocolBugs{ |
| 1393 | FailIfNotFallbackSCSV: true, |
| 1394 | }, |
| 1395 | }, |
| 1396 | shouldFail: true, |
| 1397 | expectedLocalError: "no fallback SCSV found", |
| 1398 | }, |
| 1399 | { |
| 1400 | name: "SendFallbackSCSV", |
| 1401 | config: Config{ |
| 1402 | Bugs: ProtocolBugs{ |
| 1403 | FailIfNotFallbackSCSV: true, |
| 1404 | }, |
| 1405 | }, |
| 1406 | flags: []string{"-fallback-scsv"}, |
| 1407 | }, |
| 1408 | { |
| 1409 | name: "ClientCertificateTypes", |
| 1410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1411 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1412 | ClientAuth: RequestClientCert, |
| 1413 | ClientCertificateTypes: []byte{ |
| 1414 | CertTypeDSSSign, |
| 1415 | CertTypeRSASign, |
| 1416 | CertTypeECDSASign, |
| 1417 | }, |
| 1418 | }, |
| 1419 | flags: []string{ |
| 1420 | "-expect-certificate-types", |
| 1421 | base64.StdEncoding.EncodeToString([]byte{ |
| 1422 | CertTypeDSSSign, |
| 1423 | CertTypeRSASign, |
| 1424 | CertTypeECDSASign, |
| 1425 | }), |
| 1426 | }, |
| 1427 | }, |
| 1428 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1429 | name: "UnauthenticatedECDH", |
| 1430 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1431 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1432 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1433 | Bugs: ProtocolBugs{ |
| 1434 | UnauthenticatedECDH: true, |
| 1435 | }, |
| 1436 | }, |
| 1437 | shouldFail: true, |
| 1438 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1439 | }, |
| 1440 | { |
| 1441 | name: "SkipCertificateStatus", |
| 1442 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1443 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1444 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1445 | Bugs: ProtocolBugs{ |
| 1446 | SkipCertificateStatus: true, |
| 1447 | }, |
| 1448 | }, |
| 1449 | flags: []string{ |
| 1450 | "-enable-ocsp-stapling", |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 1451 | // This test involves an optional message. Test the message callback |
| 1452 | // trace to ensure we do not miss or double-report any. |
| 1453 | "-expect-msg-callback", |
| 1454 | `write hs 1 |
| 1455 | read hs 2 |
| 1456 | read hs 11 |
| 1457 | read hs 12 |
| 1458 | read hs 14 |
| 1459 | write hs 16 |
| 1460 | write ccs |
| 1461 | write hs 20 |
| 1462 | read hs 4 |
| 1463 | read ccs |
| 1464 | read hs 20 |
| 1465 | read alert 1 0 |
| 1466 | `, |
| 1467 | }, |
| 1468 | }, |
| 1469 | { |
| 1470 | protocol: dtls, |
| 1471 | name: "SkipCertificateStatus-DTLS", |
| 1472 | config: Config{ |
| 1473 | MaxVersion: VersionTLS12, |
| 1474 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1475 | Bugs: ProtocolBugs{ |
| 1476 | SkipCertificateStatus: true, |
| 1477 | }, |
| 1478 | }, |
| 1479 | flags: []string{ |
| 1480 | "-enable-ocsp-stapling", |
| 1481 | // This test involves an optional message. Test the message callback |
| 1482 | // trace to ensure we do not miss or double-report any. |
| 1483 | "-expect-msg-callback", |
| 1484 | `write hs 1 |
| 1485 | read hs 3 |
| 1486 | write hs 1 |
| 1487 | read hs 2 |
| 1488 | read hs 11 |
| 1489 | read hs 12 |
| 1490 | read hs 14 |
| 1491 | write hs 16 |
| 1492 | write ccs |
| 1493 | write hs 20 |
| 1494 | read hs 4 |
| 1495 | read ccs |
| 1496 | read hs 20 |
| 1497 | read alert 1 0 |
| 1498 | `, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1499 | }, |
| 1500 | }, |
| 1501 | { |
| 1502 | name: "SkipServerKeyExchange", |
| 1503 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1504 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1505 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1506 | Bugs: ProtocolBugs{ |
| 1507 | SkipServerKeyExchange: true, |
| 1508 | }, |
| 1509 | }, |
| 1510 | shouldFail: true, |
| 1511 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1512 | }, |
| 1513 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1514 | testType: serverTest, |
Dimitar Vlahovski | bd70845 | 2017-08-10 18:01:06 +0200 | [diff] [blame] | 1515 | name: "ServerSkipCertificateVerify", |
| 1516 | config: Config{ |
| 1517 | MaxVersion: VersionTLS12, |
| 1518 | Certificates: []Certificate{rsaChainCertificate}, |
| 1519 | Bugs: ProtocolBugs{ |
| 1520 | SkipCertificateVerify: true, |
| 1521 | }, |
| 1522 | }, |
| 1523 | expectPeerCertificate: &rsaChainCertificate, |
| 1524 | flags: []string{ |
| 1525 | "-require-any-client-certificate", |
| 1526 | }, |
| 1527 | shouldFail: true, |
| 1528 | expectedError: ":UNEXPECTED_RECORD:", |
| 1529 | expectedLocalError: "remote error: unexpected message", |
| 1530 | }, |
| 1531 | { |
| 1532 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1533 | name: "Alert", |
| 1534 | config: Config{ |
| 1535 | Bugs: ProtocolBugs{ |
| 1536 | SendSpuriousAlert: alertRecordOverflow, |
| 1537 | }, |
| 1538 | }, |
| 1539 | shouldFail: true, |
| 1540 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1541 | }, |
| 1542 | { |
| 1543 | protocol: dtls, |
| 1544 | testType: serverTest, |
| 1545 | name: "Alert-DTLS", |
| 1546 | config: Config{ |
| 1547 | Bugs: ProtocolBugs{ |
| 1548 | SendSpuriousAlert: alertRecordOverflow, |
| 1549 | }, |
| 1550 | }, |
| 1551 | shouldFail: true, |
| 1552 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1553 | }, |
| 1554 | { |
| 1555 | testType: serverTest, |
| 1556 | name: "FragmentAlert", |
| 1557 | config: Config{ |
| 1558 | Bugs: ProtocolBugs{ |
| 1559 | FragmentAlert: true, |
| 1560 | SendSpuriousAlert: alertRecordOverflow, |
| 1561 | }, |
| 1562 | }, |
| 1563 | shouldFail: true, |
| 1564 | expectedError: ":BAD_ALERT:", |
| 1565 | }, |
| 1566 | { |
| 1567 | protocol: dtls, |
| 1568 | testType: serverTest, |
| 1569 | name: "FragmentAlert-DTLS", |
| 1570 | config: Config{ |
| 1571 | Bugs: ProtocolBugs{ |
| 1572 | FragmentAlert: true, |
| 1573 | SendSpuriousAlert: alertRecordOverflow, |
| 1574 | }, |
| 1575 | }, |
| 1576 | shouldFail: true, |
| 1577 | expectedError: ":BAD_ALERT:", |
| 1578 | }, |
| 1579 | { |
| 1580 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1581 | name: "DoubleAlert", |
| 1582 | config: Config{ |
| 1583 | Bugs: ProtocolBugs{ |
| 1584 | DoubleAlert: true, |
| 1585 | SendSpuriousAlert: alertRecordOverflow, |
| 1586 | }, |
| 1587 | }, |
| 1588 | shouldFail: true, |
| 1589 | expectedError: ":BAD_ALERT:", |
| 1590 | }, |
| 1591 | { |
| 1592 | protocol: dtls, |
| 1593 | testType: serverTest, |
| 1594 | name: "DoubleAlert-DTLS", |
| 1595 | config: Config{ |
| 1596 | Bugs: ProtocolBugs{ |
| 1597 | DoubleAlert: true, |
| 1598 | SendSpuriousAlert: alertRecordOverflow, |
| 1599 | }, |
| 1600 | }, |
| 1601 | shouldFail: true, |
| 1602 | expectedError: ":BAD_ALERT:", |
| 1603 | }, |
| 1604 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1605 | name: "SkipNewSessionTicket", |
| 1606 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1607 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1608 | Bugs: ProtocolBugs{ |
| 1609 | SkipNewSessionTicket: true, |
| 1610 | }, |
| 1611 | }, |
| 1612 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1613 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1614 | }, |
| 1615 | { |
| 1616 | testType: serverTest, |
| 1617 | name: "FallbackSCSV", |
| 1618 | config: Config{ |
| 1619 | MaxVersion: VersionTLS11, |
| 1620 | Bugs: ProtocolBugs{ |
| 1621 | SendFallbackSCSV: true, |
| 1622 | }, |
| 1623 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1624 | shouldFail: true, |
| 1625 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1626 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1627 | }, |
| 1628 | { |
| 1629 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1630 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1631 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1632 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1633 | Bugs: ProtocolBugs{ |
| 1634 | SendFallbackSCSV: true, |
| 1635 | }, |
| 1636 | }, |
| 1637 | }, |
| 1638 | { |
| 1639 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1640 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1641 | config: Config{ |
| 1642 | MaxVersion: VersionTLS12, |
| 1643 | Bugs: ProtocolBugs{ |
| 1644 | SendFallbackSCSV: true, |
| 1645 | }, |
| 1646 | }, |
| 1647 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1648 | }, |
| 1649 | { |
| 1650 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1651 | name: "FragmentedClientVersion", |
| 1652 | config: Config{ |
| 1653 | Bugs: ProtocolBugs{ |
| 1654 | MaxHandshakeRecordLength: 1, |
| 1655 | FragmentClientVersion: true, |
| 1656 | }, |
| 1657 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1658 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1659 | }, |
| 1660 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1661 | testType: serverTest, |
| 1662 | name: "HttpGET", |
| 1663 | sendPrefix: "GET / HTTP/1.0\n", |
| 1664 | shouldFail: true, |
| 1665 | expectedError: ":HTTP_REQUEST:", |
| 1666 | }, |
| 1667 | { |
| 1668 | testType: serverTest, |
| 1669 | name: "HttpPOST", |
| 1670 | sendPrefix: "POST / HTTP/1.0\n", |
| 1671 | shouldFail: true, |
| 1672 | expectedError: ":HTTP_REQUEST:", |
| 1673 | }, |
| 1674 | { |
| 1675 | testType: serverTest, |
| 1676 | name: "HttpHEAD", |
| 1677 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1678 | shouldFail: true, |
| 1679 | expectedError: ":HTTP_REQUEST:", |
| 1680 | }, |
| 1681 | { |
| 1682 | testType: serverTest, |
| 1683 | name: "HttpPUT", |
| 1684 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1685 | shouldFail: true, |
| 1686 | expectedError: ":HTTP_REQUEST:", |
| 1687 | }, |
| 1688 | { |
| 1689 | testType: serverTest, |
| 1690 | name: "HttpCONNECT", |
| 1691 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1692 | shouldFail: true, |
| 1693 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1694 | }, |
| 1695 | { |
| 1696 | testType: serverTest, |
| 1697 | name: "Garbage", |
| 1698 | sendPrefix: "blah", |
| 1699 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1700 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1701 | }, |
| 1702 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1703 | name: "RSAEphemeralKey", |
| 1704 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1705 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1706 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1707 | Bugs: ProtocolBugs{ |
| 1708 | RSAEphemeralKey: true, |
| 1709 | }, |
| 1710 | }, |
| 1711 | shouldFail: true, |
| 1712 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1713 | }, |
| 1714 | { |
| 1715 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1716 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1717 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1718 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1719 | }, |
| 1720 | { |
| 1721 | protocol: dtls, |
| 1722 | name: "DisableEverything-DTLS", |
| 1723 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1724 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1725 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1726 | }, |
| 1727 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1728 | protocol: dtls, |
| 1729 | testType: serverTest, |
| 1730 | name: "MTU", |
| 1731 | config: Config{ |
| 1732 | Bugs: ProtocolBugs{ |
| 1733 | MaxPacketLength: 256, |
| 1734 | }, |
| 1735 | }, |
| 1736 | flags: []string{"-mtu", "256"}, |
| 1737 | }, |
| 1738 | { |
| 1739 | protocol: dtls, |
| 1740 | testType: serverTest, |
| 1741 | name: "MTUExceeded", |
| 1742 | config: Config{ |
| 1743 | Bugs: ProtocolBugs{ |
| 1744 | MaxPacketLength: 255, |
| 1745 | }, |
| 1746 | }, |
| 1747 | flags: []string{"-mtu", "256"}, |
| 1748 | shouldFail: true, |
| 1749 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1750 | }, |
| 1751 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1752 | name: "EmptyCertificateList", |
| 1753 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1754 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1755 | Bugs: ProtocolBugs{ |
| 1756 | EmptyCertificateList: true, |
| 1757 | }, |
| 1758 | }, |
| 1759 | shouldFail: true, |
| 1760 | expectedError: ":DECODE_ERROR:", |
| 1761 | }, |
| 1762 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1763 | name: "EmptyCertificateList-TLS13", |
| 1764 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1765 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1766 | Bugs: ProtocolBugs{ |
| 1767 | EmptyCertificateList: true, |
| 1768 | }, |
| 1769 | }, |
| 1770 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1771 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1772 | }, |
| 1773 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1774 | name: "TLSFatalBadPackets", |
| 1775 | damageFirstWrite: true, |
| 1776 | shouldFail: true, |
| 1777 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1778 | }, |
| 1779 | { |
| 1780 | protocol: dtls, |
| 1781 | name: "DTLSIgnoreBadPackets", |
| 1782 | damageFirstWrite: true, |
| 1783 | }, |
| 1784 | { |
| 1785 | protocol: dtls, |
| 1786 | name: "DTLSIgnoreBadPackets-Async", |
| 1787 | damageFirstWrite: true, |
| 1788 | flags: []string{"-async"}, |
| 1789 | }, |
| 1790 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1791 | name: "AppDataBeforeHandshake", |
| 1792 | config: Config{ |
| 1793 | Bugs: ProtocolBugs{ |
| 1794 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1795 | }, |
| 1796 | }, |
| 1797 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1798 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1799 | }, |
| 1800 | { |
| 1801 | name: "AppDataBeforeHandshake-Empty", |
| 1802 | config: Config{ |
| 1803 | Bugs: ProtocolBugs{ |
| 1804 | AppDataBeforeHandshake: []byte{}, |
| 1805 | }, |
| 1806 | }, |
| 1807 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1808 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1809 | }, |
| 1810 | { |
| 1811 | protocol: dtls, |
| 1812 | name: "AppDataBeforeHandshake-DTLS", |
| 1813 | config: Config{ |
| 1814 | Bugs: ProtocolBugs{ |
| 1815 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1816 | }, |
| 1817 | }, |
| 1818 | shouldFail: true, |
| 1819 | expectedError: ":UNEXPECTED_RECORD:", |
| 1820 | }, |
| 1821 | { |
| 1822 | protocol: dtls, |
| 1823 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1824 | config: Config{ |
| 1825 | Bugs: ProtocolBugs{ |
| 1826 | AppDataBeforeHandshake: []byte{}, |
| 1827 | }, |
| 1828 | }, |
| 1829 | shouldFail: true, |
| 1830 | expectedError: ":UNEXPECTED_RECORD:", |
| 1831 | }, |
| 1832 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1833 | name: "AppDataAfterChangeCipherSpec", |
| 1834 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1835 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1836 | Bugs: ProtocolBugs{ |
| 1837 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1838 | }, |
| 1839 | }, |
| 1840 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1841 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1842 | }, |
| 1843 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1844 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1845 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1846 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1847 | Bugs: ProtocolBugs{ |
| 1848 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1849 | }, |
| 1850 | }, |
| 1851 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1852 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1853 | }, |
| 1854 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1855 | protocol: dtls, |
| 1856 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1857 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1858 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1859 | Bugs: ProtocolBugs{ |
| 1860 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1861 | }, |
| 1862 | }, |
| 1863 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1864 | // application data. |
| 1865 | }, |
| 1866 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1867 | protocol: dtls, |
| 1868 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1869 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1870 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1871 | Bugs: ProtocolBugs{ |
| 1872 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1873 | }, |
| 1874 | }, |
| 1875 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1876 | // application data. |
| 1877 | }, |
| 1878 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1879 | name: "AlertAfterChangeCipherSpec", |
| 1880 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1881 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1882 | Bugs: ProtocolBugs{ |
| 1883 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1884 | }, |
| 1885 | }, |
| 1886 | shouldFail: true, |
| 1887 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1888 | }, |
| 1889 | { |
| 1890 | protocol: dtls, |
| 1891 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1892 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1893 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1894 | Bugs: ProtocolBugs{ |
| 1895 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1896 | }, |
| 1897 | }, |
| 1898 | shouldFail: true, |
| 1899 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1900 | }, |
| 1901 | { |
| 1902 | protocol: dtls, |
| 1903 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1904 | config: Config{ |
| 1905 | Bugs: ProtocolBugs{ |
| 1906 | ReorderHandshakeFragments: true, |
| 1907 | // Small enough that every handshake message is |
| 1908 | // fragmented. |
| 1909 | MaxHandshakeRecordLength: 2, |
| 1910 | }, |
| 1911 | }, |
| 1912 | }, |
| 1913 | { |
| 1914 | protocol: dtls, |
| 1915 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1916 | config: Config{ |
| 1917 | Bugs: ProtocolBugs{ |
| 1918 | ReorderHandshakeFragments: true, |
| 1919 | // Large enough that no handshake message is |
| 1920 | // fragmented. |
| 1921 | MaxHandshakeRecordLength: 2048, |
| 1922 | }, |
| 1923 | }, |
| 1924 | }, |
| 1925 | { |
| 1926 | protocol: dtls, |
| 1927 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1928 | config: Config{ |
| 1929 | Bugs: ProtocolBugs{ |
| 1930 | ReorderHandshakeFragments: true, |
| 1931 | MixCompleteMessageWithFragments: true, |
| 1932 | MaxHandshakeRecordLength: 2, |
| 1933 | }, |
| 1934 | }, |
| 1935 | }, |
| 1936 | { |
| 1937 | name: "SendInvalidRecordType", |
| 1938 | config: Config{ |
| 1939 | Bugs: ProtocolBugs{ |
| 1940 | SendInvalidRecordType: true, |
| 1941 | }, |
| 1942 | }, |
| 1943 | shouldFail: true, |
| 1944 | expectedError: ":UNEXPECTED_RECORD:", |
| 1945 | }, |
| 1946 | { |
| 1947 | protocol: dtls, |
| 1948 | name: "SendInvalidRecordType-DTLS", |
| 1949 | config: Config{ |
| 1950 | Bugs: ProtocolBugs{ |
| 1951 | SendInvalidRecordType: true, |
| 1952 | }, |
| 1953 | }, |
| 1954 | shouldFail: true, |
| 1955 | expectedError: ":UNEXPECTED_RECORD:", |
| 1956 | }, |
| 1957 | { |
| 1958 | name: "FalseStart-SkipServerSecondLeg", |
| 1959 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1960 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1961 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1962 | NextProtos: []string{"foo"}, |
| 1963 | Bugs: ProtocolBugs{ |
| 1964 | SkipNewSessionTicket: true, |
| 1965 | SkipChangeCipherSpec: true, |
| 1966 | SkipFinished: true, |
| 1967 | ExpectFalseStart: true, |
| 1968 | }, |
| 1969 | }, |
| 1970 | flags: []string{ |
| 1971 | "-false-start", |
| 1972 | "-handshake-never-done", |
| 1973 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1974 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1975 | }, |
| 1976 | shimWritesFirst: true, |
| 1977 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1978 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1979 | }, |
| 1980 | { |
| 1981 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1982 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1983 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1984 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1985 | NextProtos: []string{"foo"}, |
| 1986 | Bugs: ProtocolBugs{ |
| 1987 | SkipNewSessionTicket: true, |
| 1988 | SkipChangeCipherSpec: true, |
| 1989 | SkipFinished: true, |
| 1990 | }, |
| 1991 | }, |
| 1992 | flags: []string{ |
| 1993 | "-implicit-handshake", |
| 1994 | "-false-start", |
| 1995 | "-handshake-never-done", |
| 1996 | "-advertise-alpn", "\x03foo", |
| 1997 | }, |
| 1998 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1999 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2000 | }, |
| 2001 | { |
| 2002 | testType: serverTest, |
| 2003 | name: "FailEarlyCallback", |
| 2004 | flags: []string{"-fail-early-callback"}, |
| 2005 | shouldFail: true, |
| 2006 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 2007 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2008 | }, |
| 2009 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 2010 | name: "FailCertCallback-Client-TLS12", |
| 2011 | config: Config{ |
| 2012 | MaxVersion: VersionTLS12, |
| 2013 | ClientAuth: RequestClientCert, |
| 2014 | }, |
| 2015 | flags: []string{"-fail-cert-callback"}, |
| 2016 | shouldFail: true, |
| 2017 | expectedError: ":CERT_CB_ERROR:", |
| 2018 | expectedLocalError: "remote error: internal error", |
| 2019 | }, |
| 2020 | { |
| 2021 | testType: serverTest, |
| 2022 | name: "FailCertCallback-Server-TLS12", |
| 2023 | config: Config{ |
| 2024 | MaxVersion: VersionTLS12, |
| 2025 | }, |
| 2026 | flags: []string{"-fail-cert-callback"}, |
| 2027 | shouldFail: true, |
| 2028 | expectedError: ":CERT_CB_ERROR:", |
| 2029 | expectedLocalError: "remote error: internal error", |
| 2030 | }, |
| 2031 | { |
| 2032 | name: "FailCertCallback-Client-TLS13", |
| 2033 | config: Config{ |
| 2034 | MaxVersion: VersionTLS13, |
| 2035 | ClientAuth: RequestClientCert, |
| 2036 | }, |
| 2037 | flags: []string{"-fail-cert-callback"}, |
| 2038 | shouldFail: true, |
| 2039 | expectedError: ":CERT_CB_ERROR:", |
| 2040 | expectedLocalError: "remote error: internal error", |
| 2041 | }, |
| 2042 | { |
| 2043 | testType: serverTest, |
| 2044 | name: "FailCertCallback-Server-TLS13", |
| 2045 | config: Config{ |
| 2046 | MaxVersion: VersionTLS13, |
| 2047 | }, |
| 2048 | flags: []string{"-fail-cert-callback"}, |
| 2049 | shouldFail: true, |
| 2050 | expectedError: ":CERT_CB_ERROR:", |
| 2051 | expectedLocalError: "remote error: internal error", |
| 2052 | }, |
| 2053 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2054 | protocol: dtls, |
| 2055 | name: "FragmentMessageTypeMismatch-DTLS", |
| 2056 | config: Config{ |
| 2057 | Bugs: ProtocolBugs{ |
| 2058 | MaxHandshakeRecordLength: 2, |
| 2059 | FragmentMessageTypeMismatch: true, |
| 2060 | }, |
| 2061 | }, |
| 2062 | shouldFail: true, |
| 2063 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2064 | }, |
| 2065 | { |
| 2066 | protocol: dtls, |
| 2067 | name: "FragmentMessageLengthMismatch-DTLS", |
| 2068 | config: Config{ |
| 2069 | Bugs: ProtocolBugs{ |
| 2070 | MaxHandshakeRecordLength: 2, |
| 2071 | FragmentMessageLengthMismatch: true, |
| 2072 | }, |
| 2073 | }, |
| 2074 | shouldFail: true, |
| 2075 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2076 | }, |
| 2077 | { |
| 2078 | protocol: dtls, |
| 2079 | name: "SplitFragments-Header-DTLS", |
| 2080 | config: Config{ |
| 2081 | Bugs: ProtocolBugs{ |
| 2082 | SplitFragments: 2, |
| 2083 | }, |
| 2084 | }, |
| 2085 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2086 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2087 | }, |
| 2088 | { |
| 2089 | protocol: dtls, |
| 2090 | name: "SplitFragments-Boundary-DTLS", |
| 2091 | config: Config{ |
| 2092 | Bugs: ProtocolBugs{ |
| 2093 | SplitFragments: dtlsRecordHeaderLen, |
| 2094 | }, |
| 2095 | }, |
| 2096 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2097 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2098 | }, |
| 2099 | { |
| 2100 | protocol: dtls, |
| 2101 | name: "SplitFragments-Body-DTLS", |
| 2102 | config: Config{ |
| 2103 | Bugs: ProtocolBugs{ |
| 2104 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 2105 | }, |
| 2106 | }, |
| 2107 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2108 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2109 | }, |
| 2110 | { |
| 2111 | protocol: dtls, |
| 2112 | name: "SendEmptyFragments-DTLS", |
| 2113 | config: Config{ |
| 2114 | Bugs: ProtocolBugs{ |
| 2115 | SendEmptyFragments: true, |
| 2116 | }, |
| 2117 | }, |
| 2118 | }, |
| 2119 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2120 | name: "BadFinished-Client", |
| 2121 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2122 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2123 | Bugs: ProtocolBugs{ |
| 2124 | BadFinished: true, |
| 2125 | }, |
| 2126 | }, |
| 2127 | shouldFail: true, |
| 2128 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2129 | }, |
| 2130 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2131 | name: "BadFinished-Client-TLS13", |
| 2132 | config: Config{ |
| 2133 | MaxVersion: VersionTLS13, |
| 2134 | Bugs: ProtocolBugs{ |
| 2135 | BadFinished: true, |
| 2136 | }, |
| 2137 | }, |
| 2138 | shouldFail: true, |
| 2139 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2140 | }, |
| 2141 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2142 | testType: serverTest, |
| 2143 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2144 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2145 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2146 | Bugs: ProtocolBugs{ |
| 2147 | BadFinished: true, |
| 2148 | }, |
| 2149 | }, |
| 2150 | shouldFail: true, |
| 2151 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2152 | }, |
| 2153 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2154 | testType: serverTest, |
| 2155 | name: "BadFinished-Server-TLS13", |
| 2156 | config: Config{ |
| 2157 | MaxVersion: VersionTLS13, |
| 2158 | Bugs: ProtocolBugs{ |
| 2159 | BadFinished: true, |
| 2160 | }, |
| 2161 | }, |
| 2162 | shouldFail: true, |
| 2163 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2164 | }, |
| 2165 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2166 | name: "FalseStart-BadFinished", |
| 2167 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2168 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2169 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2170 | NextProtos: []string{"foo"}, |
| 2171 | Bugs: ProtocolBugs{ |
| 2172 | BadFinished: true, |
| 2173 | ExpectFalseStart: true, |
| 2174 | }, |
| 2175 | }, |
| 2176 | flags: []string{ |
| 2177 | "-false-start", |
| 2178 | "-handshake-never-done", |
| 2179 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 2180 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2181 | }, |
| 2182 | shimWritesFirst: true, |
| 2183 | shouldFail: true, |
| 2184 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2185 | }, |
| 2186 | { |
| 2187 | name: "NoFalseStart-NoALPN", |
| 2188 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2189 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2190 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2191 | Bugs: ProtocolBugs{ |
| 2192 | ExpectFalseStart: true, |
| 2193 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2194 | }, |
| 2195 | }, |
| 2196 | flags: []string{ |
| 2197 | "-false-start", |
| 2198 | }, |
| 2199 | shimWritesFirst: true, |
| 2200 | shouldFail: true, |
| 2201 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2202 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2203 | }, |
| 2204 | { |
| 2205 | name: "NoFalseStart-NoAEAD", |
| 2206 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2207 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2208 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2209 | NextProtos: []string{"foo"}, |
| 2210 | Bugs: ProtocolBugs{ |
| 2211 | ExpectFalseStart: true, |
| 2212 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2213 | }, |
| 2214 | }, |
| 2215 | flags: []string{ |
| 2216 | "-false-start", |
| 2217 | "-advertise-alpn", "\x03foo", |
| 2218 | }, |
| 2219 | shimWritesFirst: true, |
| 2220 | shouldFail: true, |
| 2221 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2222 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2223 | }, |
| 2224 | { |
| 2225 | name: "NoFalseStart-RSA", |
| 2226 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2227 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2228 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2229 | NextProtos: []string{"foo"}, |
| 2230 | Bugs: ProtocolBugs{ |
| 2231 | ExpectFalseStart: true, |
| 2232 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2233 | }, |
| 2234 | }, |
| 2235 | flags: []string{ |
| 2236 | "-false-start", |
| 2237 | "-advertise-alpn", "\x03foo", |
| 2238 | }, |
| 2239 | shimWritesFirst: true, |
| 2240 | shouldFail: true, |
| 2241 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2242 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2243 | }, |
| 2244 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2245 | protocol: dtls, |
| 2246 | name: "SendSplitAlert-Sync", |
| 2247 | config: Config{ |
| 2248 | Bugs: ProtocolBugs{ |
| 2249 | SendSplitAlert: true, |
| 2250 | }, |
| 2251 | }, |
| 2252 | }, |
| 2253 | { |
| 2254 | protocol: dtls, |
| 2255 | name: "SendSplitAlert-Async", |
| 2256 | config: Config{ |
| 2257 | Bugs: ProtocolBugs{ |
| 2258 | SendSplitAlert: true, |
| 2259 | }, |
| 2260 | }, |
| 2261 | flags: []string{"-async"}, |
| 2262 | }, |
| 2263 | { |
| 2264 | protocol: dtls, |
| 2265 | name: "PackDTLSHandshake", |
| 2266 | config: Config{ |
| 2267 | Bugs: ProtocolBugs{ |
| 2268 | MaxHandshakeRecordLength: 2, |
| 2269 | PackHandshakeFragments: 20, |
| 2270 | PackHandshakeRecords: 200, |
| 2271 | }, |
| 2272 | }, |
| 2273 | }, |
| 2274 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2275 | name: "SendEmptyRecords-Pass", |
| 2276 | sendEmptyRecords: 32, |
| 2277 | }, |
| 2278 | { |
| 2279 | name: "SendEmptyRecords", |
| 2280 | sendEmptyRecords: 33, |
| 2281 | shouldFail: true, |
| 2282 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2283 | }, |
| 2284 | { |
| 2285 | name: "SendEmptyRecords-Async", |
| 2286 | sendEmptyRecords: 33, |
| 2287 | flags: []string{"-async"}, |
| 2288 | shouldFail: true, |
| 2289 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2290 | }, |
| 2291 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2292 | name: "SendWarningAlerts-Pass", |
| 2293 | config: Config{ |
| 2294 | MaxVersion: VersionTLS12, |
| 2295 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2296 | sendWarningAlerts: 4, |
| 2297 | }, |
| 2298 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2299 | protocol: dtls, |
| 2300 | name: "SendWarningAlerts-DTLS-Pass", |
| 2301 | config: Config{ |
| 2302 | MaxVersion: VersionTLS12, |
| 2303 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2304 | sendWarningAlerts: 4, |
| 2305 | }, |
| 2306 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2307 | name: "SendWarningAlerts-TLS13", |
| 2308 | config: Config{ |
| 2309 | MaxVersion: VersionTLS13, |
| 2310 | }, |
| 2311 | sendWarningAlerts: 4, |
| 2312 | shouldFail: true, |
| 2313 | expectedError: ":BAD_ALERT:", |
| 2314 | expectedLocalError: "remote error: error decoding message", |
| 2315 | }, |
| 2316 | { |
| 2317 | name: "SendWarningAlerts", |
| 2318 | config: Config{ |
| 2319 | MaxVersion: VersionTLS12, |
| 2320 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2321 | sendWarningAlerts: 5, |
| 2322 | shouldFail: true, |
| 2323 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2324 | }, |
| 2325 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2326 | name: "SendWarningAlerts-Async", |
| 2327 | config: Config{ |
| 2328 | MaxVersion: VersionTLS12, |
| 2329 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2330 | sendWarningAlerts: 5, |
| 2331 | flags: []string{"-async"}, |
| 2332 | shouldFail: true, |
| 2333 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2334 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2335 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2336 | name: "SendBogusAlertType", |
| 2337 | sendBogusAlertType: true, |
| 2338 | shouldFail: true, |
| 2339 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2340 | expectedLocalError: "remote error: illegal parameter", |
| 2341 | }, |
| 2342 | { |
| 2343 | protocol: dtls, |
| 2344 | name: "SendBogusAlertType-DTLS", |
| 2345 | sendBogusAlertType: true, |
| 2346 | shouldFail: true, |
| 2347 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2348 | expectedLocalError: "remote error: illegal parameter", |
| 2349 | }, |
| 2350 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2351 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2352 | config: Config{ |
| 2353 | MaxVersion: VersionTLS13, |
| 2354 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2355 | sendKeyUpdates: 33, |
| 2356 | keyUpdateRequest: keyUpdateNotRequested, |
| 2357 | shouldFail: true, |
| 2358 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2359 | }, |
| 2360 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2361 | name: "EmptySessionID", |
| 2362 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2363 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2364 | SessionTicketsDisabled: true, |
| 2365 | }, |
| 2366 | noSessionCache: true, |
| 2367 | flags: []string{"-expect-no-session"}, |
| 2368 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2369 | { |
| 2370 | name: "Unclean-Shutdown", |
| 2371 | config: Config{ |
| 2372 | Bugs: ProtocolBugs{ |
| 2373 | NoCloseNotify: true, |
| 2374 | ExpectCloseNotify: true, |
| 2375 | }, |
| 2376 | }, |
| 2377 | shimShutsDown: true, |
| 2378 | flags: []string{"-check-close-notify"}, |
| 2379 | shouldFail: true, |
| 2380 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2381 | }, |
| 2382 | { |
| 2383 | name: "Unclean-Shutdown-Ignored", |
| 2384 | config: Config{ |
| 2385 | Bugs: ProtocolBugs{ |
| 2386 | NoCloseNotify: true, |
| 2387 | }, |
| 2388 | }, |
| 2389 | shimShutsDown: true, |
| 2390 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2391 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2392 | name: "Unclean-Shutdown-Alert", |
| 2393 | config: Config{ |
| 2394 | Bugs: ProtocolBugs{ |
| 2395 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2396 | ExpectCloseNotify: true, |
| 2397 | }, |
| 2398 | }, |
| 2399 | shimShutsDown: true, |
| 2400 | flags: []string{"-check-close-notify"}, |
| 2401 | shouldFail: true, |
| 2402 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2403 | }, |
| 2404 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2405 | name: "LargePlaintext", |
| 2406 | config: Config{ |
| 2407 | Bugs: ProtocolBugs{ |
| 2408 | SendLargeRecords: true, |
| 2409 | }, |
| 2410 | }, |
| 2411 | messageLen: maxPlaintext + 1, |
| 2412 | shouldFail: true, |
| 2413 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2414 | }, |
| 2415 | { |
| 2416 | protocol: dtls, |
| 2417 | name: "LargePlaintext-DTLS", |
| 2418 | config: Config{ |
| 2419 | Bugs: ProtocolBugs{ |
| 2420 | SendLargeRecords: true, |
| 2421 | }, |
| 2422 | }, |
| 2423 | messageLen: maxPlaintext + 1, |
| 2424 | shouldFail: true, |
| 2425 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2426 | }, |
| 2427 | { |
| 2428 | name: "LargeCiphertext", |
| 2429 | config: Config{ |
| 2430 | Bugs: ProtocolBugs{ |
| 2431 | SendLargeRecords: true, |
| 2432 | }, |
| 2433 | }, |
| 2434 | messageLen: maxPlaintext * 2, |
| 2435 | shouldFail: true, |
| 2436 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2437 | }, |
| 2438 | { |
| 2439 | protocol: dtls, |
| 2440 | name: "LargeCiphertext-DTLS", |
| 2441 | config: Config{ |
| 2442 | Bugs: ProtocolBugs{ |
| 2443 | SendLargeRecords: true, |
| 2444 | }, |
| 2445 | }, |
| 2446 | messageLen: maxPlaintext * 2, |
| 2447 | // Unlike the other four cases, DTLS drops records which |
| 2448 | // are invalid before authentication, so the connection |
| 2449 | // does not fail. |
| 2450 | expectMessageDropped: true, |
| 2451 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2452 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2453 | name: "BadHelloRequest-1", |
| 2454 | renegotiate: 1, |
| 2455 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2456 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2457 | Bugs: ProtocolBugs{ |
| 2458 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2459 | }, |
| 2460 | }, |
| 2461 | flags: []string{ |
| 2462 | "-renegotiate-freely", |
| 2463 | "-expect-total-renegotiations", "1", |
| 2464 | }, |
| 2465 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2466 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2467 | }, |
| 2468 | { |
| 2469 | name: "BadHelloRequest-2", |
| 2470 | renegotiate: 1, |
| 2471 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2472 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2473 | Bugs: ProtocolBugs{ |
| 2474 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2475 | }, |
| 2476 | }, |
| 2477 | flags: []string{ |
| 2478 | "-renegotiate-freely", |
| 2479 | "-expect-total-renegotiations", "1", |
| 2480 | }, |
| 2481 | shouldFail: true, |
| 2482 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2483 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2484 | { |
| 2485 | testType: serverTest, |
| 2486 | name: "SupportTicketsWithSessionID", |
| 2487 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2488 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2489 | SessionTicketsDisabled: true, |
| 2490 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2491 | resumeConfig: &Config{ |
| 2492 | MaxVersion: VersionTLS12, |
| 2493 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2494 | resumeSession: true, |
| 2495 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2496 | { |
| 2497 | protocol: dtls, |
| 2498 | name: "DTLS-SendExtraFinished", |
| 2499 | config: Config{ |
| 2500 | Bugs: ProtocolBugs{ |
| 2501 | SendExtraFinished: true, |
| 2502 | }, |
| 2503 | }, |
| 2504 | shouldFail: true, |
| 2505 | expectedError: ":UNEXPECTED_RECORD:", |
| 2506 | }, |
| 2507 | { |
| 2508 | protocol: dtls, |
| 2509 | name: "DTLS-SendExtraFinished-Reordered", |
| 2510 | config: Config{ |
| 2511 | Bugs: ProtocolBugs{ |
| 2512 | MaxHandshakeRecordLength: 2, |
| 2513 | ReorderHandshakeFragments: true, |
| 2514 | SendExtraFinished: true, |
| 2515 | }, |
| 2516 | }, |
| 2517 | shouldFail: true, |
| 2518 | expectedError: ":UNEXPECTED_RECORD:", |
| 2519 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2520 | { |
| 2521 | testType: serverTest, |
| 2522 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2523 | config: Config{ |
| 2524 | // Choose a cipher suite that does not involve |
| 2525 | // elliptic curves, so no extensions are |
| 2526 | // involved. |
| 2527 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2528 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2529 | Bugs: ProtocolBugs{ |
| 2530 | SendV2ClientHello: true, |
| 2531 | }, |
| 2532 | }, |
| 2533 | sendPrefix: string([]byte{ |
| 2534 | byte(recordTypeHandshake), |
| 2535 | 3, 1, // version |
| 2536 | 0, 0, // length |
| 2537 | }), |
| 2538 | // A no-op empty record may not be sent before V2ClientHello. |
| 2539 | shouldFail: true, |
| 2540 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2541 | }, |
| 2542 | { |
| 2543 | testType: serverTest, |
| 2544 | name: "V2ClientHello-WarningAlertPrefix", |
| 2545 | config: Config{ |
| 2546 | // Choose a cipher suite that does not involve |
| 2547 | // elliptic curves, so no extensions are |
| 2548 | // involved. |
| 2549 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2550 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2551 | Bugs: ProtocolBugs{ |
| 2552 | SendV2ClientHello: true, |
| 2553 | }, |
| 2554 | }, |
| 2555 | sendPrefix: string([]byte{ |
| 2556 | byte(recordTypeAlert), |
| 2557 | 3, 1, // version |
| 2558 | 0, 2, // length |
| 2559 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2560 | }), |
| 2561 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2562 | shouldFail: true, |
| 2563 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2564 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2565 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2566 | name: "KeyUpdate-Client", |
| 2567 | config: Config{ |
| 2568 | MaxVersion: VersionTLS13, |
| 2569 | }, |
| 2570 | sendKeyUpdates: 1, |
| 2571 | keyUpdateRequest: keyUpdateNotRequested, |
| 2572 | }, |
| 2573 | { |
| 2574 | testType: serverTest, |
| 2575 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2576 | config: Config{ |
| 2577 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2578 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2579 | sendKeyUpdates: 1, |
| 2580 | keyUpdateRequest: keyUpdateNotRequested, |
| 2581 | }, |
| 2582 | { |
| 2583 | name: "KeyUpdate-InvalidRequestMode", |
| 2584 | config: Config{ |
| 2585 | MaxVersion: VersionTLS13, |
| 2586 | }, |
| 2587 | sendKeyUpdates: 1, |
| 2588 | keyUpdateRequest: 42, |
| 2589 | shouldFail: true, |
| 2590 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2591 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2592 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2593 | // Test that KeyUpdates are acknowledged properly. |
| 2594 | name: "KeyUpdate-RequestACK", |
| 2595 | config: Config{ |
| 2596 | MaxVersion: VersionTLS13, |
| 2597 | Bugs: ProtocolBugs{ |
| 2598 | RejectUnsolicitedKeyUpdate: true, |
| 2599 | }, |
| 2600 | }, |
| 2601 | // Test the shim receiving many KeyUpdates in a row. |
| 2602 | sendKeyUpdates: 5, |
| 2603 | messageCount: 5, |
| 2604 | keyUpdateRequest: keyUpdateRequested, |
| 2605 | }, |
| 2606 | { |
| 2607 | // Test that KeyUpdates are acknowledged properly if the |
| 2608 | // peer's KeyUpdate is discovered while a write is |
| 2609 | // pending. |
| 2610 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2611 | config: Config{ |
| 2612 | MaxVersion: VersionTLS13, |
| 2613 | Bugs: ProtocolBugs{ |
| 2614 | RejectUnsolicitedKeyUpdate: true, |
| 2615 | }, |
| 2616 | }, |
| 2617 | // Test the shim receiving many KeyUpdates in a row. |
| 2618 | sendKeyUpdates: 5, |
| 2619 | messageCount: 5, |
| 2620 | keyUpdateRequest: keyUpdateRequested, |
| 2621 | readWithUnfinishedWrite: true, |
| 2622 | flags: []string{"-async"}, |
| 2623 | }, |
| 2624 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2625 | name: "SendSNIWarningAlert", |
| 2626 | config: Config{ |
| 2627 | MaxVersion: VersionTLS12, |
| 2628 | Bugs: ProtocolBugs{ |
| 2629 | SendSNIWarningAlert: true, |
| 2630 | }, |
| 2631 | }, |
| 2632 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2633 | { |
| 2634 | testType: serverTest, |
| 2635 | name: "ExtraCompressionMethods-TLS12", |
| 2636 | config: Config{ |
| 2637 | MaxVersion: VersionTLS12, |
| 2638 | Bugs: ProtocolBugs{ |
| 2639 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2640 | }, |
| 2641 | }, |
| 2642 | }, |
| 2643 | { |
| 2644 | testType: serverTest, |
| 2645 | name: "ExtraCompressionMethods-TLS13", |
| 2646 | config: Config{ |
| 2647 | MaxVersion: VersionTLS13, |
| 2648 | Bugs: ProtocolBugs{ |
| 2649 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2650 | }, |
| 2651 | }, |
| 2652 | shouldFail: true, |
| 2653 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2654 | expectedLocalError: "remote error: illegal parameter", |
| 2655 | }, |
| 2656 | { |
| 2657 | testType: serverTest, |
| 2658 | name: "NoNullCompression-TLS12", |
| 2659 | config: Config{ |
| 2660 | MaxVersion: VersionTLS12, |
| 2661 | Bugs: ProtocolBugs{ |
| 2662 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2663 | }, |
| 2664 | }, |
| 2665 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2666 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2667 | expectedLocalError: "remote error: illegal parameter", |
| 2668 | }, |
| 2669 | { |
| 2670 | testType: serverTest, |
| 2671 | name: "NoNullCompression-TLS13", |
| 2672 | config: Config{ |
| 2673 | MaxVersion: VersionTLS13, |
| 2674 | Bugs: ProtocolBugs{ |
| 2675 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2676 | }, |
| 2677 | }, |
| 2678 | shouldFail: true, |
| 2679 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2680 | expectedLocalError: "remote error: illegal parameter", |
| 2681 | }, |
David Benjamin | 413e79e | 2017-07-01 10:11:53 -0400 | [diff] [blame] | 2682 | // Test that the client rejects invalid compression methods |
| 2683 | // from the server. |
| 2684 | { |
| 2685 | testType: clientTest, |
| 2686 | name: "InvalidCompressionMethod", |
| 2687 | config: Config{ |
| 2688 | MaxVersion: VersionTLS12, |
| 2689 | Bugs: ProtocolBugs{ |
| 2690 | SendCompressionMethod: 1, |
| 2691 | }, |
| 2692 | }, |
| 2693 | shouldFail: true, |
| 2694 | expectedError: ":UNSUPPORTED_COMPRESSION_ALGORITHM:", |
| 2695 | expectedLocalError: "remote error: illegal parameter", |
| 2696 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2697 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2698 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2699 | config: Config{ |
| 2700 | MaxVersion: VersionTLS12, |
| 2701 | Bugs: ProtocolBugs{ |
| 2702 | ExpectGREASE: true, |
| 2703 | }, |
| 2704 | }, |
| 2705 | flags: []string{"-enable-grease"}, |
| 2706 | }, |
| 2707 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2708 | name: "GREASE-Client-TLS13", |
| 2709 | config: Config{ |
| 2710 | MaxVersion: VersionTLS13, |
| 2711 | Bugs: ProtocolBugs{ |
| 2712 | ExpectGREASE: true, |
| 2713 | }, |
| 2714 | }, |
| 2715 | flags: []string{"-enable-grease"}, |
| 2716 | }, |
| 2717 | { |
| 2718 | testType: serverTest, |
| 2719 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2720 | config: Config{ |
| 2721 | MaxVersion: VersionTLS13, |
| 2722 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2723 | // TLS 1.3 servers are expected to |
| 2724 | // always enable GREASE. TLS 1.3 is new, |
| 2725 | // so there is no existing ecosystem to |
| 2726 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2727 | ExpectGREASE: true, |
| 2728 | }, |
| 2729 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2730 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2731 | { |
| 2732 | // Test the server so there is a large certificate as |
| 2733 | // well as application data. |
| 2734 | testType: serverTest, |
| 2735 | name: "MaxSendFragment", |
| 2736 | config: Config{ |
| 2737 | Bugs: ProtocolBugs{ |
| 2738 | MaxReceivePlaintext: 512, |
| 2739 | }, |
| 2740 | }, |
| 2741 | messageLen: 1024, |
| 2742 | flags: []string{ |
| 2743 | "-max-send-fragment", "512", |
| 2744 | "-read-size", "1024", |
| 2745 | }, |
| 2746 | }, |
| 2747 | { |
| 2748 | // Test the server so there is a large certificate as |
| 2749 | // well as application data. |
| 2750 | testType: serverTest, |
| 2751 | name: "MaxSendFragment-TooLarge", |
| 2752 | config: Config{ |
| 2753 | Bugs: ProtocolBugs{ |
| 2754 | // Ensure that some of the records are |
| 2755 | // 512. |
| 2756 | MaxReceivePlaintext: 511, |
| 2757 | }, |
| 2758 | }, |
| 2759 | messageLen: 1024, |
| 2760 | flags: []string{ |
| 2761 | "-max-send-fragment", "512", |
| 2762 | "-read-size", "1024", |
| 2763 | }, |
| 2764 | shouldFail: true, |
| 2765 | expectedLocalError: "local error: record overflow", |
| 2766 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2767 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2768 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2769 | |
| 2770 | // Test that very large messages can be received. |
| 2771 | cert := rsaCertificate |
| 2772 | for i := 0; i < 50; i++ { |
| 2773 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2774 | } |
| 2775 | testCases = append(testCases, testCase{ |
| 2776 | name: "LargeMessage", |
| 2777 | config: Config{ |
| 2778 | Certificates: []Certificate{cert}, |
| 2779 | }, |
| 2780 | }) |
| 2781 | testCases = append(testCases, testCase{ |
| 2782 | protocol: dtls, |
| 2783 | name: "LargeMessage-DTLS", |
| 2784 | config: Config{ |
| 2785 | Certificates: []Certificate{cert}, |
| 2786 | }, |
| 2787 | }) |
| 2788 | |
| 2789 | // They are rejected if the maximum certificate chain length is capped. |
| 2790 | testCases = append(testCases, testCase{ |
| 2791 | name: "LargeMessage-Reject", |
| 2792 | config: Config{ |
| 2793 | Certificates: []Certificate{cert}, |
| 2794 | }, |
| 2795 | flags: []string{"-max-cert-list", "16384"}, |
| 2796 | shouldFail: true, |
| 2797 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2798 | }) |
| 2799 | testCases = append(testCases, testCase{ |
| 2800 | protocol: dtls, |
| 2801 | name: "LargeMessage-Reject-DTLS", |
| 2802 | config: Config{ |
| 2803 | Certificates: []Certificate{cert}, |
| 2804 | }, |
| 2805 | flags: []string{"-max-cert-list", "16384"}, |
| 2806 | shouldFail: true, |
| 2807 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2808 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2809 | } |
| 2810 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2811 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2812 | const psk = "12345" |
| 2813 | const pskIdentity = "luggage combo" |
| 2814 | |
| 2815 | var prefix string |
| 2816 | if protocol == dtls { |
| 2817 | if !ver.hasDTLS { |
| 2818 | return |
| 2819 | } |
| 2820 | prefix = "D" |
| 2821 | } |
| 2822 | |
| 2823 | var cert Certificate |
| 2824 | var certFile string |
| 2825 | var keyFile string |
| 2826 | if hasComponent(suite.name, "ECDSA") { |
| 2827 | cert = ecdsaP256Certificate |
| 2828 | certFile = ecdsaP256CertificateFile |
| 2829 | keyFile = ecdsaP256KeyFile |
| 2830 | } else { |
| 2831 | cert = rsaCertificate |
| 2832 | certFile = rsaCertificateFile |
| 2833 | keyFile = rsaKeyFile |
| 2834 | } |
| 2835 | |
| 2836 | var flags []string |
| 2837 | if hasComponent(suite.name, "PSK") { |
| 2838 | flags = append(flags, |
| 2839 | "-psk", psk, |
| 2840 | "-psk-identity", pskIdentity) |
| 2841 | } |
| 2842 | if hasComponent(suite.name, "NULL") { |
| 2843 | // NULL ciphers must be explicitly enabled. |
| 2844 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2845 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2846 | |
| 2847 | var shouldServerFail, shouldClientFail bool |
| 2848 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2849 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2850 | // a BoringSSL server will never select it |
| 2851 | // because the extension is missing. |
| 2852 | shouldServerFail = true |
| 2853 | } |
| 2854 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2855 | shouldClientFail = true |
| 2856 | shouldServerFail = true |
| 2857 | } |
| 2858 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2859 | shouldClientFail = true |
| 2860 | shouldServerFail = true |
| 2861 | } |
| 2862 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2863 | shouldClientFail = true |
| 2864 | shouldServerFail = true |
| 2865 | } |
| 2866 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2867 | shouldClientFail = true |
| 2868 | shouldServerFail = true |
| 2869 | } |
| 2870 | |
| 2871 | var sendCipherSuite uint16 |
| 2872 | var expectedServerError, expectedClientError string |
| 2873 | serverCipherSuites := []uint16{suite.id} |
| 2874 | if shouldServerFail { |
| 2875 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2876 | } |
| 2877 | if shouldClientFail { |
| 2878 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2879 | // Configure the server to select ciphers as normal but |
| 2880 | // select an incompatible cipher in ServerHello. |
| 2881 | serverCipherSuites = nil |
| 2882 | sendCipherSuite = suite.id |
| 2883 | } |
| 2884 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2885 | // For cipher suites and versions where exporters are defined, verify |
| 2886 | // that they interoperate. |
| 2887 | var exportKeyingMaterial int |
| 2888 | if ver.version > VersionSSL30 { |
| 2889 | exportKeyingMaterial = 1024 |
| 2890 | } |
| 2891 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2892 | testCases = append(testCases, testCase{ |
| 2893 | testType: serverTest, |
| 2894 | protocol: protocol, |
| 2895 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2896 | config: Config{ |
| 2897 | MinVersion: ver.version, |
| 2898 | MaxVersion: ver.version, |
| 2899 | CipherSuites: []uint16{suite.id}, |
| 2900 | Certificates: []Certificate{cert}, |
| 2901 | PreSharedKey: []byte(psk), |
| 2902 | PreSharedKeyIdentity: pskIdentity, |
| 2903 | Bugs: ProtocolBugs{ |
| 2904 | AdvertiseAllConfiguredCiphers: true, |
| 2905 | }, |
| 2906 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2907 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2908 | certFile: certFile, |
| 2909 | keyFile: keyFile, |
| 2910 | flags: flags, |
| 2911 | resumeSession: true, |
| 2912 | shouldFail: shouldServerFail, |
| 2913 | expectedError: expectedServerError, |
| 2914 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2915 | }) |
| 2916 | |
| 2917 | testCases = append(testCases, testCase{ |
| 2918 | testType: clientTest, |
| 2919 | protocol: protocol, |
| 2920 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2921 | config: Config{ |
| 2922 | MinVersion: ver.version, |
| 2923 | MaxVersion: ver.version, |
| 2924 | CipherSuites: serverCipherSuites, |
| 2925 | Certificates: []Certificate{cert}, |
| 2926 | PreSharedKey: []byte(psk), |
| 2927 | PreSharedKeyIdentity: pskIdentity, |
| 2928 | Bugs: ProtocolBugs{ |
| 2929 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2930 | SendCipherSuite: sendCipherSuite, |
| 2931 | }, |
| 2932 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2933 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2934 | flags: flags, |
| 2935 | resumeSession: true, |
| 2936 | shouldFail: shouldClientFail, |
| 2937 | expectedError: expectedClientError, |
| 2938 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2939 | }) |
| 2940 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2941 | if shouldClientFail { |
| 2942 | return |
| 2943 | } |
| 2944 | |
| 2945 | // Ensure the maximum record size is accepted. |
| 2946 | testCases = append(testCases, testCase{ |
| 2947 | protocol: protocol, |
| 2948 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2949 | config: Config{ |
| 2950 | MinVersion: ver.version, |
| 2951 | MaxVersion: ver.version, |
| 2952 | CipherSuites: []uint16{suite.id}, |
| 2953 | Certificates: []Certificate{cert}, |
| 2954 | PreSharedKey: []byte(psk), |
| 2955 | PreSharedKeyIdentity: pskIdentity, |
| 2956 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2957 | tls13Variant: ver.tls13Variant, |
| 2958 | flags: flags, |
| 2959 | messageLen: maxPlaintext, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2960 | }) |
| 2961 | |
| 2962 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2963 | // and ignored in DTLS. |
| 2964 | var shouldFail bool |
| 2965 | var expectedError string |
| 2966 | if protocol == tls { |
| 2967 | shouldFail = true |
| 2968 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2969 | } |
| 2970 | |
| 2971 | testCases = append(testCases, testCase{ |
| 2972 | protocol: protocol, |
| 2973 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2974 | config: Config{ |
| 2975 | MinVersion: ver.version, |
| 2976 | MaxVersion: ver.version, |
| 2977 | CipherSuites: []uint16{suite.id}, |
| 2978 | Certificates: []Certificate{cert}, |
| 2979 | PreSharedKey: []byte(psk), |
| 2980 | PreSharedKeyIdentity: pskIdentity, |
| 2981 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2982 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2983 | flags: flags, |
| 2984 | damageFirstWrite: true, |
| 2985 | messageLen: maxPlaintext, |
| 2986 | shouldFail: shouldFail, |
| 2987 | expectedError: expectedError, |
| 2988 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2989 | } |
| 2990 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2991 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2992 | const bogusCipher = 0xfe00 |
| 2993 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2994 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2995 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2996 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2997 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2998 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2999 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3000 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 3001 | |
| 3002 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3003 | name: "NoSharedCipher", |
| 3004 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3005 | MaxVersion: VersionTLS12, |
| 3006 | CipherSuites: []uint16{}, |
| 3007 | }, |
| 3008 | shouldFail: true, |
| 3009 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 3010 | }) |
| 3011 | |
| 3012 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3013 | name: "NoSharedCipher-TLS13", |
| 3014 | config: Config{ |
| 3015 | MaxVersion: VersionTLS13, |
| 3016 | CipherSuites: []uint16{}, |
| 3017 | }, |
| 3018 | shouldFail: true, |
| 3019 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 3020 | }) |
| 3021 | |
| 3022 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3023 | name: "UnsupportedCipherSuite", |
| 3024 | config: Config{ |
| 3025 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3026 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3027 | Bugs: ProtocolBugs{ |
| 3028 | IgnorePeerCipherPreferences: true, |
| 3029 | }, |
| 3030 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3031 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3032 | shouldFail: true, |
| 3033 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 3034 | }) |
| 3035 | |
| 3036 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 3037 | name: "ServerHelloBogusCipher", |
| 3038 | config: Config{ |
| 3039 | MaxVersion: VersionTLS12, |
| 3040 | Bugs: ProtocolBugs{ |
| 3041 | SendCipherSuite: bogusCipher, |
| 3042 | }, |
| 3043 | }, |
| 3044 | shouldFail: true, |
| 3045 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3046 | }) |
| 3047 | testCases = append(testCases, testCase{ |
| 3048 | name: "ServerHelloBogusCipher-TLS13", |
| 3049 | config: Config{ |
| 3050 | MaxVersion: VersionTLS13, |
| 3051 | Bugs: ProtocolBugs{ |
| 3052 | SendCipherSuite: bogusCipher, |
| 3053 | }, |
| 3054 | }, |
| 3055 | shouldFail: true, |
| 3056 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3057 | }) |
| 3058 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3059 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3060 | testCases = append(testCases, testCase{ |
| 3061 | testType: serverTest, |
| 3062 | name: "UnknownCipher", |
| 3063 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3064 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3065 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3066 | Bugs: ProtocolBugs{ |
| 3067 | AdvertiseAllConfiguredCiphers: true, |
| 3068 | }, |
| 3069 | }, |
| 3070 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3071 | |
| 3072 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3073 | testCases = append(testCases, testCase{ |
| 3074 | testType: serverTest, |
| 3075 | name: "UnknownCipher-TLS13", |
| 3076 | config: Config{ |
| 3077 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3078 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3079 | Bugs: ProtocolBugs{ |
| 3080 | AdvertiseAllConfiguredCiphers: true, |
| 3081 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3082 | }, |
| 3083 | }) |
| 3084 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 3085 | // Test empty ECDHE_PSK identity hints work as expected. |
| 3086 | testCases = append(testCases, testCase{ |
| 3087 | name: "EmptyECDHEPSKHint", |
| 3088 | config: Config{ |
| 3089 | MaxVersion: VersionTLS12, |
| 3090 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3091 | PreSharedKey: []byte("secret"), |
| 3092 | }, |
| 3093 | flags: []string{"-psk", "secret"}, |
| 3094 | }) |
| 3095 | |
| 3096 | // Test empty PSK identity hints work as expected, even if an explicit |
| 3097 | // ServerKeyExchange is sent. |
| 3098 | testCases = append(testCases, testCase{ |
| 3099 | name: "ExplicitEmptyPSKHint", |
| 3100 | config: Config{ |
| 3101 | MaxVersion: VersionTLS12, |
| 3102 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3103 | PreSharedKey: []byte("secret"), |
| 3104 | Bugs: ProtocolBugs{ |
| 3105 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 3106 | }, |
| 3107 | }, |
| 3108 | flags: []string{"-psk", "secret"}, |
| 3109 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 3110 | |
| 3111 | // Test that clients enforce that the server-sent certificate and cipher |
| 3112 | // suite match in TLS 1.2. |
| 3113 | testCases = append(testCases, testCase{ |
| 3114 | name: "CertificateCipherMismatch-RSA", |
| 3115 | config: Config{ |
| 3116 | MaxVersion: VersionTLS12, |
| 3117 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3118 | Certificates: []Certificate{rsaCertificate}, |
| 3119 | Bugs: ProtocolBugs{ |
| 3120 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 3121 | }, |
| 3122 | }, |
| 3123 | shouldFail: true, |
| 3124 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3125 | }) |
| 3126 | testCases = append(testCases, testCase{ |
| 3127 | name: "CertificateCipherMismatch-ECDSA", |
| 3128 | config: Config{ |
| 3129 | MaxVersion: VersionTLS12, |
| 3130 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3131 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3132 | Bugs: ProtocolBugs{ |
| 3133 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3134 | }, |
| 3135 | }, |
| 3136 | shouldFail: true, |
| 3137 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3138 | }) |
| 3139 | testCases = append(testCases, testCase{ |
| 3140 | name: "CertificateCipherMismatch-Ed25519", |
| 3141 | config: Config{ |
| 3142 | MaxVersion: VersionTLS12, |
| 3143 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3144 | Certificates: []Certificate{ed25519Certificate}, |
| 3145 | Bugs: ProtocolBugs{ |
| 3146 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3147 | }, |
| 3148 | }, |
| 3149 | shouldFail: true, |
| 3150 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3151 | }) |
| 3152 | |
| 3153 | // Test that servers decline to select a cipher suite which is |
| 3154 | // inconsistent with their configured certificate. |
| 3155 | testCases = append(testCases, testCase{ |
| 3156 | testType: serverTest, |
| 3157 | name: "ServerCipherFilter-RSA", |
| 3158 | config: Config{ |
| 3159 | MaxVersion: VersionTLS12, |
| 3160 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3161 | }, |
| 3162 | flags: []string{ |
| 3163 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3164 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3165 | }, |
| 3166 | shouldFail: true, |
| 3167 | expectedError: ":NO_SHARED_CIPHER:", |
| 3168 | }) |
| 3169 | testCases = append(testCases, testCase{ |
| 3170 | testType: serverTest, |
| 3171 | name: "ServerCipherFilter-ECDSA", |
| 3172 | config: Config{ |
| 3173 | MaxVersion: VersionTLS12, |
| 3174 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3175 | }, |
| 3176 | flags: []string{ |
| 3177 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3178 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3179 | }, |
| 3180 | shouldFail: true, |
| 3181 | expectedError: ":NO_SHARED_CIPHER:", |
| 3182 | }) |
| 3183 | testCases = append(testCases, testCase{ |
| 3184 | testType: serverTest, |
| 3185 | name: "ServerCipherFilter-Ed25519", |
| 3186 | config: Config{ |
| 3187 | MaxVersion: VersionTLS12, |
| 3188 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3189 | }, |
| 3190 | flags: []string{ |
| 3191 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 3192 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 3193 | }, |
| 3194 | shouldFail: true, |
| 3195 | expectedError: ":NO_SHARED_CIPHER:", |
| 3196 | }) |
David Benjamin | 364af78 | 2017-07-01 10:35:27 -0400 | [diff] [blame] | 3197 | |
| 3198 | // Test cipher suite negotiation works as expected. Configure a |
| 3199 | // complicated cipher suite configuration. |
| 3200 | const negotiationTestCiphers = "" + |
| 3201 | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3202 | "[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]:" + |
| 3203 | "TLS_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3204 | "TLS_RSA_WITH_AES_128_CBC_SHA:" + |
| 3205 | "[TLS_RSA_WITH_AES_256_GCM_SHA384|TLS_RSA_WITH_AES_256_CBC_SHA]" |
| 3206 | negotiationTests := []struct { |
| 3207 | ciphers []uint16 |
| 3208 | expected uint16 |
| 3209 | }{ |
| 3210 | // Server preferences are honored, including when |
| 3211 | // equipreference groups are involved. |
| 3212 | { |
| 3213 | []uint16{ |
| 3214 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3215 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3216 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3217 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3218 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3219 | }, |
| 3220 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3221 | }, |
| 3222 | { |
| 3223 | []uint16{ |
| 3224 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3225 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3226 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3227 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3228 | }, |
| 3229 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3230 | }, |
| 3231 | { |
| 3232 | []uint16{ |
| 3233 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3234 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3235 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3236 | }, |
| 3237 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3238 | }, |
| 3239 | { |
| 3240 | []uint16{ |
| 3241 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3242 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3243 | }, |
| 3244 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3245 | }, |
| 3246 | // Equipreference groups use the client preference. |
| 3247 | { |
| 3248 | []uint16{ |
| 3249 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3250 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3251 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3252 | }, |
| 3253 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3254 | }, |
| 3255 | { |
| 3256 | []uint16{ |
| 3257 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3258 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3259 | }, |
| 3260 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3261 | }, |
| 3262 | { |
| 3263 | []uint16{ |
| 3264 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3265 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3266 | }, |
| 3267 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3268 | }, |
| 3269 | { |
| 3270 | []uint16{ |
| 3271 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3272 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3273 | }, |
| 3274 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3275 | }, |
| 3276 | { |
| 3277 | []uint16{ |
| 3278 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3279 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3280 | }, |
| 3281 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3282 | }, |
| 3283 | // If there are two equipreference groups, the preferred one |
| 3284 | // takes precedence. |
| 3285 | { |
| 3286 | []uint16{ |
| 3287 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3288 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3289 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3290 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3291 | }, |
| 3292 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3293 | }, |
| 3294 | } |
| 3295 | for i, t := range negotiationTests { |
| 3296 | testCases = append(testCases, testCase{ |
| 3297 | testType: serverTest, |
| 3298 | name: "CipherNegotiation-" + strconv.Itoa(i), |
| 3299 | config: Config{ |
| 3300 | MaxVersion: VersionTLS12, |
| 3301 | CipherSuites: t.ciphers, |
| 3302 | }, |
| 3303 | flags: []string{"-cipher", negotiationTestCiphers}, |
| 3304 | expectedCipher: t.expected, |
| 3305 | }) |
| 3306 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3307 | } |
| 3308 | |
| 3309 | func addBadECDSASignatureTests() { |
| 3310 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 3311 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3312 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3313 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 3314 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3315 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3316 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3317 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3318 | Bugs: ProtocolBugs{ |
| 3319 | BadECDSAR: badR, |
| 3320 | BadECDSAS: badS, |
| 3321 | }, |
| 3322 | }, |
| 3323 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3324 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3325 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3326 | testCases = append(testCases, testCase{ |
| 3327 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 3328 | config: Config{ |
| 3329 | MaxVersion: VersionTLS13, |
| 3330 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3331 | Bugs: ProtocolBugs{ |
| 3332 | BadECDSAR: badR, |
| 3333 | BadECDSAS: badS, |
| 3334 | }, |
| 3335 | }, |
| 3336 | shouldFail: true, |
| 3337 | expectedError: ":BAD_SIGNATURE:", |
| 3338 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3339 | } |
| 3340 | } |
| 3341 | } |
| 3342 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3343 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3344 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3345 | name: "MaxCBCPadding", |
| 3346 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3347 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3348 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3349 | Bugs: ProtocolBugs{ |
| 3350 | MaxPadding: true, |
| 3351 | }, |
| 3352 | }, |
| 3353 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3354 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3355 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3356 | name: "BadCBCPadding", |
| 3357 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3358 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3359 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3360 | Bugs: ProtocolBugs{ |
| 3361 | PaddingFirstByteBad: true, |
| 3362 | }, |
| 3363 | }, |
| 3364 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3365 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3366 | }) |
| 3367 | // OpenSSL previously had an issue where the first byte of padding in |
| 3368 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3369 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3370 | name: "BadCBCPadding255", |
| 3371 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3372 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3373 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3374 | Bugs: ProtocolBugs{ |
| 3375 | MaxPadding: true, |
| 3376 | PaddingFirstByteBadIf255: true, |
| 3377 | }, |
| 3378 | }, |
| 3379 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3380 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3381 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3382 | }) |
| 3383 | } |
| 3384 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3385 | func addCBCSplittingTests() { |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3386 | var cbcCiphers = []struct { |
| 3387 | name string |
| 3388 | cipher uint16 |
| 3389 | }{ |
| 3390 | {"3DES", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
| 3391 | {"AES128", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3392 | {"AES256", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
| 3393 | } |
| 3394 | for _, t := range cbcCiphers { |
| 3395 | testCases = append(testCases, testCase{ |
| 3396 | name: "CBCRecordSplitting-" + t.name, |
| 3397 | config: Config{ |
| 3398 | MaxVersion: VersionTLS10, |
| 3399 | MinVersion: VersionTLS10, |
| 3400 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3401 | Bugs: ProtocolBugs{ |
| 3402 | ExpectRecordSplitting: true, |
| 3403 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3404 | }, |
| 3405 | messageLen: -1, // read until EOF |
| 3406 | resumeSession: true, |
| 3407 | flags: []string{ |
| 3408 | "-async", |
| 3409 | "-write-different-record-sizes", |
| 3410 | "-cbc-record-splitting", |
| 3411 | }, |
| 3412 | }) |
| 3413 | testCases = append(testCases, testCase{ |
| 3414 | name: "CBCRecordSplittingPartialWrite-" + t.name, |
| 3415 | config: Config{ |
| 3416 | MaxVersion: VersionTLS10, |
| 3417 | MinVersion: VersionTLS10, |
| 3418 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3419 | Bugs: ProtocolBugs{ |
| 3420 | ExpectRecordSplitting: true, |
| 3421 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3422 | }, |
| 3423 | messageLen: -1, // read until EOF |
| 3424 | flags: []string{ |
| 3425 | "-async", |
| 3426 | "-write-different-record-sizes", |
| 3427 | "-cbc-record-splitting", |
| 3428 | "-partial-write", |
| 3429 | }, |
| 3430 | }) |
| 3431 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3432 | } |
| 3433 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3434 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3435 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3436 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3437 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3438 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3439 | if err != nil { |
| 3440 | panic(err) |
| 3441 | } |
| 3442 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3443 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3444 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3445 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3446 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3447 | testCases = append(testCases, testCase{ |
| 3448 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3449 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3450 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3451 | MinVersion: ver.version, |
| 3452 | MaxVersion: ver.version, |
| 3453 | ClientAuth: RequireAnyClientCert, |
| 3454 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3455 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3456 | tls13Variant: ver.tls13Variant, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3457 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3458 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3459 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3460 | }, |
| 3461 | }) |
| 3462 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3463 | testType: serverTest, |
| 3464 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3465 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3466 | MinVersion: ver.version, |
| 3467 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3468 | Certificates: []Certificate{rsaCertificate}, |
| 3469 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3470 | tls13Variant: ver.tls13Variant, |
| 3471 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3472 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3473 | if ver.version != VersionSSL30 { |
| 3474 | testCases = append(testCases, testCase{ |
| 3475 | testType: serverTest, |
| 3476 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3477 | config: Config{ |
| 3478 | MinVersion: ver.version, |
| 3479 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3480 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3481 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3482 | tls13Variant: ver.tls13Variant, |
| 3483 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3484 | }) |
| 3485 | testCases = append(testCases, testCase{ |
| 3486 | testType: clientTest, |
| 3487 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3488 | config: Config{ |
| 3489 | MinVersion: ver.version, |
| 3490 | MaxVersion: ver.version, |
| 3491 | ClientAuth: RequireAnyClientCert, |
| 3492 | ClientCAs: certPool, |
| 3493 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3494 | tls13Variant: ver.tls13Variant, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3495 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3496 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3497 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3498 | }, |
| 3499 | }) |
| 3500 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3501 | |
| 3502 | testCases = append(testCases, testCase{ |
| 3503 | name: "NoClientCertificate-" + ver.name, |
| 3504 | config: Config{ |
| 3505 | MinVersion: ver.version, |
| 3506 | MaxVersion: ver.version, |
| 3507 | ClientAuth: RequireAnyClientCert, |
| 3508 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3509 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3510 | shouldFail: true, |
| 3511 | expectedLocalError: "client didn't provide a certificate", |
| 3512 | }) |
| 3513 | |
| 3514 | testCases = append(testCases, testCase{ |
| 3515 | // Even if not configured to expect a certificate, OpenSSL will |
| 3516 | // return X509_V_OK as the verify_result. |
| 3517 | testType: serverTest, |
| 3518 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3519 | config: Config{ |
| 3520 | MinVersion: ver.version, |
| 3521 | MaxVersion: ver.version, |
| 3522 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3523 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3524 | flags: []string{ |
| 3525 | "-expect-verify-result", |
| 3526 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3527 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3528 | }) |
| 3529 | |
| 3530 | testCases = append(testCases, testCase{ |
| 3531 | // If a client certificate is not provided, OpenSSL will still |
| 3532 | // return X509_V_OK as the verify_result. |
| 3533 | testType: serverTest, |
| 3534 | name: "NoClientCertificate-Server-" + ver.name, |
| 3535 | config: Config{ |
| 3536 | MinVersion: ver.version, |
| 3537 | MaxVersion: ver.version, |
| 3538 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3539 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3540 | flags: []string{ |
| 3541 | "-expect-verify-result", |
| 3542 | "-verify-peer", |
| 3543 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3544 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3545 | }) |
| 3546 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3547 | certificateRequired := "remote error: certificate required" |
| 3548 | if ver.version < VersionTLS13 { |
| 3549 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3550 | // was used. |
| 3551 | certificateRequired = "remote error: handshake failure" |
| 3552 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3553 | testCases = append(testCases, testCase{ |
| 3554 | testType: serverTest, |
| 3555 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3556 | config: Config{ |
| 3557 | MinVersion: ver.version, |
| 3558 | MaxVersion: ver.version, |
| 3559 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3560 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3561 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3562 | shouldFail: true, |
| 3563 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3564 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3565 | }) |
| 3566 | |
| 3567 | if ver.version != VersionSSL30 { |
| 3568 | testCases = append(testCases, testCase{ |
| 3569 | testType: serverTest, |
| 3570 | name: "SkipClientCertificate-" + ver.name, |
| 3571 | config: Config{ |
| 3572 | MinVersion: ver.version, |
| 3573 | MaxVersion: ver.version, |
| 3574 | Bugs: ProtocolBugs{ |
| 3575 | SkipClientCertificate: true, |
| 3576 | }, |
| 3577 | }, |
| 3578 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3579 | flags: []string{"-verify-peer"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3580 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3581 | shouldFail: true, |
| 3582 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3583 | }) |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3584 | |
| 3585 | testCases = append(testCases, testCase{ |
| 3586 | testType: serverTest, |
| 3587 | name: "VerifyPeerIfNoOBC-NoChannelID-" + ver.name, |
| 3588 | config: Config{ |
| 3589 | MinVersion: ver.version, |
| 3590 | MaxVersion: ver.version, |
| 3591 | }, |
| 3592 | flags: []string{ |
| 3593 | "-enable-channel-id", |
| 3594 | "-verify-peer-if-no-obc", |
| 3595 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3596 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3597 | shouldFail: true, |
| 3598 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3599 | expectedLocalError: certificateRequired, |
| 3600 | }) |
| 3601 | |
| 3602 | testCases = append(testCases, testCase{ |
| 3603 | testType: serverTest, |
| 3604 | name: "VerifyPeerIfNoOBC-ChannelID-" + ver.name, |
| 3605 | config: Config{ |
| 3606 | MinVersion: ver.version, |
| 3607 | MaxVersion: ver.version, |
| 3608 | ChannelID: channelIDKey, |
| 3609 | }, |
| 3610 | expectChannelID: true, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3611 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3612 | flags: []string{ |
| 3613 | "-enable-channel-id", |
| 3614 | "-verify-peer-if-no-obc", |
| 3615 | }, |
| 3616 | }) |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3617 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3618 | |
| 3619 | testCases = append(testCases, testCase{ |
| 3620 | testType: serverTest, |
| 3621 | name: ver.name + "-Server-CertReq-CA-List", |
| 3622 | config: Config{ |
| 3623 | MinVersion: ver.version, |
| 3624 | MaxVersion: ver.version, |
| 3625 | Certificates: []Certificate{rsaCertificate}, |
| 3626 | Bugs: ProtocolBugs{ |
| 3627 | ExpectCertificateReqNames: caNames, |
| 3628 | }, |
| 3629 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3630 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3631 | flags: []string{ |
| 3632 | "-require-any-client-certificate", |
| 3633 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3634 | }, |
| 3635 | }) |
| 3636 | |
| 3637 | testCases = append(testCases, testCase{ |
| 3638 | testType: clientTest, |
| 3639 | name: ver.name + "-Client-CertReq-CA-List", |
| 3640 | config: Config{ |
| 3641 | MinVersion: ver.version, |
| 3642 | MaxVersion: ver.version, |
| 3643 | Certificates: []Certificate{rsaCertificate}, |
| 3644 | ClientAuth: RequireAnyClientCert, |
| 3645 | ClientCAs: certPool, |
| 3646 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3647 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3648 | flags: []string{ |
| 3649 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3650 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3651 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3652 | }, |
| 3653 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3654 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3655 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3656 | // Client auth is only legal in certificate-based ciphers. |
| 3657 | testCases = append(testCases, testCase{ |
| 3658 | testType: clientTest, |
| 3659 | name: "ClientAuth-PSK", |
| 3660 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3661 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3662 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3663 | PreSharedKey: []byte("secret"), |
| 3664 | ClientAuth: RequireAnyClientCert, |
| 3665 | }, |
| 3666 | flags: []string{ |
| 3667 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3668 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3669 | "-psk", "secret", |
| 3670 | }, |
| 3671 | shouldFail: true, |
| 3672 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3673 | }) |
| 3674 | testCases = append(testCases, testCase{ |
| 3675 | testType: clientTest, |
| 3676 | name: "ClientAuth-ECDHE_PSK", |
| 3677 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3678 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3679 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3680 | PreSharedKey: []byte("secret"), |
| 3681 | ClientAuth: RequireAnyClientCert, |
| 3682 | }, |
| 3683 | flags: []string{ |
| 3684 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3685 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3686 | "-psk", "secret", |
| 3687 | }, |
| 3688 | shouldFail: true, |
| 3689 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3690 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3691 | |
| 3692 | // Regression test for a bug where the client CA list, if explicitly |
| 3693 | // set to NULL, was mis-encoded. |
| 3694 | testCases = append(testCases, testCase{ |
| 3695 | testType: serverTest, |
| 3696 | name: "Null-Client-CA-List", |
| 3697 | config: Config{ |
| 3698 | MaxVersion: VersionTLS12, |
| 3699 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3700 | Bugs: ProtocolBugs{ |
| 3701 | ExpectCertificateReqNames: [][]byte{}, |
| 3702 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3703 | }, |
| 3704 | flags: []string{ |
| 3705 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3706 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3707 | }, |
| 3708 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3709 | } |
| 3710 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3711 | func addExtendedMasterSecretTests() { |
| 3712 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3713 | |
| 3714 | for _, with := range []bool{false, true} { |
| 3715 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3716 | if with { |
| 3717 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3718 | } |
| 3719 | |
| 3720 | for _, isClient := range []bool{false, true} { |
| 3721 | suffix := "-Server" |
| 3722 | testType := serverTest |
| 3723 | if isClient { |
| 3724 | suffix = "-Client" |
| 3725 | testType = clientTest |
| 3726 | } |
| 3727 | |
| 3728 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3729 | // In TLS 1.3, the extension is irrelevant and |
| 3730 | // always reports as enabled. |
| 3731 | var flags []string |
| 3732 | if with || ver.version >= VersionTLS13 { |
| 3733 | flags = []string{expectEMSFlag} |
| 3734 | } |
| 3735 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3736 | test := testCase{ |
| 3737 | testType: testType, |
| 3738 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3739 | config: Config{ |
| 3740 | MinVersion: ver.version, |
| 3741 | MaxVersion: ver.version, |
| 3742 | Bugs: ProtocolBugs{ |
| 3743 | NoExtendedMasterSecret: !with, |
| 3744 | RequireExtendedMasterSecret: with, |
| 3745 | }, |
| 3746 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3747 | tls13Variant: ver.tls13Variant, |
| 3748 | flags: flags, |
| 3749 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3750 | } |
| 3751 | if test.shouldFail { |
| 3752 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3753 | } |
| 3754 | testCases = append(testCases, test) |
| 3755 | } |
| 3756 | } |
| 3757 | } |
| 3758 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3759 | for _, isClient := range []bool{false, true} { |
| 3760 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3761 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3762 | boolToWord := func(b bool) string { |
| 3763 | if b { |
| 3764 | return "Yes" |
| 3765 | } |
| 3766 | return "No" |
| 3767 | } |
| 3768 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3769 | if isClient { |
| 3770 | suffix += "Client" |
| 3771 | } else { |
| 3772 | suffix += "Server" |
| 3773 | } |
| 3774 | |
| 3775 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3776 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3777 | Bugs: ProtocolBugs{ |
| 3778 | RequireExtendedMasterSecret: true, |
| 3779 | }, |
| 3780 | } |
| 3781 | |
| 3782 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3783 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3784 | Bugs: ProtocolBugs{ |
| 3785 | NoExtendedMasterSecret: true, |
| 3786 | }, |
| 3787 | } |
| 3788 | |
| 3789 | test := testCase{ |
| 3790 | name: "ExtendedMasterSecret-" + suffix, |
| 3791 | resumeSession: true, |
| 3792 | } |
| 3793 | |
| 3794 | if !isClient { |
| 3795 | test.testType = serverTest |
| 3796 | } |
| 3797 | |
| 3798 | if supportedInFirstConnection { |
| 3799 | test.config = supportedConfig |
| 3800 | } else { |
| 3801 | test.config = noSupportConfig |
| 3802 | } |
| 3803 | |
| 3804 | if supportedInResumeConnection { |
| 3805 | test.resumeConfig = &supportedConfig |
| 3806 | } else { |
| 3807 | test.resumeConfig = &noSupportConfig |
| 3808 | } |
| 3809 | |
| 3810 | switch suffix { |
| 3811 | case "YesToYes-Client", "YesToYes-Server": |
| 3812 | // When a session is resumed, it should |
| 3813 | // still be aware that its master |
| 3814 | // secret was generated via EMS and |
| 3815 | // thus it's safe to use tls-unique. |
| 3816 | test.flags = []string{expectEMSFlag} |
| 3817 | case "NoToYes-Server": |
| 3818 | // If an original connection did not |
| 3819 | // contain EMS, but a resumption |
| 3820 | // handshake does, then a server should |
| 3821 | // not resume the session. |
| 3822 | test.expectResumeRejected = true |
| 3823 | case "YesToNo-Server": |
| 3824 | // Resuming an EMS session without the |
| 3825 | // EMS extension should cause the |
| 3826 | // server to abort the connection. |
| 3827 | test.shouldFail = true |
| 3828 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3829 | case "NoToYes-Client": |
| 3830 | // A client should abort a connection |
| 3831 | // where the server resumed a non-EMS |
| 3832 | // session but echoed the EMS |
| 3833 | // extension. |
| 3834 | test.shouldFail = true |
| 3835 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3836 | case "YesToNo-Client": |
| 3837 | // A client should abort a connection |
| 3838 | // where the server didn't echo EMS |
| 3839 | // when the session used it. |
| 3840 | test.shouldFail = true |
| 3841 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3842 | } |
| 3843 | |
| 3844 | testCases = append(testCases, test) |
| 3845 | } |
| 3846 | } |
| 3847 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3848 | |
| 3849 | // Switching EMS on renegotiation is forbidden. |
| 3850 | testCases = append(testCases, testCase{ |
| 3851 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3852 | config: Config{ |
| 3853 | MaxVersion: VersionTLS12, |
| 3854 | Bugs: ProtocolBugs{ |
| 3855 | NoExtendedMasterSecret: true, |
| 3856 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3857 | }, |
| 3858 | }, |
| 3859 | renegotiate: 1, |
| 3860 | flags: []string{ |
| 3861 | "-renegotiate-freely", |
| 3862 | "-expect-total-renegotiations", "1", |
| 3863 | }, |
| 3864 | }) |
| 3865 | |
| 3866 | testCases = append(testCases, testCase{ |
| 3867 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3868 | config: Config{ |
| 3869 | MaxVersion: VersionTLS12, |
| 3870 | Bugs: ProtocolBugs{ |
| 3871 | NoExtendedMasterSecret: true, |
| 3872 | }, |
| 3873 | }, |
| 3874 | renegotiate: 1, |
| 3875 | flags: []string{ |
| 3876 | "-renegotiate-freely", |
| 3877 | "-expect-total-renegotiations", "1", |
| 3878 | }, |
| 3879 | shouldFail: true, |
| 3880 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3881 | }) |
| 3882 | |
| 3883 | testCases = append(testCases, testCase{ |
| 3884 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3885 | config: Config{ |
| 3886 | MaxVersion: VersionTLS12, |
| 3887 | Bugs: ProtocolBugs{ |
| 3888 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3889 | }, |
| 3890 | }, |
| 3891 | renegotiate: 1, |
| 3892 | flags: []string{ |
| 3893 | "-renegotiate-freely", |
| 3894 | "-expect-total-renegotiations", "1", |
| 3895 | }, |
| 3896 | shouldFail: true, |
| 3897 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3898 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3899 | } |
| 3900 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3901 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3902 | protocol protocol |
| 3903 | async bool |
| 3904 | splitHandshake bool |
| 3905 | packHandshakeFlight bool |
| 3906 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3907 | } |
| 3908 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3909 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3910 | // various conditions. Some of these are redundant with other tests, but they |
| 3911 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3912 | func addAllStateMachineCoverageTests() { |
| 3913 | for _, async := range []bool{false, true} { |
| 3914 | for _, protocol := range []protocol{tls, dtls} { |
| 3915 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3916 | protocol: protocol, |
| 3917 | async: async, |
| 3918 | }) |
| 3919 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3920 | protocol: protocol, |
| 3921 | async: async, |
| 3922 | implicitHandshake: true, |
| 3923 | }) |
| 3924 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3925 | protocol: protocol, |
| 3926 | async: async, |
| 3927 | splitHandshake: true, |
| 3928 | }) |
| 3929 | if protocol == tls { |
| 3930 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3931 | protocol: protocol, |
| 3932 | async: async, |
| 3933 | packHandshakeFlight: true, |
| 3934 | }) |
| 3935 | } |
| 3936 | } |
| 3937 | } |
| 3938 | } |
| 3939 | |
| 3940 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3941 | var tests []testCase |
| 3942 | |
| 3943 | // Basic handshake, with resumption. Client and server, |
| 3944 | // session ID and session ticket. |
| 3945 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3946 | name: "Basic-Client", |
| 3947 | config: Config{ |
| 3948 | MaxVersion: VersionTLS12, |
| 3949 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3950 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3951 | // Ensure session tickets are used, not session IDs. |
| 3952 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3953 | }) |
| 3954 | tests = append(tests, testCase{ |
| 3955 | name: "Basic-Client-RenewTicket", |
| 3956 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3957 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3958 | Bugs: ProtocolBugs{ |
| 3959 | RenewTicketOnResume: true, |
| 3960 | }, |
| 3961 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3962 | flags: []string{"-expect-ticket-renewal"}, |
| 3963 | resumeSession: true, |
| 3964 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3965 | }) |
| 3966 | tests = append(tests, testCase{ |
| 3967 | name: "Basic-Client-NoTicket", |
| 3968 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3969 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3970 | SessionTicketsDisabled: true, |
| 3971 | }, |
| 3972 | resumeSession: true, |
| 3973 | }) |
| 3974 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3975 | testType: serverTest, |
| 3976 | name: "Basic-Server", |
| 3977 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3978 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3979 | Bugs: ProtocolBugs{ |
| 3980 | RequireSessionTickets: true, |
| 3981 | }, |
| 3982 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3983 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3984 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3985 | }) |
| 3986 | tests = append(tests, testCase{ |
| 3987 | testType: serverTest, |
| 3988 | name: "Basic-Server-NoTickets", |
| 3989 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3990 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3991 | SessionTicketsDisabled: true, |
| 3992 | }, |
| 3993 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3994 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3995 | }) |
| 3996 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3997 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3998 | name: "Basic-Server-EarlyCallback", |
| 3999 | config: Config{ |
| 4000 | MaxVersion: VersionTLS12, |
| 4001 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4002 | flags: []string{"-use-early-callback"}, |
| 4003 | resumeSession: true, |
| 4004 | }) |
| 4005 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4006 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4007 | if config.protocol == tls { |
| 4008 | tests = append(tests, testCase{ |
| 4009 | name: "TLS13-1RTT-Client", |
| 4010 | config: Config{ |
| 4011 | MaxVersion: VersionTLS13, |
| 4012 | MinVersion: VersionTLS13, |
| 4013 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 4014 | resumeSession: true, |
| 4015 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4016 | }) |
| 4017 | |
| 4018 | tests = append(tests, testCase{ |
| 4019 | testType: serverTest, |
| 4020 | name: "TLS13-1RTT-Server", |
| 4021 | config: Config{ |
| 4022 | MaxVersion: VersionTLS13, |
| 4023 | MinVersion: VersionTLS13, |
| 4024 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 4025 | resumeSession: true, |
| 4026 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 4027 | // TLS 1.3 uses tickets, so the session should not be |
| 4028 | // cached statefully. |
| 4029 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4030 | }) |
| 4031 | |
| 4032 | tests = append(tests, testCase{ |
| 4033 | name: "TLS13-HelloRetryRequest-Client", |
| 4034 | config: Config{ |
| 4035 | MaxVersion: VersionTLS13, |
| 4036 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 4037 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 4038 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4039 | CurvePreferences: []CurveID{CurveP384}, |
| 4040 | Bugs: ProtocolBugs{ |
| 4041 | ExpectMissingKeyShare: true, |
| 4042 | }, |
| 4043 | }, |
| 4044 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4045 | resumeSession: true, |
| 4046 | }) |
| 4047 | |
| 4048 | tests = append(tests, testCase{ |
| 4049 | testType: serverTest, |
| 4050 | name: "TLS13-HelloRetryRequest-Server", |
| 4051 | config: Config{ |
| 4052 | MaxVersion: VersionTLS13, |
| 4053 | MinVersion: VersionTLS13, |
| 4054 | // Require a HelloRetryRequest for every curve. |
| 4055 | DefaultCurves: []CurveID{}, |
| 4056 | }, |
| 4057 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4058 | resumeSession: true, |
| 4059 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4060 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4061 | tests = append(tests, testCase{ |
| 4062 | testType: clientTest, |
| 4063 | name: "TLS13-EarlyData-Client", |
| 4064 | config: Config{ |
| 4065 | MaxVersion: VersionTLS13, |
| 4066 | MinVersion: VersionTLS13, |
| 4067 | MaxEarlyDataSize: 16384, |
| 4068 | }, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4069 | resumeConfig: &Config{ |
| 4070 | MaxVersion: VersionTLS13, |
| 4071 | MinVersion: VersionTLS13, |
| 4072 | MaxEarlyDataSize: 16384, |
| 4073 | Bugs: ProtocolBugs{ |
| 4074 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4075 | }, |
| 4076 | }, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4077 | resumeSession: true, |
| 4078 | flags: []string{ |
| 4079 | "-enable-early-data", |
| 4080 | "-expect-early-data-info", |
| 4081 | "-expect-accept-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4082 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4083 | }, |
| 4084 | }) |
| 4085 | |
| 4086 | tests = append(tests, testCase{ |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4087 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4088 | name: "TLS13Experiment-EarlyData-Client", |
| 4089 | config: Config{ |
| 4090 | MaxVersion: VersionTLS13, |
| 4091 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4092 | MaxEarlyDataSize: 16384, |
| 4093 | }, |
| 4094 | resumeConfig: &Config{ |
| 4095 | MaxVersion: VersionTLS13, |
| 4096 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4097 | MaxEarlyDataSize: 16384, |
| 4098 | Bugs: ProtocolBugs{ |
| 4099 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4100 | }, |
| 4101 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4102 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4103 | resumeSession: true, |
| 4104 | flags: []string{ |
| 4105 | "-enable-early-data", |
| 4106 | "-expect-early-data-info", |
| 4107 | "-expect-accept-early-data", |
| 4108 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4109 | }, |
| 4110 | }) |
| 4111 | |
| 4112 | tests = append(tests, testCase{ |
| 4113 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4114 | name: "TLS13RecordTypeExperiment-EarlyData-Client", |
| 4115 | config: Config{ |
| 4116 | MaxVersion: VersionTLS13, |
| 4117 | MinVersion: VersionTLS13, |
| 4118 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4119 | MaxEarlyDataSize: 16384, |
| 4120 | }, |
| 4121 | resumeConfig: &Config{ |
| 4122 | MaxVersion: VersionTLS13, |
| 4123 | MinVersion: VersionTLS13, |
| 4124 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4125 | MaxEarlyDataSize: 16384, |
| 4126 | Bugs: ProtocolBugs{ |
| 4127 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4128 | }, |
| 4129 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4130 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4131 | resumeSession: true, |
| 4132 | flags: []string{ |
| 4133 | "-enable-early-data", |
| 4134 | "-expect-early-data-info", |
| 4135 | "-expect-accept-early-data", |
| 4136 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4137 | }, |
| 4138 | }) |
| 4139 | |
| 4140 | tests = append(tests, testCase{ |
| 4141 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4142 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 4143 | config: Config{ |
| 4144 | MaxVersion: VersionTLS13, |
| 4145 | MinVersion: VersionTLS13, |
| 4146 | MaxEarlyDataSize: 2, |
| 4147 | }, |
| 4148 | resumeConfig: &Config{ |
| 4149 | MaxVersion: VersionTLS13, |
| 4150 | MinVersion: VersionTLS13, |
| 4151 | MaxEarlyDataSize: 2, |
| 4152 | Bugs: ProtocolBugs{ |
| 4153 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 4154 | }, |
| 4155 | }, |
| 4156 | resumeShimPrefix: "llo", |
| 4157 | resumeSession: true, |
| 4158 | flags: []string{ |
| 4159 | "-enable-early-data", |
| 4160 | "-expect-early-data-info", |
| 4161 | "-expect-accept-early-data", |
| 4162 | "-on-resume-shim-writes-first", |
| 4163 | }, |
| 4164 | }) |
| 4165 | |
| 4166 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 4167 | // can't be tested as part of an ImplicitHandshake in this case since |
| 4168 | // otherwise the early data will be sent as normal data. |
| 4169 | if config.async && !config.implicitHandshake { |
| 4170 | tests = append(tests, testCase{ |
| 4171 | testType: clientTest, |
| 4172 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 4173 | config: Config{ |
| 4174 | MaxVersion: VersionTLS13, |
| 4175 | MinVersion: VersionTLS13, |
| 4176 | MaxEarlyDataSize: 16384, |
| 4177 | }, |
| 4178 | resumeConfig: &Config{ |
| 4179 | MaxVersion: VersionTLS13, |
| 4180 | MinVersion: VersionTLS13, |
| 4181 | MaxEarlyDataSize: 16384, |
| 4182 | Bugs: ProtocolBugs{ |
| 4183 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4184 | }, |
| 4185 | }, |
| 4186 | resumeSession: true, |
| 4187 | flags: []string{ |
| 4188 | "-enable-early-data", |
| 4189 | "-expect-early-data-info", |
| 4190 | "-expect-accept-early-data", |
| 4191 | "-on-resume-read-with-unfinished-write", |
| 4192 | "-on-resume-shim-writes-first", |
| 4193 | }, |
| 4194 | }) |
| 4195 | |
| 4196 | // Rejected unfinished writes are discarded (from the |
| 4197 | // perspective of the calling application) on 0-RTT |
| 4198 | // reject. |
| 4199 | tests = append(tests, testCase{ |
| 4200 | testType: clientTest, |
| 4201 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 4202 | config: Config{ |
| 4203 | MaxVersion: VersionTLS13, |
| 4204 | MinVersion: VersionTLS13, |
| 4205 | MaxEarlyDataSize: 16384, |
| 4206 | }, |
| 4207 | resumeConfig: &Config{ |
| 4208 | MaxVersion: VersionTLS13, |
| 4209 | MinVersion: VersionTLS13, |
| 4210 | MaxEarlyDataSize: 16384, |
| 4211 | Bugs: ProtocolBugs{ |
| 4212 | AlwaysRejectEarlyData: true, |
| 4213 | }, |
| 4214 | }, |
| 4215 | resumeSession: true, |
| 4216 | flags: []string{ |
| 4217 | "-enable-early-data", |
| 4218 | "-expect-early-data-info", |
| 4219 | "-expect-reject-early-data", |
| 4220 | "-on-resume-read-with-unfinished-write", |
| 4221 | "-on-resume-shim-writes-first", |
| 4222 | }, |
| 4223 | }) |
| 4224 | } |
| 4225 | |
| 4226 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4227 | testType: serverTest, |
| 4228 | name: "TLS13-EarlyData-Server", |
| 4229 | config: Config{ |
| 4230 | MaxVersion: VersionTLS13, |
| 4231 | MinVersion: VersionTLS13, |
| 4232 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4233 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4234 | ExpectEarlyDataAccepted: true, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4235 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4236 | }, |
| 4237 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4238 | messageCount: 2, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4239 | resumeSession: true, |
| 4240 | flags: []string{ |
| 4241 | "-enable-early-data", |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4242 | "-expect-accept-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4243 | }, |
| 4244 | }) |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4245 | |
| 4246 | tests = append(tests, testCase{ |
| 4247 | testType: serverTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4248 | name: "TLS13Experiment-EarlyData-Server", |
| 4249 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4250 | MaxVersion: VersionTLS13, |
| 4251 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4252 | Bugs: ProtocolBugs{ |
| 4253 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4254 | ExpectEarlyDataAccepted: true, |
| 4255 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4256 | }, |
| 4257 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4258 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4259 | messageCount: 2, |
| 4260 | resumeSession: true, |
| 4261 | flags: []string{ |
| 4262 | "-enable-early-data", |
| 4263 | "-expect-accept-early-data", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4264 | }, |
| 4265 | }) |
| 4266 | |
| 4267 | tests = append(tests, testCase{ |
| 4268 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4269 | name: "TLS13RecordTypeExperiment-EarlyData-Server", |
| 4270 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4271 | MaxVersion: VersionTLS13, |
| 4272 | MinVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4273 | Bugs: ProtocolBugs{ |
| 4274 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4275 | ExpectEarlyDataAccepted: true, |
| 4276 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4277 | }, |
| 4278 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4279 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4280 | messageCount: 2, |
| 4281 | resumeSession: true, |
| 4282 | flags: []string{ |
| 4283 | "-enable-early-data", |
| 4284 | "-expect-accept-early-data", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4285 | }, |
| 4286 | }) |
| 4287 | |
| 4288 | tests = append(tests, testCase{ |
| 4289 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4290 | name: "TLS13-MaxEarlyData-Server", |
| 4291 | config: Config{ |
| 4292 | MaxVersion: VersionTLS13, |
| 4293 | MinVersion: VersionTLS13, |
| 4294 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4295 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4296 | ExpectEarlyDataAccepted: true, |
| 4297 | }, |
| 4298 | }, |
| 4299 | messageCount: 2, |
| 4300 | resumeSession: true, |
| 4301 | flags: []string{ |
| 4302 | "-enable-early-data", |
| 4303 | "-expect-accept-early-data", |
| 4304 | }, |
| 4305 | shouldFail: true, |
| 4306 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4307 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4308 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4309 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4310 | // TLS client auth. |
| 4311 | tests = append(tests, testCase{ |
| 4312 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4313 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4314 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4315 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4316 | ClientAuth: RequestClientCert, |
| 4317 | }, |
| 4318 | }) |
| 4319 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4320 | testType: serverTest, |
| 4321 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4322 | config: Config{ |
| 4323 | MaxVersion: VersionTLS12, |
| 4324 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4325 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4326 | flags: []string{"-verify-peer"}, |
| 4327 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4328 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4329 | tests = append(tests, testCase{ |
| 4330 | testType: clientTest, |
| 4331 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4332 | config: Config{ |
| 4333 | MaxVersion: VersionSSL30, |
| 4334 | ClientAuth: RequestClientCert, |
| 4335 | }, |
| 4336 | }) |
| 4337 | tests = append(tests, testCase{ |
| 4338 | testType: serverTest, |
| 4339 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4340 | config: Config{ |
| 4341 | MaxVersion: VersionSSL30, |
| 4342 | }, |
| 4343 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4344 | flags: []string{"-verify-peer"}, |
| 4345 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4346 | tests = append(tests, testCase{ |
| 4347 | testType: clientTest, |
| 4348 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4349 | config: Config{ |
| 4350 | MaxVersion: VersionTLS13, |
| 4351 | ClientAuth: RequestClientCert, |
| 4352 | }, |
| 4353 | }) |
| 4354 | tests = append(tests, testCase{ |
| 4355 | testType: serverTest, |
| 4356 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4357 | config: Config{ |
| 4358 | MaxVersion: VersionTLS13, |
| 4359 | }, |
| 4360 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4361 | flags: []string{"-verify-peer"}, |
| 4362 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4363 | } |
| 4364 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4365 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4366 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4367 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4368 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4369 | ClientAuth: RequireAnyClientCert, |
| 4370 | }, |
| 4371 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4372 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4373 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4374 | }, |
| 4375 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4376 | tests = append(tests, testCase{ |
| 4377 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4378 | name: "ClientAuth-RSA-Client-TLS13", |
| 4379 | config: Config{ |
| 4380 | MaxVersion: VersionTLS13, |
| 4381 | ClientAuth: RequireAnyClientCert, |
| 4382 | }, |
| 4383 | flags: []string{ |
| 4384 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4385 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4386 | }, |
| 4387 | }) |
| 4388 | tests = append(tests, testCase{ |
| 4389 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4390 | name: "ClientAuth-ECDSA-Client", |
| 4391 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4392 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4393 | ClientAuth: RequireAnyClientCert, |
| 4394 | }, |
| 4395 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4396 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4397 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4398 | }, |
| 4399 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4400 | tests = append(tests, testCase{ |
| 4401 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4402 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4403 | config: Config{ |
| 4404 | MaxVersion: VersionTLS13, |
| 4405 | ClientAuth: RequireAnyClientCert, |
| 4406 | }, |
| 4407 | flags: []string{ |
| 4408 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4409 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4410 | }, |
| 4411 | }) |
| 4412 | tests = append(tests, testCase{ |
| 4413 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4414 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4415 | config: Config{ |
| 4416 | MaxVersion: VersionTLS12, |
| 4417 | ClientAuth: RequestClientCert, |
| 4418 | }, |
| 4419 | flags: []string{"-use-old-client-cert-callback"}, |
| 4420 | }) |
| 4421 | tests = append(tests, testCase{ |
| 4422 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4423 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4424 | config: Config{ |
| 4425 | MaxVersion: VersionTLS13, |
| 4426 | ClientAuth: RequestClientCert, |
| 4427 | }, |
| 4428 | flags: []string{"-use-old-client-cert-callback"}, |
| 4429 | }) |
| 4430 | tests = append(tests, testCase{ |
| 4431 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4432 | name: "ClientAuth-OldCallback", |
| 4433 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4434 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4435 | ClientAuth: RequireAnyClientCert, |
| 4436 | }, |
| 4437 | flags: []string{ |
| 4438 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4439 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4440 | "-use-old-client-cert-callback", |
| 4441 | }, |
| 4442 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4443 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4444 | testType: clientTest, |
| 4445 | name: "ClientAuth-OldCallback-TLS13", |
| 4446 | config: Config{ |
| 4447 | MaxVersion: VersionTLS13, |
| 4448 | ClientAuth: RequireAnyClientCert, |
| 4449 | }, |
| 4450 | flags: []string{ |
| 4451 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4452 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4453 | "-use-old-client-cert-callback", |
| 4454 | }, |
| 4455 | }) |
| 4456 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4457 | testType: serverTest, |
| 4458 | name: "ClientAuth-Server", |
| 4459 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4460 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4461 | Certificates: []Certificate{rsaCertificate}, |
| 4462 | }, |
| 4463 | flags: []string{"-require-any-client-certificate"}, |
| 4464 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4465 | tests = append(tests, testCase{ |
| 4466 | testType: serverTest, |
| 4467 | name: "ClientAuth-Server-TLS13", |
| 4468 | config: Config{ |
| 4469 | MaxVersion: VersionTLS13, |
| 4470 | Certificates: []Certificate{rsaCertificate}, |
| 4471 | }, |
| 4472 | flags: []string{"-require-any-client-certificate"}, |
| 4473 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4474 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4475 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4476 | tests = append(tests, testCase{ |
| 4477 | testType: serverTest, |
| 4478 | name: "Basic-Server-RSA", |
| 4479 | config: Config{ |
| 4480 | MaxVersion: VersionTLS12, |
| 4481 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4482 | }, |
| 4483 | flags: []string{ |
| 4484 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4485 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4486 | }, |
| 4487 | }) |
| 4488 | tests = append(tests, testCase{ |
| 4489 | testType: serverTest, |
| 4490 | name: "Basic-Server-ECDHE-RSA", |
| 4491 | config: Config{ |
| 4492 | MaxVersion: VersionTLS12, |
| 4493 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4494 | }, |
| 4495 | flags: []string{ |
| 4496 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4497 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4498 | }, |
| 4499 | }) |
| 4500 | tests = append(tests, testCase{ |
| 4501 | testType: serverTest, |
| 4502 | name: "Basic-Server-ECDHE-ECDSA", |
| 4503 | config: Config{ |
| 4504 | MaxVersion: VersionTLS12, |
| 4505 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4506 | }, |
| 4507 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4508 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4509 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4510 | }, |
| 4511 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4512 | tests = append(tests, testCase{ |
| 4513 | testType: serverTest, |
| 4514 | name: "Basic-Server-Ed25519", |
| 4515 | config: Config{ |
| 4516 | MaxVersion: VersionTLS12, |
| 4517 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4518 | }, |
| 4519 | flags: []string{ |
| 4520 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4521 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4522 | "-enable-ed25519", |
| 4523 | }, |
| 4524 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4525 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4526 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4527 | tests = append(tests, testCase{ |
| 4528 | name: "SessionTicketsDisabled-Client", |
| 4529 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4530 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4531 | SessionTicketsDisabled: true, |
| 4532 | }, |
| 4533 | }) |
| 4534 | tests = append(tests, testCase{ |
| 4535 | testType: serverTest, |
| 4536 | name: "SessionTicketsDisabled-Server", |
| 4537 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4538 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4539 | SessionTicketsDisabled: true, |
| 4540 | }, |
| 4541 | }) |
| 4542 | |
| 4543 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4544 | // identity hint. |
| 4545 | tests = append(tests, testCase{ |
| 4546 | name: "EmptyPSKHint-Client", |
| 4547 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4548 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4549 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4550 | PreSharedKey: []byte("secret"), |
| 4551 | }, |
| 4552 | flags: []string{"-psk", "secret"}, |
| 4553 | }) |
| 4554 | tests = append(tests, testCase{ |
| 4555 | testType: serverTest, |
| 4556 | name: "EmptyPSKHint-Server", |
| 4557 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4558 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4559 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4560 | PreSharedKey: []byte("secret"), |
| 4561 | }, |
| 4562 | flags: []string{"-psk", "secret"}, |
| 4563 | }) |
| 4564 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4565 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4566 | tests = append(tests, testCase{ |
| 4567 | testType: clientTest, |
| 4568 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4569 | config: Config{ |
| 4570 | MaxVersion: VersionTLS12, |
| 4571 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4572 | flags: []string{ |
| 4573 | "-enable-ocsp-stapling", |
| 4574 | "-expect-ocsp-response", |
| 4575 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4576 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4577 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4578 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4579 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4580 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4581 | testType: serverTest, |
| 4582 | name: "OCSPStapling-Server", |
| 4583 | config: Config{ |
| 4584 | MaxVersion: VersionTLS12, |
| 4585 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4586 | expectedOCSPResponse: testOCSPResponse, |
| 4587 | flags: []string{ |
| 4588 | "-ocsp-response", |
| 4589 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4590 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4591 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4592 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4593 | tests = append(tests, testCase{ |
| 4594 | testType: clientTest, |
| 4595 | name: "OCSPStapling-Client-TLS13", |
| 4596 | config: Config{ |
| 4597 | MaxVersion: VersionTLS13, |
| 4598 | }, |
| 4599 | flags: []string{ |
| 4600 | "-enable-ocsp-stapling", |
| 4601 | "-expect-ocsp-response", |
| 4602 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4603 | "-verify-peer", |
| 4604 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4605 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4606 | }) |
| 4607 | tests = append(tests, testCase{ |
| 4608 | testType: serverTest, |
| 4609 | name: "OCSPStapling-Server-TLS13", |
| 4610 | config: Config{ |
| 4611 | MaxVersion: VersionTLS13, |
| 4612 | }, |
| 4613 | expectedOCSPResponse: testOCSPResponse, |
| 4614 | flags: []string{ |
| 4615 | "-ocsp-response", |
| 4616 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4617 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4618 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4619 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4620 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4621 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4622 | for _, vers := range tlsVersions { |
| 4623 | if config.protocol == dtls && !vers.hasDTLS { |
| 4624 | continue |
| 4625 | } |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4626 | for _, useCustomCallback := range []bool{false, true} { |
| 4627 | for _, testType := range []testType{clientTest, serverTest} { |
| 4628 | suffix := "-Client" |
| 4629 | if testType == serverTest { |
| 4630 | suffix = "-Server" |
| 4631 | } |
| 4632 | suffix += "-" + vers.name |
| 4633 | if useCustomCallback { |
| 4634 | suffix += "-CustomCallback" |
| 4635 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4636 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4637 | flags := []string{"-verify-peer"} |
| 4638 | if testType == serverTest { |
| 4639 | flags = append(flags, "-require-any-client-certificate") |
| 4640 | } |
| 4641 | if useCustomCallback { |
| 4642 | flags = append(flags, "-use-custom-verify-callback") |
| 4643 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4644 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4645 | tests = append(tests, testCase{ |
| 4646 | testType: testType, |
| 4647 | name: "CertificateVerificationSucceed" + suffix, |
| 4648 | config: Config{ |
| 4649 | MaxVersion: vers.version, |
| 4650 | Certificates: []Certificate{rsaCertificate}, |
| 4651 | }, |
| 4652 | tls13Variant: vers.tls13Variant, |
| 4653 | flags: append([]string{"-expect-verify-result"}, flags...), |
| 4654 | resumeSession: true, |
| 4655 | }) |
| 4656 | tests = append(tests, testCase{ |
| 4657 | testType: testType, |
| 4658 | name: "CertificateVerificationFail" + suffix, |
| 4659 | config: Config{ |
| 4660 | MaxVersion: vers.version, |
| 4661 | Certificates: []Certificate{rsaCertificate}, |
| 4662 | }, |
| 4663 | tls13Variant: vers.tls13Variant, |
| 4664 | flags: append([]string{"-verify-fail"}, flags...), |
| 4665 | shouldFail: true, |
| 4666 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4667 | }) |
| 4668 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4669 | } |
| 4670 | |
| 4671 | // By default, the client is in a soft fail mode where the peer |
| 4672 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4673 | tests = append(tests, testCase{ |
| 4674 | testType: clientTest, |
| 4675 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4676 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4677 | MaxVersion: vers.version, |
| 4678 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4679 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4680 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4681 | flags: []string{ |
| 4682 | "-verify-fail", |
| 4683 | "-expect-verify-result", |
| 4684 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4685 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4686 | }) |
| 4687 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4688 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4689 | tests = append(tests, testCase{ |
| 4690 | name: "ShimSendAlert", |
| 4691 | flags: []string{"-send-alert"}, |
| 4692 | shimWritesFirst: true, |
| 4693 | shouldFail: true, |
| 4694 | expectedLocalError: "remote error: decompression failure", |
| 4695 | }) |
| 4696 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4697 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4698 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4699 | name: "Renegotiate-Client", |
| 4700 | config: Config{ |
| 4701 | MaxVersion: VersionTLS12, |
| 4702 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4703 | renegotiate: 1, |
| 4704 | flags: []string{ |
| 4705 | "-renegotiate-freely", |
| 4706 | "-expect-total-renegotiations", "1", |
| 4707 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4708 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4709 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4710 | tests = append(tests, testCase{ |
| 4711 | name: "SendHalfHelloRequest", |
| 4712 | config: Config{ |
| 4713 | MaxVersion: VersionTLS12, |
| 4714 | Bugs: ProtocolBugs{ |
| 4715 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4716 | }, |
| 4717 | }, |
| 4718 | sendHalfHelloRequest: true, |
| 4719 | flags: []string{"-renegotiate-ignore"}, |
| 4720 | shouldFail: true, |
| 4721 | expectedError: ":UNEXPECTED_RECORD:", |
| 4722 | }) |
| 4723 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4724 | // NPN on client and server; results in post-handshake message. |
| 4725 | tests = append(tests, testCase{ |
| 4726 | name: "NPN-Client", |
| 4727 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4728 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4729 | NextProtos: []string{"foo"}, |
| 4730 | }, |
| 4731 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4732 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4733 | expectedNextProto: "foo", |
| 4734 | expectedNextProtoType: npn, |
| 4735 | }) |
| 4736 | tests = append(tests, testCase{ |
| 4737 | testType: serverTest, |
| 4738 | name: "NPN-Server", |
| 4739 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4740 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4741 | NextProtos: []string{"bar"}, |
| 4742 | }, |
| 4743 | flags: []string{ |
| 4744 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4745 | "-expect-next-proto", "bar", |
| 4746 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4747 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4748 | expectedNextProto: "bar", |
| 4749 | expectedNextProtoType: npn, |
| 4750 | }) |
| 4751 | |
| 4752 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4753 | |
| 4754 | // Client does False Start and negotiates NPN. |
| 4755 | tests = append(tests, testCase{ |
| 4756 | name: "FalseStart", |
| 4757 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4758 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4759 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4760 | NextProtos: []string{"foo"}, |
| 4761 | Bugs: ProtocolBugs{ |
| 4762 | ExpectFalseStart: true, |
| 4763 | }, |
| 4764 | }, |
| 4765 | flags: []string{ |
| 4766 | "-false-start", |
| 4767 | "-select-next-proto", "foo", |
| 4768 | }, |
| 4769 | shimWritesFirst: true, |
| 4770 | resumeSession: true, |
| 4771 | }) |
| 4772 | |
| 4773 | // Client does False Start and negotiates ALPN. |
| 4774 | tests = append(tests, testCase{ |
| 4775 | name: "FalseStart-ALPN", |
| 4776 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4777 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4778 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4779 | NextProtos: []string{"foo"}, |
| 4780 | Bugs: ProtocolBugs{ |
| 4781 | ExpectFalseStart: true, |
| 4782 | }, |
| 4783 | }, |
| 4784 | flags: []string{ |
| 4785 | "-false-start", |
| 4786 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4787 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4788 | }, |
| 4789 | shimWritesFirst: true, |
| 4790 | resumeSession: true, |
| 4791 | }) |
| 4792 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4793 | // False Start without session tickets. |
| 4794 | tests = append(tests, testCase{ |
| 4795 | name: "FalseStart-SessionTicketsDisabled", |
| 4796 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4797 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4798 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4799 | NextProtos: []string{"foo"}, |
| 4800 | SessionTicketsDisabled: true, |
| 4801 | Bugs: ProtocolBugs{ |
| 4802 | ExpectFalseStart: true, |
| 4803 | }, |
| 4804 | }, |
| 4805 | flags: []string{ |
| 4806 | "-false-start", |
| 4807 | "-select-next-proto", "foo", |
| 4808 | }, |
| 4809 | shimWritesFirst: true, |
| 4810 | }) |
| 4811 | |
| 4812 | // Server parses a V2ClientHello. |
| 4813 | tests = append(tests, testCase{ |
| 4814 | testType: serverTest, |
| 4815 | name: "SendV2ClientHello", |
| 4816 | config: Config{ |
| 4817 | // Choose a cipher suite that does not involve |
| 4818 | // elliptic curves, so no extensions are |
| 4819 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4820 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4821 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4822 | Bugs: ProtocolBugs{ |
| 4823 | SendV2ClientHello: true, |
| 4824 | }, |
| 4825 | }, |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 4826 | flags: []string{ |
| 4827 | "-expect-msg-callback", |
| 4828 | `read v2clienthello |
| 4829 | write hs 2 |
| 4830 | write hs 11 |
| 4831 | write hs 14 |
| 4832 | read hs 16 |
| 4833 | read ccs |
| 4834 | read hs 20 |
| 4835 | write ccs |
| 4836 | write hs 20 |
| 4837 | read alert 1 0 |
| 4838 | `, |
| 4839 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4840 | }) |
| 4841 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4842 | // Test Channel ID |
| 4843 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4844 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4845 | continue |
| 4846 | } |
| 4847 | // Client sends a Channel ID. |
| 4848 | tests = append(tests, testCase{ |
| 4849 | name: "ChannelID-Client-" + ver.name, |
| 4850 | config: Config{ |
| 4851 | MaxVersion: ver.version, |
| 4852 | RequestChannelID: true, |
| 4853 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4854 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4855 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4856 | resumeSession: true, |
| 4857 | expectChannelID: true, |
| 4858 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4859 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4860 | // Server accepts a Channel ID. |
| 4861 | tests = append(tests, testCase{ |
| 4862 | testType: serverTest, |
| 4863 | name: "ChannelID-Server-" + ver.name, |
| 4864 | config: Config{ |
| 4865 | MaxVersion: ver.version, |
| 4866 | ChannelID: channelIDKey, |
| 4867 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4868 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4869 | flags: []string{ |
| 4870 | "-expect-channel-id", |
| 4871 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4872 | }, |
| 4873 | resumeSession: true, |
| 4874 | expectChannelID: true, |
| 4875 | }) |
| 4876 | |
| 4877 | tests = append(tests, testCase{ |
| 4878 | testType: serverTest, |
| 4879 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4880 | config: Config{ |
| 4881 | MaxVersion: ver.version, |
| 4882 | ChannelID: channelIDKey, |
| 4883 | Bugs: ProtocolBugs{ |
| 4884 | InvalidChannelIDSignature: true, |
| 4885 | }, |
| 4886 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4887 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4888 | flags: []string{"-enable-channel-id"}, |
| 4889 | shouldFail: true, |
| 4890 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4891 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4892 | |
| 4893 | if ver.version < VersionTLS13 { |
| 4894 | // Channel ID requires ECDHE ciphers. |
| 4895 | tests = append(tests, testCase{ |
| 4896 | testType: serverTest, |
| 4897 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4898 | config: Config{ |
| 4899 | MaxVersion: ver.version, |
| 4900 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4901 | ChannelID: channelIDKey, |
| 4902 | }, |
| 4903 | expectChannelID: false, |
| 4904 | flags: []string{"-enable-channel-id"}, |
| 4905 | }) |
| 4906 | |
| 4907 | // Sanity-check setting expectChannelID false works. |
| 4908 | tests = append(tests, testCase{ |
| 4909 | testType: serverTest, |
| 4910 | name: "ChannelID-ECDHE-" + ver.name, |
| 4911 | config: Config{ |
| 4912 | MaxVersion: ver.version, |
| 4913 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4914 | ChannelID: channelIDKey, |
| 4915 | }, |
| 4916 | expectChannelID: false, |
| 4917 | flags: []string{"-enable-channel-id"}, |
| 4918 | shouldFail: true, |
| 4919 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4920 | }) |
| 4921 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4922 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4923 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4924 | // Channel ID and NPN at the same time, to ensure their relative |
| 4925 | // ordering is correct. |
| 4926 | tests = append(tests, testCase{ |
| 4927 | name: "ChannelID-NPN-Client", |
| 4928 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4929 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4930 | RequestChannelID: true, |
| 4931 | NextProtos: []string{"foo"}, |
| 4932 | }, |
| 4933 | flags: []string{ |
| 4934 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4935 | "-select-next-proto", "foo", |
| 4936 | }, |
| 4937 | resumeSession: true, |
| 4938 | expectChannelID: true, |
| 4939 | expectedNextProto: "foo", |
| 4940 | expectedNextProtoType: npn, |
| 4941 | }) |
| 4942 | tests = append(tests, testCase{ |
| 4943 | testType: serverTest, |
| 4944 | name: "ChannelID-NPN-Server", |
| 4945 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4946 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4947 | ChannelID: channelIDKey, |
| 4948 | NextProtos: []string{"bar"}, |
| 4949 | }, |
| 4950 | flags: []string{ |
| 4951 | "-expect-channel-id", |
| 4952 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4953 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4954 | "-expect-next-proto", "bar", |
| 4955 | }, |
| 4956 | resumeSession: true, |
| 4957 | expectChannelID: true, |
| 4958 | expectedNextProto: "bar", |
| 4959 | expectedNextProtoType: npn, |
| 4960 | }) |
| 4961 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4962 | // Bidirectional shutdown with the runner initiating. |
| 4963 | tests = append(tests, testCase{ |
| 4964 | name: "Shutdown-Runner", |
| 4965 | config: Config{ |
| 4966 | Bugs: ProtocolBugs{ |
| 4967 | ExpectCloseNotify: true, |
| 4968 | }, |
| 4969 | }, |
| 4970 | flags: []string{"-check-close-notify"}, |
| 4971 | }) |
| 4972 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4973 | if !config.implicitHandshake { |
| 4974 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4975 | // in the meantime, sends garbage before the close_notify which |
| 4976 | // the shim must ignore. This test is disabled under implicit |
| 4977 | // handshake tests because the shim never reads or writes. |
| 4978 | tests = append(tests, testCase{ |
| 4979 | name: "Shutdown-Shim", |
| 4980 | config: Config{ |
| 4981 | MaxVersion: VersionTLS12, |
| 4982 | Bugs: ProtocolBugs{ |
| 4983 | ExpectCloseNotify: true, |
| 4984 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4985 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4986 | shimShutsDown: true, |
| 4987 | sendEmptyRecords: 1, |
| 4988 | sendWarningAlerts: 1, |
| 4989 | flags: []string{"-check-close-notify"}, |
| 4990 | }) |
| 4991 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4992 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4993 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4994 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4995 | tests = append(tests, testCase{ |
| 4996 | name: "SkipHelloVerifyRequest", |
| 4997 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4998 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4999 | Bugs: ProtocolBugs{ |
| 5000 | SkipHelloVerifyRequest: true, |
| 5001 | }, |
| 5002 | }, |
| 5003 | }) |
| 5004 | } |
| 5005 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 5006 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5007 | test.protocol = config.protocol |
| 5008 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5009 | test.name += "-DTLS" |
| 5010 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5011 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5012 | test.name += "-Async" |
| 5013 | test.flags = append(test.flags, "-async") |
| 5014 | } else { |
| 5015 | test.name += "-Sync" |
| 5016 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5017 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5018 | test.name += "-SplitHandshakeRecords" |
| 5019 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5020 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5021 | test.config.Bugs.MaxPacketLength = 256 |
| 5022 | test.flags = append(test.flags, "-mtu", "256") |
| 5023 | } |
| 5024 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5025 | if config.packHandshakeFlight { |
| 5026 | test.name += "-PackHandshakeFlight" |
| 5027 | test.config.Bugs.PackHandshakeFlight = true |
| 5028 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 5029 | if config.implicitHandshake { |
| 5030 | test.name += "-ImplicitHandshake" |
| 5031 | test.flags = append(test.flags, "-implicit-handshake") |
| 5032 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 5033 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 5034 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 5035 | } |
| 5036 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5037 | func addDDoSCallbackTests() { |
| 5038 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5039 | for _, resume := range []bool{false, true} { |
| 5040 | suffix := "Resume" |
| 5041 | if resume { |
| 5042 | suffix = "No" + suffix |
| 5043 | } |
| 5044 | |
| 5045 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5046 | testType: serverTest, |
| 5047 | name: "Server-DDoS-OK-" + suffix, |
| 5048 | config: Config{ |
| 5049 | MaxVersion: VersionTLS12, |
| 5050 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5051 | flags: []string{"-install-ddos-callback"}, |
| 5052 | resumeSession: resume, |
| 5053 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5054 | testCases = append(testCases, testCase{ |
| 5055 | testType: serverTest, |
| 5056 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 5057 | config: Config{ |
| 5058 | MaxVersion: VersionTLS13, |
| 5059 | }, |
| 5060 | flags: []string{"-install-ddos-callback"}, |
| 5061 | resumeSession: resume, |
| 5062 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5063 | |
| 5064 | failFlag := "-fail-ddos-callback" |
| 5065 | if resume { |
| 5066 | failFlag = "-fail-second-ddos-callback" |
| 5067 | } |
| 5068 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5069 | testType: serverTest, |
| 5070 | name: "Server-DDoS-Reject-" + suffix, |
| 5071 | config: Config{ |
| 5072 | MaxVersion: VersionTLS12, |
| 5073 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5074 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5075 | resumeSession: resume, |
| 5076 | shouldFail: true, |
| 5077 | expectedError: ":CONNECTION_REJECTED:", |
| 5078 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5079 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5080 | testCases = append(testCases, testCase{ |
| 5081 | testType: serverTest, |
| 5082 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 5083 | config: Config{ |
| 5084 | MaxVersion: VersionTLS13, |
| 5085 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5086 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5087 | resumeSession: resume, |
| 5088 | shouldFail: true, |
| 5089 | expectedError: ":CONNECTION_REJECTED:", |
| 5090 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5091 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5092 | } |
| 5093 | } |
| 5094 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5095 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5096 | for _, protocol := range []protocol{tls, dtls} { |
| 5097 | for _, shimVers := range allVersions(protocol) { |
| 5098 | // Assemble flags to disable all newer versions on the shim. |
| 5099 | var flags []string |
| 5100 | for _, vers := range allVersions(protocol) { |
| 5101 | if vers.version > shimVers.version { |
| 5102 | flags = append(flags, vers.excludeFlag) |
| 5103 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5104 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5105 | |
| 5106 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 5107 | |
| 5108 | if shimVers.tls13Variant != 0 { |
| 5109 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5110 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5111 | } |
| 5112 | |
| 5113 | // Test configuring the runner's maximum version. |
| 5114 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5115 | expectedVersion := shimVers.version |
| 5116 | if runnerVers.version < shimVers.version { |
| 5117 | expectedVersion = runnerVers.version |
| 5118 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5119 | // When running and shim have different TLS 1.3 variants enabled, |
| 5120 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5121 | // servers support both variants when enabled when the experiment is |
| 5122 | // enabled. |
| 5123 | expectedServerVersion := expectedVersion |
| 5124 | expectedClientVersion := expectedVersion |
| 5125 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5126 | expectedClientVersion = VersionTLS12 |
| 5127 | expectedServerVersion = VersionTLS12 |
| 5128 | if shimVers.tls13Variant != TLS13Default { |
| 5129 | expectedServerVersion = VersionTLS13 |
| 5130 | } |
| 5131 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5132 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5133 | suffix := shimVers.name + "-" + runnerVers.name |
| 5134 | if protocol == dtls { |
| 5135 | suffix += "-DTLS" |
| 5136 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5137 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5138 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5139 | clientVers := shimVers.version |
| 5140 | if clientVers > VersionTLS10 { |
| 5141 | clientVers = VersionTLS10 |
| 5142 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5143 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5144 | serverVers := expectedServerVersion |
| 5145 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5146 | serverVers = VersionTLS10 |
| 5147 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5148 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5149 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5150 | testCases = append(testCases, testCase{ |
| 5151 | protocol: protocol, |
| 5152 | testType: clientTest, |
| 5153 | name: "VersionNegotiation-Client-" + suffix, |
| 5154 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5155 | MaxVersion: runnerVers.version, |
| 5156 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5157 | Bugs: ProtocolBugs{ |
| 5158 | ExpectInitialRecordVersion: clientVers, |
| 5159 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5160 | }, |
| 5161 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5162 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5163 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5164 | testCases = append(testCases, testCase{ |
| 5165 | protocol: protocol, |
| 5166 | testType: clientTest, |
| 5167 | name: "VersionNegotiation-Client2-" + suffix, |
| 5168 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5169 | MaxVersion: runnerVers.version, |
| 5170 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5171 | Bugs: ProtocolBugs{ |
| 5172 | ExpectInitialRecordVersion: clientVers, |
| 5173 | }, |
| 5174 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5175 | flags: flags2, |
| 5176 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5177 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5178 | |
| 5179 | testCases = append(testCases, testCase{ |
| 5180 | protocol: protocol, |
| 5181 | testType: serverTest, |
| 5182 | name: "VersionNegotiation-Server-" + suffix, |
| 5183 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5184 | MaxVersion: runnerVers.version, |
| 5185 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5186 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5187 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5188 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5189 | }, |
| 5190 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5191 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5192 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5193 | testCases = append(testCases, testCase{ |
| 5194 | protocol: protocol, |
| 5195 | testType: serverTest, |
| 5196 | name: "VersionNegotiation-Server2-" + suffix, |
| 5197 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5198 | MaxVersion: runnerVers.version, |
| 5199 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5200 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5201 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5202 | }, |
| 5203 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5204 | flags: flags2, |
| 5205 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5206 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5207 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5208 | } |
| 5209 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5210 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5211 | // Test the version extension at all versions. |
| 5212 | for _, vers := range tlsVersions { |
| 5213 | protocols := []protocol{tls} |
| 5214 | if vers.hasDTLS { |
| 5215 | protocols = append(protocols, dtls) |
| 5216 | } |
| 5217 | for _, protocol := range protocols { |
| 5218 | suffix := vers.name |
| 5219 | if protocol == dtls { |
| 5220 | suffix += "-DTLS" |
| 5221 | } |
| 5222 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5223 | testCases = append(testCases, testCase{ |
| 5224 | protocol: protocol, |
| 5225 | testType: serverTest, |
| 5226 | name: "VersionNegotiationExtension-" + suffix, |
| 5227 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5228 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5229 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5230 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5231 | }, |
| 5232 | }, |
| 5233 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5234 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5235 | }) |
| 5236 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5237 | } |
| 5238 | |
| 5239 | // If all versions are unknown, negotiation fails. |
| 5240 | testCases = append(testCases, testCase{ |
| 5241 | testType: serverTest, |
| 5242 | name: "NoSupportedVersions", |
| 5243 | config: Config{ |
| 5244 | Bugs: ProtocolBugs{ |
| 5245 | SendSupportedVersions: []uint16{0x1111}, |
| 5246 | }, |
| 5247 | }, |
| 5248 | shouldFail: true, |
| 5249 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5250 | }) |
| 5251 | testCases = append(testCases, testCase{ |
| 5252 | protocol: dtls, |
| 5253 | testType: serverTest, |
| 5254 | name: "NoSupportedVersions-DTLS", |
| 5255 | config: Config{ |
| 5256 | Bugs: ProtocolBugs{ |
| 5257 | SendSupportedVersions: []uint16{0x1111}, |
| 5258 | }, |
| 5259 | }, |
| 5260 | shouldFail: true, |
| 5261 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5262 | }) |
| 5263 | |
| 5264 | testCases = append(testCases, testCase{ |
| 5265 | testType: serverTest, |
| 5266 | name: "ClientHelloVersionTooHigh", |
| 5267 | config: Config{ |
| 5268 | MaxVersion: VersionTLS13, |
| 5269 | Bugs: ProtocolBugs{ |
| 5270 | SendClientVersion: 0x0304, |
| 5271 | OmitSupportedVersions: true, |
| 5272 | }, |
| 5273 | }, |
| 5274 | expectedVersion: VersionTLS12, |
| 5275 | }) |
| 5276 | |
| 5277 | testCases = append(testCases, testCase{ |
| 5278 | testType: serverTest, |
| 5279 | name: "ConflictingVersionNegotiation", |
| 5280 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5281 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5282 | SendClientVersion: VersionTLS12, |
| 5283 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5284 | }, |
| 5285 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5286 | // The extension takes precedence over the ClientHello version. |
| 5287 | expectedVersion: VersionTLS11, |
| 5288 | }) |
| 5289 | |
| 5290 | testCases = append(testCases, testCase{ |
| 5291 | testType: serverTest, |
| 5292 | name: "ConflictingVersionNegotiation-2", |
| 5293 | config: Config{ |
| 5294 | Bugs: ProtocolBugs{ |
| 5295 | SendClientVersion: VersionTLS11, |
| 5296 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5297 | }, |
| 5298 | }, |
| 5299 | // The extension takes precedence over the ClientHello version. |
| 5300 | expectedVersion: VersionTLS12, |
| 5301 | }) |
| 5302 | |
| 5303 | testCases = append(testCases, testCase{ |
| 5304 | testType: serverTest, |
| 5305 | name: "RejectFinalTLS13", |
| 5306 | config: Config{ |
| 5307 | Bugs: ProtocolBugs{ |
| 5308 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5309 | }, |
| 5310 | }, |
| 5311 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5312 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5313 | expectedVersion: VersionTLS12, |
| 5314 | }) |
| 5315 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5316 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5317 | // the ServerHello. |
| 5318 | testCases = append(testCases, testCase{ |
| 5319 | testType: clientTest, |
| 5320 | name: "SupportedVersionSelection-TLS12", |
| 5321 | config: Config{ |
| 5322 | MaxVersion: VersionTLS12, |
| 5323 | Bugs: ProtocolBugs{ |
| 5324 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5325 | }, |
| 5326 | }, |
| 5327 | shouldFail: true, |
| 5328 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5329 | }) |
| 5330 | |
| 5331 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5332 | // supported_versions extension in the ServerHello. |
| 5333 | testCases = append(testCases, testCase{ |
| 5334 | testType: clientTest, |
| 5335 | name: "SupportedVersionSelection-TLS13", |
| 5336 | config: Config{ |
| 5337 | MaxVersion: VersionTLS13, |
| 5338 | Bugs: ProtocolBugs{ |
| 5339 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5340 | }, |
| 5341 | }, |
| 5342 | shouldFail: true, |
| 5343 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5344 | }) |
| 5345 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5346 | // Test that the maximum version is selected regardless of the |
| 5347 | // client-sent order. |
| 5348 | testCases = append(testCases, testCase{ |
| 5349 | testType: serverTest, |
| 5350 | name: "IgnoreClientVersionOrder", |
| 5351 | config: Config{ |
| 5352 | Bugs: ProtocolBugs{ |
| 5353 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5354 | }, |
| 5355 | }, |
| 5356 | expectedVersion: VersionTLS13, |
| 5357 | }) |
| 5358 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5359 | // Test for version tolerance. |
| 5360 | testCases = append(testCases, testCase{ |
| 5361 | testType: serverTest, |
| 5362 | name: "MinorVersionTolerance", |
| 5363 | config: Config{ |
| 5364 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5365 | SendClientVersion: 0x03ff, |
| 5366 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5367 | }, |
| 5368 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5369 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5370 | }) |
| 5371 | testCases = append(testCases, testCase{ |
| 5372 | testType: serverTest, |
| 5373 | name: "MajorVersionTolerance", |
| 5374 | config: Config{ |
| 5375 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5376 | SendClientVersion: 0x0400, |
| 5377 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5378 | }, |
| 5379 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5380 | // TLS 1.3 must be negotiated with the supported_versions |
| 5381 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5382 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5383 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5384 | testCases = append(testCases, testCase{ |
| 5385 | testType: serverTest, |
| 5386 | name: "VersionTolerance-TLS13", |
| 5387 | config: Config{ |
| 5388 | Bugs: ProtocolBugs{ |
| 5389 | // Although TLS 1.3 does not use |
| 5390 | // ClientHello.version, it still tolerates high |
| 5391 | // values there. |
| 5392 | SendClientVersion: 0x0400, |
| 5393 | }, |
| 5394 | }, |
| 5395 | expectedVersion: VersionTLS13, |
| 5396 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5397 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5398 | testCases = append(testCases, testCase{ |
| 5399 | protocol: dtls, |
| 5400 | testType: serverTest, |
| 5401 | name: "MinorVersionTolerance-DTLS", |
| 5402 | config: Config{ |
| 5403 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5404 | SendClientVersion: 0xfe00, |
| 5405 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5406 | }, |
| 5407 | }, |
| 5408 | expectedVersion: VersionTLS12, |
| 5409 | }) |
| 5410 | testCases = append(testCases, testCase{ |
| 5411 | protocol: dtls, |
| 5412 | testType: serverTest, |
| 5413 | name: "MajorVersionTolerance-DTLS", |
| 5414 | config: Config{ |
| 5415 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5416 | SendClientVersion: 0xfdff, |
| 5417 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5418 | }, |
| 5419 | }, |
| 5420 | expectedVersion: VersionTLS12, |
| 5421 | }) |
| 5422 | |
| 5423 | // Test that versions below 3.0 are rejected. |
| 5424 | testCases = append(testCases, testCase{ |
| 5425 | testType: serverTest, |
| 5426 | name: "VersionTooLow", |
| 5427 | config: Config{ |
| 5428 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5429 | SendClientVersion: 0x0200, |
| 5430 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5431 | }, |
| 5432 | }, |
| 5433 | shouldFail: true, |
| 5434 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5435 | }) |
| 5436 | testCases = append(testCases, testCase{ |
| 5437 | protocol: dtls, |
| 5438 | testType: serverTest, |
| 5439 | name: "VersionTooLow-DTLS", |
| 5440 | config: Config{ |
| 5441 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5442 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5443 | }, |
| 5444 | }, |
| 5445 | shouldFail: true, |
| 5446 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5447 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5448 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5449 | testCases = append(testCases, testCase{ |
| 5450 | name: "ServerBogusVersion", |
| 5451 | config: Config{ |
| 5452 | Bugs: ProtocolBugs{ |
| 5453 | SendServerHelloVersion: 0x1234, |
| 5454 | }, |
| 5455 | }, |
| 5456 | shouldFail: true, |
| 5457 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5458 | }) |
| 5459 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5460 | // Test TLS 1.3's downgrade signal. |
| 5461 | testCases = append(testCases, testCase{ |
| 5462 | name: "Downgrade-TLS12-Client", |
| 5463 | config: Config{ |
| 5464 | Bugs: ProtocolBugs{ |
| 5465 | NegotiateVersion: VersionTLS12, |
| 5466 | }, |
| 5467 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5468 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5469 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5470 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5471 | }) |
| 5472 | testCases = append(testCases, testCase{ |
| 5473 | testType: serverTest, |
| 5474 | name: "Downgrade-TLS12-Server", |
| 5475 | config: Config{ |
| 5476 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5477 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5478 | }, |
| 5479 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5480 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5481 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5482 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5483 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5484 | } |
| 5485 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5486 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5487 | for _, protocol := range []protocol{tls, dtls} { |
| 5488 | for _, shimVers := range allVersions(protocol) { |
| 5489 | // Assemble flags to disable all older versions on the shim. |
| 5490 | var flags []string |
| 5491 | for _, vers := range allVersions(protocol) { |
| 5492 | if vers.version < shimVers.version { |
| 5493 | flags = append(flags, vers.excludeFlag) |
| 5494 | } |
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 | |
| 5497 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5498 | |
| 5499 | if shimVers.tls13Variant != 0 { |
| 5500 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5501 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5502 | } |
| 5503 | |
| 5504 | for _, runnerVers := range allVersions(protocol) { |
| 5505 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5506 | // produce consistent minimum versions. |
| 5507 | // |
| 5508 | // TODO(davidben): Fold these tests (the main value is in the |
| 5509 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5510 | // on intended shim behavior, not the shim + runner combination. |
| 5511 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5512 | continue |
| 5513 | } |
| 5514 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5515 | suffix := shimVers.name + "-" + runnerVers.name |
| 5516 | if protocol == dtls { |
| 5517 | suffix += "-DTLS" |
| 5518 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5519 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5520 | var expectedVersion uint16 |
| 5521 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5522 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5523 | if runnerVers.version >= shimVers.version { |
| 5524 | expectedVersion = runnerVers.version |
| 5525 | } else { |
| 5526 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5527 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5528 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5529 | } |
| 5530 | |
| 5531 | testCases = append(testCases, testCase{ |
| 5532 | protocol: protocol, |
| 5533 | testType: clientTest, |
| 5534 | name: "MinimumVersion-Client-" + suffix, |
| 5535 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5536 | MaxVersion: runnerVers.version, |
| 5537 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5538 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5539 | // Ensure the server does not decline to |
| 5540 | // select a version (versions extension) or |
| 5541 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5542 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5543 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5544 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5545 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5546 | flags: flags, |
| 5547 | expectedVersion: expectedVersion, |
| 5548 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5549 | expectedError: expectedError, |
| 5550 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5551 | }) |
| 5552 | testCases = append(testCases, testCase{ |
| 5553 | protocol: protocol, |
| 5554 | testType: clientTest, |
| 5555 | name: "MinimumVersion-Client2-" + suffix, |
| 5556 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5557 | MaxVersion: runnerVers.version, |
| 5558 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5559 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5560 | // Ensure the server does not decline to |
| 5561 | // select a version (versions extension) or |
| 5562 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5563 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5564 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5565 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5566 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5567 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5568 | expectedVersion: expectedVersion, |
| 5569 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5570 | expectedError: expectedError, |
| 5571 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5572 | }) |
| 5573 | |
| 5574 | testCases = append(testCases, testCase{ |
| 5575 | protocol: protocol, |
| 5576 | testType: serverTest, |
| 5577 | name: "MinimumVersion-Server-" + suffix, |
| 5578 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5579 | MaxVersion: runnerVers.version, |
| 5580 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5581 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5582 | flags: flags, |
| 5583 | expectedVersion: expectedVersion, |
| 5584 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5585 | expectedError: expectedError, |
| 5586 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5587 | }) |
| 5588 | testCases = append(testCases, testCase{ |
| 5589 | protocol: protocol, |
| 5590 | testType: serverTest, |
| 5591 | name: "MinimumVersion-Server2-" + suffix, |
| 5592 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5593 | MaxVersion: runnerVers.version, |
| 5594 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5595 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5596 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5597 | expectedVersion: expectedVersion, |
| 5598 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5599 | expectedError: expectedError, |
| 5600 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5601 | }) |
| 5602 | } |
| 5603 | } |
| 5604 | } |
| 5605 | } |
| 5606 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5607 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5608 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5609 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5610 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5611 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5612 | // Repeat extensions tests all versions except SSL 3.0. |
| 5613 | for _, ver := range tlsVersions { |
| 5614 | if ver.version == VersionSSL30 { |
| 5615 | continue |
| 5616 | } |
| 5617 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5618 | // Test that duplicate extensions are rejected. |
| 5619 | testCases = append(testCases, testCase{ |
| 5620 | testType: clientTest, |
| 5621 | name: "DuplicateExtensionClient-" + ver.name, |
| 5622 | config: Config{ |
| 5623 | MaxVersion: ver.version, |
| 5624 | Bugs: ProtocolBugs{ |
| 5625 | DuplicateExtension: true, |
| 5626 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5627 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5628 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5629 | shouldFail: true, |
| 5630 | expectedLocalError: "remote error: error decoding message", |
| 5631 | }) |
| 5632 | testCases = append(testCases, testCase{ |
| 5633 | testType: serverTest, |
| 5634 | name: "DuplicateExtensionServer-" + ver.name, |
| 5635 | config: Config{ |
| 5636 | MaxVersion: ver.version, |
| 5637 | Bugs: ProtocolBugs{ |
| 5638 | DuplicateExtension: true, |
| 5639 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5640 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5641 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5642 | shouldFail: true, |
| 5643 | expectedLocalError: "remote error: error decoding message", |
| 5644 | }) |
| 5645 | |
| 5646 | // Test SNI. |
| 5647 | testCases = append(testCases, testCase{ |
| 5648 | testType: clientTest, |
| 5649 | name: "ServerNameExtensionClient-" + ver.name, |
| 5650 | config: Config{ |
| 5651 | MaxVersion: ver.version, |
| 5652 | Bugs: ProtocolBugs{ |
| 5653 | ExpectServerName: "example.com", |
| 5654 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5655 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5656 | tls13Variant: ver.tls13Variant, |
| 5657 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5658 | }) |
| 5659 | testCases = append(testCases, testCase{ |
| 5660 | testType: clientTest, |
| 5661 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5662 | config: Config{ |
| 5663 | MaxVersion: ver.version, |
| 5664 | Bugs: ProtocolBugs{ |
| 5665 | ExpectServerName: "mismatch.com", |
| 5666 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5667 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5668 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5669 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5670 | shouldFail: true, |
| 5671 | expectedLocalError: "tls: unexpected server name", |
| 5672 | }) |
| 5673 | testCases = append(testCases, testCase{ |
| 5674 | testType: clientTest, |
| 5675 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5676 | config: Config{ |
| 5677 | MaxVersion: ver.version, |
| 5678 | Bugs: ProtocolBugs{ |
| 5679 | ExpectServerName: "missing.com", |
| 5680 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5681 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5682 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5683 | shouldFail: true, |
| 5684 | expectedLocalError: "tls: unexpected server name", |
| 5685 | }) |
| 5686 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5687 | testType: clientTest, |
| 5688 | name: "TolerateServerNameAck-" + ver.name, |
| 5689 | config: Config{ |
| 5690 | MaxVersion: ver.version, |
| 5691 | Bugs: ProtocolBugs{ |
| 5692 | SendServerNameAck: true, |
| 5693 | }, |
| 5694 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5695 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5696 | flags: []string{"-host-name", "example.com"}, |
| 5697 | resumeSession: true, |
| 5698 | }) |
| 5699 | testCases = append(testCases, testCase{ |
| 5700 | testType: clientTest, |
| 5701 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5702 | config: Config{ |
| 5703 | MaxVersion: ver.version, |
| 5704 | Bugs: ProtocolBugs{ |
| 5705 | SendServerNameAck: true, |
| 5706 | }, |
| 5707 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5708 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5709 | shouldFail: true, |
| 5710 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5711 | expectedLocalError: "remote error: unsupported extension", |
| 5712 | }) |
| 5713 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5714 | testType: serverTest, |
| 5715 | name: "ServerNameExtensionServer-" + ver.name, |
| 5716 | config: Config{ |
| 5717 | MaxVersion: ver.version, |
| 5718 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5719 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5720 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5721 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5722 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5723 | }) |
| 5724 | |
| 5725 | // Test ALPN. |
| 5726 | testCases = append(testCases, testCase{ |
| 5727 | testType: clientTest, |
| 5728 | name: "ALPNClient-" + ver.name, |
| 5729 | config: Config{ |
| 5730 | MaxVersion: ver.version, |
| 5731 | NextProtos: []string{"foo"}, |
| 5732 | }, |
| 5733 | flags: []string{ |
| 5734 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5735 | "-expect-alpn", "foo", |
| 5736 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5737 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5738 | expectedNextProto: "foo", |
| 5739 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5740 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5741 | }) |
| 5742 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5743 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5744 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5745 | config: Config{ |
| 5746 | MaxVersion: ver.version, |
| 5747 | Bugs: ProtocolBugs{ |
| 5748 | SendALPN: "baz", |
| 5749 | }, |
| 5750 | }, |
| 5751 | flags: []string{ |
| 5752 | "-advertise-alpn", "\x03foo\x03bar", |
| 5753 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5754 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5755 | shouldFail: true, |
| 5756 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5757 | expectedLocalError: "remote error: illegal parameter", |
| 5758 | }) |
| 5759 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5760 | testType: clientTest, |
| 5761 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5762 | config: Config{ |
| 5763 | MaxVersion: ver.version, |
| 5764 | Bugs: ProtocolBugs{ |
| 5765 | SendALPN: "baz", |
| 5766 | }, |
| 5767 | }, |
| 5768 | flags: []string{ |
| 5769 | "-advertise-alpn", "\x03foo\x03bar", |
| 5770 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5771 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5772 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5773 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5774 | }) |
| 5775 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5776 | testType: serverTest, |
| 5777 | name: "ALPNServer-" + ver.name, |
| 5778 | config: Config{ |
| 5779 | MaxVersion: ver.version, |
| 5780 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5781 | }, |
| 5782 | flags: []string{ |
| 5783 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5784 | "-select-alpn", "foo", |
| 5785 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5786 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5787 | expectedNextProto: "foo", |
| 5788 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5789 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5790 | }) |
| 5791 | testCases = append(testCases, testCase{ |
| 5792 | testType: serverTest, |
| 5793 | name: "ALPNServer-Decline-" + ver.name, |
| 5794 | config: Config{ |
| 5795 | MaxVersion: ver.version, |
| 5796 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5797 | }, |
| 5798 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5799 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5800 | expectNoNextProto: true, |
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 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5804 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5805 | // called once. |
| 5806 | testCases = append(testCases, testCase{ |
| 5807 | testType: serverTest, |
| 5808 | name: "ALPNServer-Async-" + ver.name, |
| 5809 | config: Config{ |
| 5810 | MaxVersion: ver.version, |
| 5811 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5812 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5813 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5814 | }, |
| 5815 | flags: []string{ |
| 5816 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5817 | "-select-alpn", "foo", |
| 5818 | "-async", |
| 5819 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5820 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5821 | expectedNextProto: "foo", |
| 5822 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5823 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5824 | }) |
| 5825 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5826 | var emptyString string |
| 5827 | testCases = append(testCases, testCase{ |
| 5828 | testType: clientTest, |
| 5829 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5830 | config: Config{ |
| 5831 | MaxVersion: ver.version, |
| 5832 | NextProtos: []string{""}, |
| 5833 | Bugs: ProtocolBugs{ |
| 5834 | // A server returning an empty ALPN protocol |
| 5835 | // should be rejected. |
| 5836 | ALPNProtocol: &emptyString, |
| 5837 | }, |
| 5838 | }, |
| 5839 | flags: []string{ |
| 5840 | "-advertise-alpn", "\x03foo", |
| 5841 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5842 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5843 | shouldFail: true, |
| 5844 | expectedError: ":PARSE_TLSEXT:", |
| 5845 | }) |
| 5846 | testCases = append(testCases, testCase{ |
| 5847 | testType: serverTest, |
| 5848 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5849 | config: Config{ |
| 5850 | MaxVersion: ver.version, |
| 5851 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5852 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5853 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5854 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5855 | flags: []string{ |
| 5856 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5857 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5858 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5859 | shouldFail: true, |
| 5860 | expectedError: ":PARSE_TLSEXT:", |
| 5861 | }) |
| 5862 | |
| 5863 | // Test NPN and the interaction with ALPN. |
| 5864 | if ver.version < VersionTLS13 { |
| 5865 | // Test that the server prefers ALPN over NPN. |
| 5866 | testCases = append(testCases, testCase{ |
| 5867 | testType: serverTest, |
| 5868 | name: "ALPNServer-Preferred-" + ver.name, |
| 5869 | config: Config{ |
| 5870 | MaxVersion: ver.version, |
| 5871 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5872 | }, |
| 5873 | flags: []string{ |
| 5874 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5875 | "-select-alpn", "foo", |
| 5876 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5877 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5878 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5879 | expectedNextProto: "foo", |
| 5880 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5881 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5882 | }) |
| 5883 | testCases = append(testCases, testCase{ |
| 5884 | testType: serverTest, |
| 5885 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5886 | config: Config{ |
| 5887 | MaxVersion: ver.version, |
| 5888 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5889 | Bugs: ProtocolBugs{ |
| 5890 | SwapNPNAndALPN: true, |
| 5891 | }, |
| 5892 | }, |
| 5893 | flags: []string{ |
| 5894 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5895 | "-select-alpn", "foo", |
| 5896 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5897 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5898 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5899 | expectedNextProto: "foo", |
| 5900 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5901 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5902 | }) |
| 5903 | |
| 5904 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5905 | testCases = append(testCases, testCase{ |
| 5906 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5907 | config: Config{ |
| 5908 | MaxVersion: ver.version, |
| 5909 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5910 | Bugs: ProtocolBugs{ |
| 5911 | NegotiateALPNAndNPN: true, |
| 5912 | }, |
| 5913 | }, |
| 5914 | flags: []string{ |
| 5915 | "-advertise-alpn", "\x03foo", |
| 5916 | "-select-next-proto", "foo", |
| 5917 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5918 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5919 | shouldFail: true, |
| 5920 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5921 | }) |
| 5922 | testCases = append(testCases, testCase{ |
| 5923 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5924 | config: Config{ |
| 5925 | MaxVersion: ver.version, |
| 5926 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5927 | Bugs: ProtocolBugs{ |
| 5928 | NegotiateALPNAndNPN: true, |
| 5929 | SwapNPNAndALPN: true, |
| 5930 | }, |
| 5931 | }, |
| 5932 | flags: []string{ |
| 5933 | "-advertise-alpn", "\x03foo", |
| 5934 | "-select-next-proto", "foo", |
| 5935 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5936 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5937 | shouldFail: true, |
| 5938 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5939 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5940 | } |
| 5941 | |
| 5942 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5943 | |
| 5944 | // Resume with a corrupt ticket. |
| 5945 | testCases = append(testCases, testCase{ |
| 5946 | testType: serverTest, |
| 5947 | name: "CorruptTicket-" + ver.name, |
| 5948 | config: Config{ |
| 5949 | MaxVersion: ver.version, |
| 5950 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5951 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5952 | in[len(in)-1] ^= 1 |
| 5953 | return in, nil |
| 5954 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5955 | }, |
| 5956 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5957 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5958 | resumeSession: true, |
| 5959 | expectResumeRejected: true, |
| 5960 | }) |
| 5961 | // Test the ticket callback, with and without renewal. |
| 5962 | testCases = append(testCases, testCase{ |
| 5963 | testType: serverTest, |
| 5964 | name: "TicketCallback-" + ver.name, |
| 5965 | config: Config{ |
| 5966 | MaxVersion: ver.version, |
| 5967 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5968 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5969 | resumeSession: true, |
| 5970 | flags: []string{"-use-ticket-callback"}, |
| 5971 | }) |
| 5972 | testCases = append(testCases, testCase{ |
| 5973 | testType: serverTest, |
| 5974 | name: "TicketCallback-Renew-" + ver.name, |
| 5975 | config: Config{ |
| 5976 | MaxVersion: ver.version, |
| 5977 | Bugs: ProtocolBugs{ |
| 5978 | ExpectNewTicket: true, |
| 5979 | }, |
| 5980 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5981 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5982 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5983 | resumeSession: true, |
| 5984 | }) |
| 5985 | |
| 5986 | // Test that the ticket callback is only called once when everything before |
| 5987 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5988 | // certificate selection callbacks run. |
| 5989 | testCases = append(testCases, testCase{ |
| 5990 | testType: serverTest, |
| 5991 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5992 | config: Config{ |
| 5993 | MaxVersion: ver.version, |
| 5994 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5995 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5996 | in[len(in)-1] ^= 1 |
| 5997 | return in, nil |
| 5998 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5999 | }, |
| 6000 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6001 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6002 | resumeSession: true, |
| 6003 | expectResumeRejected: true, |
| 6004 | flags: []string{ |
| 6005 | "-use-ticket-callback", |
| 6006 | "-async", |
| 6007 | }, |
| 6008 | }) |
| 6009 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6010 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6011 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6012 | testCases = append(testCases, testCase{ |
| 6013 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6014 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6015 | config: Config{ |
| 6016 | MaxVersion: ver.version, |
| 6017 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6018 | EmptyTicketSessionID: true, |
| 6019 | }, |
| 6020 | }, |
| 6021 | resumeSession: true, |
| 6022 | }) |
| 6023 | testCases = append(testCases, testCase{ |
| 6024 | testType: serverTest, |
| 6025 | name: "TicketSessionIDLength-16-" + ver.name, |
| 6026 | config: Config{ |
| 6027 | MaxVersion: ver.version, |
| 6028 | Bugs: ProtocolBugs{ |
| 6029 | TicketSessionIDLength: 16, |
| 6030 | }, |
| 6031 | }, |
| 6032 | resumeSession: true, |
| 6033 | }) |
| 6034 | testCases = append(testCases, testCase{ |
| 6035 | testType: serverTest, |
| 6036 | name: "TicketSessionIDLength-32-" + ver.name, |
| 6037 | config: Config{ |
| 6038 | MaxVersion: ver.version, |
| 6039 | Bugs: ProtocolBugs{ |
| 6040 | TicketSessionIDLength: 32, |
| 6041 | }, |
| 6042 | }, |
| 6043 | resumeSession: true, |
| 6044 | }) |
| 6045 | testCases = append(testCases, testCase{ |
| 6046 | testType: serverTest, |
| 6047 | name: "TicketSessionIDLength-33-" + ver.name, |
| 6048 | config: Config{ |
| 6049 | MaxVersion: ver.version, |
| 6050 | Bugs: ProtocolBugs{ |
| 6051 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6052 | }, |
| 6053 | }, |
| 6054 | resumeSession: true, |
| 6055 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6056 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6057 | expectedError: ":DECODE_ERROR:", |
| 6058 | }) |
| 6059 | } |
| 6060 | |
| 6061 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 6062 | // are ignored. |
| 6063 | if ver.hasDTLS { |
| 6064 | testCases = append(testCases, testCase{ |
| 6065 | protocol: dtls, |
| 6066 | name: "SRTP-Client-" + ver.name, |
| 6067 | config: Config{ |
| 6068 | MaxVersion: ver.version, |
| 6069 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6070 | }, |
| 6071 | flags: []string{ |
| 6072 | "-srtp-profiles", |
| 6073 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6074 | }, |
| 6075 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6076 | }) |
| 6077 | testCases = append(testCases, testCase{ |
| 6078 | protocol: dtls, |
| 6079 | testType: serverTest, |
| 6080 | name: "SRTP-Server-" + ver.name, |
| 6081 | config: Config{ |
| 6082 | MaxVersion: ver.version, |
| 6083 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6084 | }, |
| 6085 | flags: []string{ |
| 6086 | "-srtp-profiles", |
| 6087 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6088 | }, |
| 6089 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6090 | }) |
| 6091 | // Test that the MKI is ignored. |
| 6092 | testCases = append(testCases, testCase{ |
| 6093 | protocol: dtls, |
| 6094 | testType: serverTest, |
| 6095 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 6096 | config: Config{ |
| 6097 | MaxVersion: ver.version, |
| 6098 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 6099 | Bugs: ProtocolBugs{ |
| 6100 | SRTPMasterKeyIdentifer: "bogus", |
| 6101 | }, |
| 6102 | }, |
| 6103 | flags: []string{ |
| 6104 | "-srtp-profiles", |
| 6105 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6106 | }, |
| 6107 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6108 | }) |
| 6109 | // Test that SRTP isn't negotiated on the server if there were |
| 6110 | // no matching profiles. |
| 6111 | testCases = append(testCases, testCase{ |
| 6112 | protocol: dtls, |
| 6113 | testType: serverTest, |
| 6114 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6115 | config: Config{ |
| 6116 | MaxVersion: ver.version, |
| 6117 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6118 | }, |
| 6119 | flags: []string{ |
| 6120 | "-srtp-profiles", |
| 6121 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6122 | }, |
| 6123 | expectedSRTPProtectionProfile: 0, |
| 6124 | }) |
| 6125 | // Test that the server returning an invalid SRTP profile is |
| 6126 | // flagged as an error by the client. |
| 6127 | testCases = append(testCases, testCase{ |
| 6128 | protocol: dtls, |
| 6129 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6130 | config: Config{ |
| 6131 | MaxVersion: ver.version, |
| 6132 | Bugs: ProtocolBugs{ |
| 6133 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6134 | }, |
| 6135 | }, |
| 6136 | flags: []string{ |
| 6137 | "-srtp-profiles", |
| 6138 | "SRTP_AES128_CM_SHA1_80", |
| 6139 | }, |
| 6140 | shouldFail: true, |
| 6141 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6142 | }) |
| 6143 | } |
| 6144 | |
| 6145 | // Test SCT list. |
| 6146 | testCases = append(testCases, testCase{ |
| 6147 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6148 | testType: clientTest, |
| 6149 | config: Config{ |
| 6150 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6151 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6152 | flags: []string{ |
| 6153 | "-enable-signed-cert-timestamps", |
| 6154 | "-expect-signed-cert-timestamps", |
| 6155 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6156 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6157 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6158 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6159 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6160 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6161 | var differentSCTList []byte |
| 6162 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6163 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6164 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6165 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6166 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6167 | testCases = append(testCases, testCase{ |
| 6168 | name: "SendSCTListOnResume-" + ver.name, |
| 6169 | config: Config{ |
| 6170 | MaxVersion: ver.version, |
| 6171 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6172 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6173 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6174 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6175 | flags: []string{ |
| 6176 | "-enable-signed-cert-timestamps", |
| 6177 | "-expect-signed-cert-timestamps", |
| 6178 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6179 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6180 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6181 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6182 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6183 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6184 | testCases = append(testCases, testCase{ |
| 6185 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6186 | testType: serverTest, |
| 6187 | config: Config{ |
| 6188 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6189 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6190 | flags: []string{ |
| 6191 | "-signed-cert-timestamps", |
| 6192 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6193 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6194 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6195 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6196 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6197 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6198 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6199 | emptySCTListCert := *testCerts[0].cert |
| 6200 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6201 | |
| 6202 | // Test empty SCT list. |
| 6203 | testCases = append(testCases, testCase{ |
| 6204 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6205 | testType: clientTest, |
| 6206 | config: Config{ |
| 6207 | MaxVersion: ver.version, |
| 6208 | Certificates: []Certificate{emptySCTListCert}, |
| 6209 | }, |
| 6210 | flags: []string{ |
| 6211 | "-enable-signed-cert-timestamps", |
| 6212 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6213 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6214 | shouldFail: true, |
| 6215 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6216 | }) |
| 6217 | |
| 6218 | emptySCTCert := *testCerts[0].cert |
| 6219 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6220 | |
| 6221 | // Test empty SCT in non-empty list. |
| 6222 | testCases = append(testCases, testCase{ |
| 6223 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6224 | testType: clientTest, |
| 6225 | config: Config{ |
| 6226 | MaxVersion: ver.version, |
| 6227 | Certificates: []Certificate{emptySCTCert}, |
| 6228 | }, |
| 6229 | flags: []string{ |
| 6230 | "-enable-signed-cert-timestamps", |
| 6231 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6232 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6233 | shouldFail: true, |
| 6234 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6235 | }) |
| 6236 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6237 | // Test that certificate-related extensions are not sent unsolicited. |
| 6238 | testCases = append(testCases, testCase{ |
| 6239 | testType: serverTest, |
| 6240 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6241 | config: Config{ |
| 6242 | MaxVersion: ver.version, |
| 6243 | Bugs: ProtocolBugs{ |
| 6244 | NoOCSPStapling: true, |
| 6245 | NoSignedCertificateTimestamps: true, |
| 6246 | }, |
| 6247 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6248 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6249 | flags: []string{ |
| 6250 | "-ocsp-response", |
| 6251 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6252 | "-signed-cert-timestamps", |
| 6253 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6254 | }, |
| 6255 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6256 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6257 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6258 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6259 | testType: clientTest, |
| 6260 | name: "ClientHelloPadding", |
| 6261 | config: Config{ |
| 6262 | Bugs: ProtocolBugs{ |
| 6263 | RequireClientHelloSize: 512, |
| 6264 | }, |
| 6265 | }, |
| 6266 | // This hostname just needs to be long enough to push the |
| 6267 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6268 | // long. |
| 6269 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6270 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6271 | |
| 6272 | // Extensions should not function in SSL 3.0. |
| 6273 | testCases = append(testCases, testCase{ |
| 6274 | testType: serverTest, |
| 6275 | name: "SSLv3Extensions-NoALPN", |
| 6276 | config: Config{ |
| 6277 | MaxVersion: VersionSSL30, |
| 6278 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6279 | }, |
| 6280 | flags: []string{ |
| 6281 | "-select-alpn", "foo", |
| 6282 | }, |
| 6283 | expectNoNextProto: true, |
| 6284 | }) |
| 6285 | |
| 6286 | // Test session tickets separately as they follow a different codepath. |
| 6287 | testCases = append(testCases, testCase{ |
| 6288 | testType: serverTest, |
| 6289 | name: "SSLv3Extensions-NoTickets", |
| 6290 | config: Config{ |
| 6291 | MaxVersion: VersionSSL30, |
| 6292 | Bugs: ProtocolBugs{ |
| 6293 | // Historically, session tickets in SSL 3.0 |
| 6294 | // failed in different ways depending on whether |
| 6295 | // the client supported renegotiation_info. |
| 6296 | NoRenegotiationInfo: true, |
| 6297 | }, |
| 6298 | }, |
| 6299 | resumeSession: true, |
| 6300 | }) |
| 6301 | testCases = append(testCases, testCase{ |
| 6302 | testType: serverTest, |
| 6303 | name: "SSLv3Extensions-NoTickets2", |
| 6304 | config: Config{ |
| 6305 | MaxVersion: VersionSSL30, |
| 6306 | }, |
| 6307 | resumeSession: true, |
| 6308 | }) |
| 6309 | |
| 6310 | // But SSL 3.0 does send and process renegotiation_info. |
| 6311 | testCases = append(testCases, testCase{ |
| 6312 | testType: serverTest, |
| 6313 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6314 | config: Config{ |
| 6315 | MaxVersion: VersionSSL30, |
| 6316 | Bugs: ProtocolBugs{ |
| 6317 | RequireRenegotiationInfo: true, |
| 6318 | }, |
| 6319 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6320 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6321 | }) |
| 6322 | testCases = append(testCases, testCase{ |
| 6323 | testType: serverTest, |
| 6324 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6325 | config: Config{ |
| 6326 | MaxVersion: VersionSSL30, |
| 6327 | Bugs: ProtocolBugs{ |
| 6328 | NoRenegotiationInfo: true, |
| 6329 | SendRenegotiationSCSV: true, |
| 6330 | RequireRenegotiationInfo: true, |
| 6331 | }, |
| 6332 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6333 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6334 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6335 | |
| 6336 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6337 | // in ServerHello. |
| 6338 | testCases = append(testCases, testCase{ |
| 6339 | name: "NPN-Forbidden-TLS13", |
| 6340 | config: Config{ |
| 6341 | MaxVersion: VersionTLS13, |
| 6342 | NextProtos: []string{"foo"}, |
| 6343 | Bugs: ProtocolBugs{ |
| 6344 | NegotiateNPNAtAllVersions: true, |
| 6345 | }, |
| 6346 | }, |
| 6347 | flags: []string{"-select-next-proto", "foo"}, |
| 6348 | shouldFail: true, |
| 6349 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6350 | }) |
| 6351 | testCases = append(testCases, testCase{ |
| 6352 | name: "EMS-Forbidden-TLS13", |
| 6353 | config: Config{ |
| 6354 | MaxVersion: VersionTLS13, |
| 6355 | Bugs: ProtocolBugs{ |
| 6356 | NegotiateEMSAtAllVersions: true, |
| 6357 | }, |
| 6358 | }, |
| 6359 | shouldFail: true, |
| 6360 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6361 | }) |
| 6362 | testCases = append(testCases, testCase{ |
| 6363 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6364 | config: Config{ |
| 6365 | MaxVersion: VersionTLS13, |
| 6366 | Bugs: ProtocolBugs{ |
| 6367 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6368 | }, |
| 6369 | }, |
| 6370 | shouldFail: true, |
| 6371 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6372 | }) |
| 6373 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6374 | name: "Ticket-Forbidden-TLS13", |
| 6375 | config: Config{ |
| 6376 | MaxVersion: VersionTLS12, |
| 6377 | }, |
| 6378 | resumeConfig: &Config{ |
| 6379 | MaxVersion: VersionTLS13, |
| 6380 | Bugs: ProtocolBugs{ |
| 6381 | AdvertiseTicketExtension: true, |
| 6382 | }, |
| 6383 | }, |
| 6384 | resumeSession: true, |
| 6385 | shouldFail: true, |
| 6386 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6387 | }) |
| 6388 | |
| 6389 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6390 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6391 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6392 | // implicit in every test.) |
| 6393 | testCases = append(testCases, testCase{ |
| 6394 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6395 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6396 | config: Config{ |
| 6397 | MaxVersion: VersionTLS13, |
| 6398 | NextProtos: []string{"bar"}, |
| 6399 | }, |
| 6400 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6401 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6402 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6403 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6404 | // tolerated. |
| 6405 | testCases = append(testCases, testCase{ |
| 6406 | name: "SendOCSPResponseOnResume-TLS12", |
| 6407 | config: Config{ |
| 6408 | MaxVersion: VersionTLS12, |
| 6409 | Bugs: ProtocolBugs{ |
| 6410 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6411 | }, |
| 6412 | }, |
| 6413 | flags: []string{ |
| 6414 | "-enable-ocsp-stapling", |
| 6415 | "-expect-ocsp-response", |
| 6416 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6417 | }, |
| 6418 | resumeSession: true, |
| 6419 | }) |
| 6420 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6421 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6422 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6423 | config: Config{ |
| 6424 | MaxVersion: VersionTLS13, |
| 6425 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6426 | SendExtensionOnCertificate: testOCSPExtension, |
| 6427 | }, |
| 6428 | }, |
| 6429 | shouldFail: true, |
| 6430 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6431 | }) |
| 6432 | |
| 6433 | testCases = append(testCases, testCase{ |
| 6434 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6435 | config: Config{ |
| 6436 | MaxVersion: VersionTLS13, |
| 6437 | Bugs: ProtocolBugs{ |
| 6438 | SendExtensionOnCertificate: testSCTExtension, |
| 6439 | }, |
| 6440 | }, |
| 6441 | shouldFail: true, |
| 6442 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6443 | }) |
| 6444 | |
| 6445 | // Test that extensions on client certificates are never accepted. |
| 6446 | testCases = append(testCases, testCase{ |
| 6447 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6448 | testType: serverTest, |
| 6449 | config: Config{ |
| 6450 | MaxVersion: VersionTLS13, |
| 6451 | Certificates: []Certificate{rsaCertificate}, |
| 6452 | Bugs: ProtocolBugs{ |
| 6453 | SendExtensionOnCertificate: testOCSPExtension, |
| 6454 | }, |
| 6455 | }, |
| 6456 | flags: []string{ |
| 6457 | "-enable-ocsp-stapling", |
| 6458 | "-require-any-client-certificate", |
| 6459 | }, |
| 6460 | shouldFail: true, |
| 6461 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6462 | }) |
| 6463 | |
| 6464 | testCases = append(testCases, testCase{ |
| 6465 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6466 | config: Config{ |
| 6467 | MaxVersion: VersionTLS13, |
| 6468 | Bugs: ProtocolBugs{ |
| 6469 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6470 | }, |
| 6471 | }, |
| 6472 | shouldFail: true, |
| 6473 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6474 | }) |
| 6475 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6476 | var differentSCTList []byte |
| 6477 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6478 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6479 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6480 | // Test that extensions on intermediates are allowed but ignored. |
| 6481 | testCases = append(testCases, testCase{ |
| 6482 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6483 | config: Config{ |
| 6484 | MaxVersion: VersionTLS13, |
| 6485 | Certificates: []Certificate{rsaChainCertificate}, |
| 6486 | Bugs: ProtocolBugs{ |
| 6487 | // Send different values on the intermediate. This tests |
| 6488 | // the intermediate's extensions do not override the |
| 6489 | // leaf's. |
| 6490 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6491 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6492 | }, |
| 6493 | }, |
| 6494 | flags: []string{ |
| 6495 | "-enable-ocsp-stapling", |
| 6496 | "-expect-ocsp-response", |
| 6497 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6498 | "-enable-signed-cert-timestamps", |
| 6499 | "-expect-signed-cert-timestamps", |
| 6500 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6501 | }, |
| 6502 | resumeSession: true, |
| 6503 | }) |
| 6504 | |
| 6505 | // Test that extensions are not sent on intermediates when configured |
| 6506 | // only for a leaf. |
| 6507 | testCases = append(testCases, testCase{ |
| 6508 | testType: serverTest, |
| 6509 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6510 | config: Config{ |
| 6511 | MaxVersion: VersionTLS13, |
| 6512 | Bugs: ProtocolBugs{ |
| 6513 | ExpectNoExtensionsOnIntermediate: true, |
| 6514 | }, |
| 6515 | }, |
| 6516 | flags: []string{ |
| 6517 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6518 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6519 | "-ocsp-response", |
| 6520 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6521 | "-signed-cert-timestamps", |
| 6522 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6523 | }, |
| 6524 | }) |
| 6525 | |
| 6526 | // Test that extensions are not sent on client certificates. |
| 6527 | testCases = append(testCases, testCase{ |
| 6528 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6529 | config: Config{ |
| 6530 | MaxVersion: VersionTLS13, |
| 6531 | ClientAuth: RequireAnyClientCert, |
| 6532 | }, |
| 6533 | flags: []string{ |
| 6534 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6535 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6536 | "-ocsp-response", |
| 6537 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6538 | "-signed-cert-timestamps", |
| 6539 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6540 | }, |
| 6541 | }) |
| 6542 | |
| 6543 | testCases = append(testCases, testCase{ |
| 6544 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6545 | config: Config{ |
| 6546 | MaxVersion: VersionTLS13, |
| 6547 | Bugs: ProtocolBugs{ |
| 6548 | SendDuplicateCertExtensions: true, |
| 6549 | }, |
| 6550 | }, |
| 6551 | flags: []string{ |
| 6552 | "-enable-ocsp-stapling", |
| 6553 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6554 | }, |
| 6555 | resumeSession: true, |
| 6556 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6557 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6558 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6559 | |
| 6560 | testCases = append(testCases, testCase{ |
| 6561 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6562 | testType: serverTest, |
| 6563 | flags: []string{ |
| 6564 | "-signed-cert-timestamps", |
| 6565 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6566 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6567 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6568 | expectedError: ":INVALID_SCT_LIST:", |
| 6569 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6570 | } |
| 6571 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6572 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6573 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6574 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6575 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6576 | // have session IDs, so skip their cross-resumption |
| 6577 | // tests. |
| 6578 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6579 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6580 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6581 | } |
| 6582 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6583 | protocols := []protocol{tls} |
| 6584 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6585 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6586 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6587 | for _, protocol := range protocols { |
| 6588 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6589 | if protocol == dtls { |
| 6590 | suffix += "-DTLS" |
| 6591 | } |
| 6592 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6593 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6594 | // session resumption. |
| 6595 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6596 | continue |
| 6597 | } |
| 6598 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6599 | if sessionVers.version == resumeVers.version { |
| 6600 | testCases = append(testCases, testCase{ |
| 6601 | protocol: protocol, |
| 6602 | name: "Resume-Client" + suffix, |
| 6603 | resumeSession: true, |
| 6604 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6605 | MaxVersion: sessionVers.version, |
| 6606 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6607 | Bugs: ProtocolBugs{ |
| 6608 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6609 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6610 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6611 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6612 | expectedVersion: sessionVers.version, |
| 6613 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6614 | flags: []string{ |
| 6615 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6616 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6617 | }) |
| 6618 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6619 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6620 | |
| 6621 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6622 | // there is no way to convince a non-lookahead client the |
| 6623 | // session was resumed. It will appear to the client that a |
| 6624 | // stray ChangeCipherSpec was sent. |
| 6625 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6626 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6627 | } |
| 6628 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6629 | testCases = append(testCases, testCase{ |
| 6630 | protocol: protocol, |
| 6631 | name: "Resume-Client-Mismatch" + suffix, |
| 6632 | resumeSession: true, |
| 6633 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6634 | MaxVersion: sessionVers.version, |
| 6635 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6636 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6637 | expectedVersion: sessionVers.version, |
| 6638 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6639 | MaxVersion: resumeVers.version, |
| 6640 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6641 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6642 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6643 | }, |
| 6644 | }, |
| 6645 | expectedResumeVersion: resumeVers.version, |
| 6646 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6647 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6648 | flags: []string{ |
| 6649 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6650 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6651 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6652 | }) |
| 6653 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6654 | |
| 6655 | testCases = append(testCases, testCase{ |
| 6656 | protocol: protocol, |
| 6657 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6658 | resumeSession: true, |
| 6659 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6660 | MaxVersion: sessionVers.version, |
| 6661 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6662 | }, |
| 6663 | expectedVersion: sessionVers.version, |
| 6664 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6665 | MaxVersion: resumeVers.version, |
| 6666 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6667 | }, |
| 6668 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6669 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6670 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6671 | flags: []string{ |
| 6672 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6673 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6674 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6675 | }) |
| 6676 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6677 | testCases = append(testCases, testCase{ |
| 6678 | protocol: protocol, |
| 6679 | testType: serverTest, |
| 6680 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6681 | resumeSession: true, |
| 6682 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6683 | MaxVersion: sessionVers.version, |
| 6684 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6685 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6686 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6687 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6688 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6689 | MaxVersion: resumeVers.version, |
| 6690 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6691 | Bugs: ProtocolBugs{ |
| 6692 | SendBothTickets: true, |
| 6693 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6694 | }, |
| 6695 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6696 | flags: []string{ |
| 6697 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6698 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6699 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6700 | }) |
| 6701 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6702 | } |
| 6703 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6704 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6705 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6706 | testCases = append(testCases, testCase{ |
| 6707 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6708 | name: "ShimTicketRewritable", |
| 6709 | resumeSession: true, |
| 6710 | config: Config{ |
| 6711 | MaxVersion: VersionTLS12, |
| 6712 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6713 | Bugs: ProtocolBugs{ |
| 6714 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6715 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6716 | if err != nil { |
| 6717 | return nil, err |
| 6718 | } |
| 6719 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6720 | }, |
| 6721 | }, |
| 6722 | }, |
| 6723 | flags: []string{ |
| 6724 | "-ticket-key", |
| 6725 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6726 | }, |
| 6727 | }) |
| 6728 | |
| 6729 | // Resumptions are declined if the version does not match. |
| 6730 | testCases = append(testCases, testCase{ |
| 6731 | testType: serverTest, |
| 6732 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6733 | resumeSession: true, |
| 6734 | config: Config{ |
| 6735 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6736 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6737 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6738 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6739 | return SetShimTicketVersion(in, VersionTLS13) |
| 6740 | }, |
| 6741 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6742 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6743 | flags: []string{ |
| 6744 | "-ticket-key", |
| 6745 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6746 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6747 | expectResumeRejected: true, |
| 6748 | }) |
| 6749 | |
| 6750 | testCases = append(testCases, testCase{ |
| 6751 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6752 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6753 | resumeSession: true, |
| 6754 | config: Config{ |
| 6755 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6756 | Bugs: ProtocolBugs{ |
| 6757 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6758 | return SetShimTicketVersion(in, VersionTLS12) |
| 6759 | }, |
| 6760 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6761 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6762 | flags: []string{ |
| 6763 | "-ticket-key", |
| 6764 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6765 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6766 | expectResumeRejected: true, |
| 6767 | }) |
| 6768 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6769 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6770 | testCases = append(testCases, testCase{ |
| 6771 | testType: serverTest, |
| 6772 | name: "Resume-Server-DeclineBadCipher", |
| 6773 | resumeSession: true, |
| 6774 | config: Config{ |
| 6775 | MaxVersion: VersionTLS12, |
| 6776 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6777 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6778 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6779 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6780 | }, |
| 6781 | }, |
| 6782 | }, |
| 6783 | flags: []string{ |
| 6784 | "-ticket-key", |
| 6785 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6786 | }, |
| 6787 | expectResumeRejected: true, |
| 6788 | }) |
| 6789 | |
| 6790 | testCases = append(testCases, testCase{ |
| 6791 | testType: serverTest, |
| 6792 | name: "Resume-Server-DeclineBadCipher-2", |
| 6793 | resumeSession: true, |
| 6794 | config: Config{ |
| 6795 | MaxVersion: VersionTLS12, |
| 6796 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6797 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6798 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6799 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6800 | }, |
| 6801 | }, |
| 6802 | }, |
| 6803 | flags: []string{ |
| 6804 | "-cipher", "AES128", |
| 6805 | "-ticket-key", |
| 6806 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6807 | }, |
| 6808 | expectResumeRejected: true, |
| 6809 | }) |
| 6810 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6811 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6812 | testCases = append(testCases, testCase{ |
| 6813 | testType: serverTest, |
| 6814 | name: "Resume-Server-CipherNotPreferred", |
| 6815 | resumeSession: true, |
| 6816 | config: Config{ |
| 6817 | MaxVersion: VersionTLS12, |
| 6818 | Bugs: ProtocolBugs{ |
| 6819 | ExpectNewTicket: true, |
| 6820 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6821 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6822 | }, |
| 6823 | }, |
| 6824 | }, |
| 6825 | flags: []string{ |
| 6826 | "-ticket-key", |
| 6827 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6828 | }, |
| 6829 | shouldFail: false, |
| 6830 | expectResumeRejected: true, |
| 6831 | }) |
| 6832 | |
| 6833 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6834 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6835 | testCases = append(testCases, testCase{ |
| 6836 | testType: serverTest, |
| 6837 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6838 | resumeSession: true, |
| 6839 | config: Config{ |
| 6840 | MaxVersion: VersionTLS13, |
| 6841 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6842 | Bugs: ProtocolBugs{ |
| 6843 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6844 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6845 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6846 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6847 | }, |
| 6848 | }, |
| 6849 | }, |
| 6850 | flags: []string{ |
| 6851 | "-ticket-key", |
| 6852 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6853 | }, |
| 6854 | shouldFail: false, |
| 6855 | expectResumeRejected: true, |
| 6856 | }) |
| 6857 | |
| 6858 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6859 | testCases = append(testCases, testCase{ |
| 6860 | testType: serverTest, |
| 6861 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6862 | resumeSession: true, |
| 6863 | config: Config{ |
| 6864 | MaxVersion: VersionTLS13, |
| 6865 | Bugs: ProtocolBugs{ |
| 6866 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6867 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6868 | }, |
| 6869 | }, |
| 6870 | }, |
| 6871 | flags: []string{ |
| 6872 | "-ticket-key", |
| 6873 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6874 | }, |
| 6875 | expectResumeRejected: true, |
| 6876 | }) |
| 6877 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6878 | // If the client does not offer the cipher from the session, decline to |
| 6879 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6880 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6881 | testCases = append(testCases, testCase{ |
| 6882 | testType: serverTest, |
| 6883 | name: "Resume-Server-UnofferedCipher", |
| 6884 | resumeSession: true, |
| 6885 | config: Config{ |
| 6886 | MaxVersion: VersionTLS12, |
| 6887 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6888 | }, |
| 6889 | resumeConfig: &Config{ |
| 6890 | MaxVersion: VersionTLS12, |
| 6891 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6892 | Bugs: ProtocolBugs{ |
| 6893 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6894 | }, |
| 6895 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6896 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6897 | }) |
| 6898 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6899 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6900 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6901 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6902 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6903 | testCases = append(testCases, testCase{ |
| 6904 | testType: serverTest, |
| 6905 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6906 | resumeSession: true, |
| 6907 | config: Config{ |
| 6908 | MaxVersion: VersionTLS13, |
| 6909 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6910 | }, |
| 6911 | resumeConfig: &Config{ |
| 6912 | MaxVersion: VersionTLS13, |
| 6913 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6914 | Bugs: ProtocolBugs{ |
| 6915 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6916 | }, |
| 6917 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6918 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6919 | }) |
| 6920 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6921 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6922 | testCases = append(testCases, testCase{ |
| 6923 | name: "Resume-Client-CipherMismatch", |
| 6924 | resumeSession: true, |
| 6925 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6926 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6927 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6928 | }, |
| 6929 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6930 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6931 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6932 | Bugs: ProtocolBugs{ |
| 6933 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6934 | }, |
| 6935 | }, |
| 6936 | shouldFail: true, |
| 6937 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6938 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6939 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6940 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6941 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6942 | testCases = append(testCases, testCase{ |
| 6943 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6944 | resumeSession: true, |
| 6945 | config: Config{ |
| 6946 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6947 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6948 | }, |
| 6949 | resumeConfig: &Config{ |
| 6950 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6951 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6952 | }, |
| 6953 | }) |
| 6954 | |
| 6955 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6956 | testCases = append(testCases, testCase{ |
| 6957 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6958 | resumeSession: true, |
| 6959 | config: Config{ |
| 6960 | MaxVersion: VersionTLS13, |
| 6961 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6962 | }, |
| 6963 | resumeConfig: &Config{ |
| 6964 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6965 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6966 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6967 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6968 | }, |
| 6969 | }, |
| 6970 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6971 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6972 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6973 | |
| 6974 | testCases = append(testCases, testCase{ |
| 6975 | testType: serverTest, |
| 6976 | name: "Resume-Server-BinderWrongLength", |
| 6977 | resumeSession: true, |
| 6978 | config: Config{ |
| 6979 | MaxVersion: VersionTLS13, |
| 6980 | Bugs: ProtocolBugs{ |
| 6981 | SendShortPSKBinder: true, |
| 6982 | }, |
| 6983 | }, |
| 6984 | shouldFail: true, |
| 6985 | expectedLocalError: "remote error: error decrypting message", |
| 6986 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6987 | }) |
| 6988 | |
| 6989 | testCases = append(testCases, testCase{ |
| 6990 | testType: serverTest, |
| 6991 | name: "Resume-Server-NoPSKBinder", |
| 6992 | resumeSession: true, |
| 6993 | config: Config{ |
| 6994 | MaxVersion: VersionTLS13, |
| 6995 | Bugs: ProtocolBugs{ |
| 6996 | SendNoPSKBinder: true, |
| 6997 | }, |
| 6998 | }, |
| 6999 | shouldFail: true, |
| 7000 | expectedLocalError: "remote error: error decoding message", |
| 7001 | expectedError: ":DECODE_ERROR:", |
| 7002 | }) |
| 7003 | |
| 7004 | testCases = append(testCases, testCase{ |
| 7005 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 7006 | name: "Resume-Server-ExtraPSKBinder", |
| 7007 | resumeSession: true, |
| 7008 | config: Config{ |
| 7009 | MaxVersion: VersionTLS13, |
| 7010 | Bugs: ProtocolBugs{ |
| 7011 | SendExtraPSKBinder: true, |
| 7012 | }, |
| 7013 | }, |
| 7014 | shouldFail: true, |
| 7015 | expectedLocalError: "remote error: illegal parameter", |
| 7016 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 7017 | }) |
| 7018 | |
| 7019 | testCases = append(testCases, testCase{ |
| 7020 | testType: serverTest, |
| 7021 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 7022 | resumeSession: true, |
| 7023 | config: Config{ |
| 7024 | MaxVersion: VersionTLS13, |
| 7025 | Bugs: ProtocolBugs{ |
| 7026 | ExtraPSKIdentity: true, |
| 7027 | }, |
| 7028 | }, |
| 7029 | shouldFail: true, |
| 7030 | expectedLocalError: "remote error: illegal parameter", |
| 7031 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 7032 | }) |
| 7033 | |
| 7034 | testCases = append(testCases, testCase{ |
| 7035 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 7036 | name: "Resume-Server-InvalidPSKBinder", |
| 7037 | resumeSession: true, |
| 7038 | config: Config{ |
| 7039 | MaxVersion: VersionTLS13, |
| 7040 | Bugs: ProtocolBugs{ |
| 7041 | SendInvalidPSKBinder: true, |
| 7042 | }, |
| 7043 | }, |
| 7044 | shouldFail: true, |
| 7045 | expectedLocalError: "remote error: error decrypting message", |
| 7046 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 7047 | }) |
| 7048 | |
| 7049 | testCases = append(testCases, testCase{ |
| 7050 | testType: serverTest, |
| 7051 | name: "Resume-Server-PSKBinderFirstExtension", |
| 7052 | resumeSession: true, |
| 7053 | config: Config{ |
| 7054 | MaxVersion: VersionTLS13, |
| 7055 | Bugs: ProtocolBugs{ |
| 7056 | PSKBinderFirst: true, |
| 7057 | }, |
| 7058 | }, |
| 7059 | shouldFail: true, |
| 7060 | expectedLocalError: "remote error: illegal parameter", |
| 7061 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 7062 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 7063 | } |
| 7064 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7065 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 7066 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7067 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7068 | testType: serverTest, |
| 7069 | name: "Renegotiate-Server-Forbidden", |
| 7070 | config: Config{ |
| 7071 | MaxVersion: VersionTLS12, |
| 7072 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7073 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7074 | shouldFail: true, |
| 7075 | expectedError: ":NO_RENEGOTIATION:", |
| 7076 | expectedLocalError: "remote error: no renegotiation", |
| 7077 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7078 | // The server shouldn't echo the renegotiation extension unless |
| 7079 | // requested by the client. |
| 7080 | testCases = append(testCases, testCase{ |
| 7081 | testType: serverTest, |
| 7082 | name: "Renegotiate-Server-NoExt", |
| 7083 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7084 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7085 | Bugs: ProtocolBugs{ |
| 7086 | NoRenegotiationInfo: true, |
| 7087 | RequireRenegotiationInfo: true, |
| 7088 | }, |
| 7089 | }, |
| 7090 | shouldFail: true, |
| 7091 | expectedLocalError: "renegotiation extension missing", |
| 7092 | }) |
| 7093 | // The renegotiation SCSV should be sufficient for the server to echo |
| 7094 | // the extension. |
| 7095 | testCases = append(testCases, testCase{ |
| 7096 | testType: serverTest, |
| 7097 | name: "Renegotiate-Server-NoExt-SCSV", |
| 7098 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7099 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7100 | Bugs: ProtocolBugs{ |
| 7101 | NoRenegotiationInfo: true, |
| 7102 | SendRenegotiationSCSV: true, |
| 7103 | RequireRenegotiationInfo: true, |
| 7104 | }, |
| 7105 | }, |
| 7106 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7107 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7108 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7109 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7110 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7111 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7112 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7113 | }, |
| 7114 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7115 | renegotiate: 1, |
| 7116 | flags: []string{ |
| 7117 | "-renegotiate-freely", |
| 7118 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7119 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7120 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7121 | }) |
| 7122 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7123 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7124 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7125 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7126 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7127 | Bugs: ProtocolBugs{ |
| 7128 | EmptyRenegotiationInfo: true, |
| 7129 | }, |
| 7130 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7131 | flags: []string{"-renegotiate-freely"}, |
| 7132 | shouldFail: true, |
| 7133 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7134 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7135 | }) |
| 7136 | testCases = append(testCases, testCase{ |
| 7137 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7138 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7139 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7140 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7141 | Bugs: ProtocolBugs{ |
| 7142 | BadRenegotiationInfo: true, |
| 7143 | }, |
| 7144 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7145 | flags: []string{"-renegotiate-freely"}, |
| 7146 | shouldFail: true, |
| 7147 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7148 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7149 | }) |
| 7150 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7151 | name: "Renegotiate-Client-BadExt2", |
| 7152 | renegotiate: 1, |
| 7153 | config: Config{ |
| 7154 | MaxVersion: VersionTLS12, |
| 7155 | Bugs: ProtocolBugs{ |
| 7156 | BadRenegotiationInfoEnd: true, |
| 7157 | }, |
| 7158 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7159 | flags: []string{"-renegotiate-freely"}, |
| 7160 | shouldFail: true, |
| 7161 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7162 | expectedLocalError: "handshake failure", |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7163 | }) |
| 7164 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7165 | name: "Renegotiate-Client-Downgrade", |
| 7166 | renegotiate: 1, |
| 7167 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7168 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7169 | Bugs: ProtocolBugs{ |
| 7170 | NoRenegotiationInfoAfterInitial: true, |
| 7171 | }, |
| 7172 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7173 | flags: []string{"-renegotiate-freely"}, |
| 7174 | shouldFail: true, |
| 7175 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7176 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7177 | }) |
| 7178 | testCases = append(testCases, testCase{ |
| 7179 | name: "Renegotiate-Client-Upgrade", |
| 7180 | renegotiate: 1, |
| 7181 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7182 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7183 | Bugs: ProtocolBugs{ |
| 7184 | NoRenegotiationInfoInInitial: true, |
| 7185 | }, |
| 7186 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7187 | flags: []string{"-renegotiate-freely"}, |
| 7188 | shouldFail: true, |
| 7189 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7190 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7191 | }) |
| 7192 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7193 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7194 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7195 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7196 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7197 | Bugs: ProtocolBugs{ |
| 7198 | NoRenegotiationInfo: true, |
| 7199 | }, |
| 7200 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7201 | flags: []string{ |
| 7202 | "-renegotiate-freely", |
| 7203 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7204 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7205 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7206 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7207 | |
| 7208 | // Test that the server may switch ciphers on renegotiation without |
| 7209 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7210 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7211 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7212 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7213 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7214 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7215 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7216 | }, |
| 7217 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7218 | flags: []string{ |
| 7219 | "-renegotiate-freely", |
| 7220 | "-expect-total-renegotiations", "1", |
| 7221 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7222 | }) |
| 7223 | testCases = append(testCases, testCase{ |
| 7224 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7225 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7226 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7227 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7228 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7229 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7230 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7231 | flags: []string{ |
| 7232 | "-renegotiate-freely", |
| 7233 | "-expect-total-renegotiations", "1", |
| 7234 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7235 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7236 | |
| 7237 | // Test that the server may not switch versions on renegotiation. |
| 7238 | testCases = append(testCases, testCase{ |
| 7239 | name: "Renegotiate-Client-SwitchVersion", |
| 7240 | config: Config{ |
| 7241 | MaxVersion: VersionTLS12, |
| 7242 | // Pick a cipher which exists at both versions. |
| 7243 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7244 | Bugs: ProtocolBugs{ |
| 7245 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7246 | // Avoid failing early at the record layer. |
| 7247 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7248 | }, |
| 7249 | }, |
| 7250 | renegotiate: 1, |
| 7251 | flags: []string{ |
| 7252 | "-renegotiate-freely", |
| 7253 | "-expect-total-renegotiations", "1", |
| 7254 | }, |
| 7255 | shouldFail: true, |
| 7256 | expectedError: ":WRONG_SSL_VERSION:", |
| 7257 | }) |
| 7258 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7259 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7260 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7261 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7262 | config: Config{ |
| 7263 | MaxVersion: VersionTLS10, |
| 7264 | Bugs: ProtocolBugs{ |
| 7265 | RequireSameRenegoClientVersion: true, |
| 7266 | }, |
| 7267 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7268 | flags: []string{ |
| 7269 | "-renegotiate-freely", |
| 7270 | "-expect-total-renegotiations", "1", |
| 7271 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7272 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7273 | testCases = append(testCases, testCase{ |
| 7274 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7275 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7276 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7277 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7278 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7279 | NextProtos: []string{"foo"}, |
| 7280 | }, |
| 7281 | flags: []string{ |
| 7282 | "-false-start", |
| 7283 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7284 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7285 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7286 | }, |
| 7287 | shimWritesFirst: true, |
| 7288 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7289 | |
| 7290 | // Client-side renegotiation controls. |
| 7291 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7292 | name: "Renegotiate-Client-Forbidden-1", |
| 7293 | config: Config{ |
| 7294 | MaxVersion: VersionTLS12, |
| 7295 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7296 | renegotiate: 1, |
| 7297 | shouldFail: true, |
| 7298 | expectedError: ":NO_RENEGOTIATION:", |
| 7299 | expectedLocalError: "remote error: no renegotiation", |
| 7300 | }) |
| 7301 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7302 | name: "Renegotiate-Client-Once-1", |
| 7303 | config: Config{ |
| 7304 | MaxVersion: VersionTLS12, |
| 7305 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7306 | renegotiate: 1, |
| 7307 | flags: []string{ |
| 7308 | "-renegotiate-once", |
| 7309 | "-expect-total-renegotiations", "1", |
| 7310 | }, |
| 7311 | }) |
| 7312 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7313 | name: "Renegotiate-Client-Freely-1", |
| 7314 | config: Config{ |
| 7315 | MaxVersion: VersionTLS12, |
| 7316 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7317 | renegotiate: 1, |
| 7318 | flags: []string{ |
| 7319 | "-renegotiate-freely", |
| 7320 | "-expect-total-renegotiations", "1", |
| 7321 | }, |
| 7322 | }) |
| 7323 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7324 | name: "Renegotiate-Client-Once-2", |
| 7325 | config: Config{ |
| 7326 | MaxVersion: VersionTLS12, |
| 7327 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7328 | renegotiate: 2, |
| 7329 | flags: []string{"-renegotiate-once"}, |
| 7330 | shouldFail: true, |
| 7331 | expectedError: ":NO_RENEGOTIATION:", |
| 7332 | expectedLocalError: "remote error: no renegotiation", |
| 7333 | }) |
| 7334 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7335 | name: "Renegotiate-Client-Freely-2", |
| 7336 | config: Config{ |
| 7337 | MaxVersion: VersionTLS12, |
| 7338 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7339 | renegotiate: 2, |
| 7340 | flags: []string{ |
| 7341 | "-renegotiate-freely", |
| 7342 | "-expect-total-renegotiations", "2", |
| 7343 | }, |
| 7344 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7345 | testCases = append(testCases, testCase{ |
| 7346 | name: "Renegotiate-Client-NoIgnore", |
| 7347 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7348 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7349 | Bugs: ProtocolBugs{ |
| 7350 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7351 | }, |
| 7352 | }, |
| 7353 | shouldFail: true, |
| 7354 | expectedError: ":NO_RENEGOTIATION:", |
| 7355 | }) |
| 7356 | testCases = append(testCases, testCase{ |
| 7357 | name: "Renegotiate-Client-Ignore", |
| 7358 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7359 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7360 | Bugs: ProtocolBugs{ |
| 7361 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7362 | }, |
| 7363 | }, |
| 7364 | flags: []string{ |
| 7365 | "-renegotiate-ignore", |
| 7366 | "-expect-total-renegotiations", "0", |
| 7367 | }, |
| 7368 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7369 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7370 | // Renegotiation is not allowed at SSL 3.0. |
| 7371 | testCases = append(testCases, testCase{ |
| 7372 | name: "Renegotiate-Client-SSL3", |
| 7373 | config: Config{ |
| 7374 | MaxVersion: VersionSSL30, |
| 7375 | }, |
| 7376 | renegotiate: 1, |
| 7377 | flags: []string{ |
| 7378 | "-renegotiate-freely", |
| 7379 | "-expect-total-renegotiations", "1", |
| 7380 | }, |
| 7381 | shouldFail: true, |
| 7382 | expectedError: ":NO_RENEGOTIATION:", |
| 7383 | expectedLocalError: "remote error: no renegotiation", |
| 7384 | }) |
| 7385 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7386 | // Renegotiation is not allowed when there is an unfinished write. |
| 7387 | testCases = append(testCases, testCase{ |
| 7388 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7389 | config: Config{ |
| 7390 | MaxVersion: VersionTLS12, |
| 7391 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7392 | renegotiate: 1, |
| 7393 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7394 | flags: []string{ |
| 7395 | "-async", |
| 7396 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7397 | }, |
| 7398 | shouldFail: true, |
| 7399 | expectedError: ":NO_RENEGOTIATION:", |
| 7400 | // We do not successfully send the no_renegotiation alert in |
| 7401 | // this case. https://crbug.com/boringssl/130 |
| 7402 | }) |
| 7403 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7404 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7405 | testCases = append(testCases, testCase{ |
| 7406 | name: "StrayHelloRequest", |
| 7407 | config: Config{ |
| 7408 | MaxVersion: VersionTLS12, |
| 7409 | Bugs: ProtocolBugs{ |
| 7410 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7411 | }, |
| 7412 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7413 | shouldFail: true, |
| 7414 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7415 | }) |
| 7416 | testCases = append(testCases, testCase{ |
| 7417 | name: "StrayHelloRequest-Packed", |
| 7418 | config: Config{ |
| 7419 | MaxVersion: VersionTLS12, |
| 7420 | Bugs: ProtocolBugs{ |
| 7421 | PackHandshakeFlight: true, |
| 7422 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7423 | }, |
| 7424 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7425 | shouldFail: true, |
| 7426 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7427 | }) |
| 7428 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7429 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7430 | // the same record. |
| 7431 | testCases = append(testCases, testCase{ |
| 7432 | name: "Renegotiate-Client-Packed", |
| 7433 | config: Config{ |
| 7434 | MaxVersion: VersionTLS12, |
| 7435 | Bugs: ProtocolBugs{ |
| 7436 | PackHandshakeFlight: true, |
| 7437 | PackHelloRequestWithFinished: true, |
| 7438 | }, |
| 7439 | }, |
| 7440 | renegotiate: 1, |
| 7441 | flags: []string{ |
| 7442 | "-renegotiate-freely", |
| 7443 | "-expect-total-renegotiations", "1", |
| 7444 | }, |
| 7445 | }) |
| 7446 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7447 | // Renegotiation is forbidden in TLS 1.3. |
| 7448 | testCases = append(testCases, testCase{ |
| 7449 | name: "Renegotiate-Client-TLS13", |
| 7450 | config: Config{ |
| 7451 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7452 | Bugs: ProtocolBugs{ |
| 7453 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7454 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7455 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7456 | flags: []string{ |
| 7457 | "-renegotiate-freely", |
| 7458 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7459 | shouldFail: true, |
| 7460 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7461 | }) |
| 7462 | |
| 7463 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7464 | testCases = append(testCases, testCase{ |
| 7465 | name: "StrayHelloRequest-TLS13", |
| 7466 | config: Config{ |
| 7467 | MaxVersion: VersionTLS13, |
| 7468 | Bugs: ProtocolBugs{ |
| 7469 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7470 | }, |
| 7471 | }, |
| 7472 | shouldFail: true, |
| 7473 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7474 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7475 | |
| 7476 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7477 | // always reads as supporting it, regardless of whether it was |
| 7478 | // negotiated. |
| 7479 | testCases = append(testCases, testCase{ |
| 7480 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7481 | config: Config{ |
| 7482 | MaxVersion: VersionTLS13, |
| 7483 | Bugs: ProtocolBugs{ |
| 7484 | NoRenegotiationInfo: true, |
| 7485 | }, |
| 7486 | }, |
| 7487 | flags: []string{ |
| 7488 | "-expect-secure-renegotiation", |
| 7489 | }, |
| 7490 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7491 | |
| 7492 | // Certificates may not change on renegotiation. |
| 7493 | testCases = append(testCases, testCase{ |
| 7494 | name: "Renegotiation-CertificateChange", |
| 7495 | config: Config{ |
| 7496 | MaxVersion: VersionTLS12, |
| 7497 | Certificates: []Certificate{rsaCertificate}, |
| 7498 | Bugs: ProtocolBugs{ |
| 7499 | RenegotiationCertificate: &rsaChainCertificate, |
| 7500 | }, |
| 7501 | }, |
| 7502 | renegotiate: 1, |
| 7503 | flags: []string{"-renegotiate-freely"}, |
| 7504 | shouldFail: true, |
| 7505 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7506 | }) |
| 7507 | testCases = append(testCases, testCase{ |
| 7508 | name: "Renegotiation-CertificateChange-2", |
| 7509 | config: Config{ |
| 7510 | MaxVersion: VersionTLS12, |
| 7511 | Certificates: []Certificate{rsaCertificate}, |
| 7512 | Bugs: ProtocolBugs{ |
| 7513 | RenegotiationCertificate: &rsa1024Certificate, |
| 7514 | }, |
| 7515 | }, |
| 7516 | renegotiate: 1, |
| 7517 | flags: []string{"-renegotiate-freely"}, |
| 7518 | shouldFail: true, |
| 7519 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7520 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7521 | |
| 7522 | // We do not negotiate ALPN after the initial handshake. This is |
| 7523 | // error-prone and only risks bugs in consumers. |
| 7524 | testCases = append(testCases, testCase{ |
| 7525 | testType: clientTest, |
| 7526 | name: "Renegotiation-ForbidALPN", |
| 7527 | config: Config{ |
| 7528 | MaxVersion: VersionTLS12, |
| 7529 | Bugs: ProtocolBugs{ |
| 7530 | // Forcibly negotiate ALPN on both initial and |
| 7531 | // renegotiation handshakes. The test stack will |
| 7532 | // internally check the client does not offer |
| 7533 | // it. |
| 7534 | SendALPN: "foo", |
| 7535 | }, |
| 7536 | }, |
| 7537 | flags: []string{ |
| 7538 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7539 | "-expect-alpn", "foo", |
| 7540 | "-renegotiate-freely", |
| 7541 | }, |
| 7542 | renegotiate: 1, |
| 7543 | shouldFail: true, |
| 7544 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7545 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7546 | } |
| 7547 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7548 | func addDTLSReplayTests() { |
| 7549 | // Test that sequence number replays are detected. |
| 7550 | testCases = append(testCases, testCase{ |
| 7551 | protocol: dtls, |
| 7552 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7553 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7554 | replayWrites: true, |
| 7555 | }) |
| 7556 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7557 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7558 | // than the retransmit window. |
| 7559 | testCases = append(testCases, testCase{ |
| 7560 | protocol: dtls, |
| 7561 | name: "DTLS-Replay-LargeGaps", |
| 7562 | config: Config{ |
| 7563 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7564 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7565 | return in * 127 |
| 7566 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7567 | }, |
| 7568 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7569 | messageCount: 200, |
| 7570 | replayWrites: true, |
| 7571 | }) |
| 7572 | |
| 7573 | // Test the incoming sequence number changing non-monotonically. |
| 7574 | testCases = append(testCases, testCase{ |
| 7575 | protocol: dtls, |
| 7576 | name: "DTLS-Replay-NonMonotonic", |
| 7577 | config: Config{ |
| 7578 | Bugs: ProtocolBugs{ |
| 7579 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7580 | return in ^ 31 |
| 7581 | }, |
| 7582 | }, |
| 7583 | }, |
| 7584 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7585 | replayWrites: true, |
| 7586 | }) |
| 7587 | } |
| 7588 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7589 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7590 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7591 | id signatureAlgorithm |
| 7592 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7593 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7594 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7595 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7596 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7597 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7598 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7599 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7600 | // hash function doesn't have to match the curve and so the same |
| 7601 | // signature algorithm works with P-224. |
| 7602 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7603 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7604 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7605 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7606 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7607 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7608 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7609 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7610 | // Tests for key types prior to TLS 1.2. |
| 7611 | {"RSA", 0, testCertRSA}, |
| 7612 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7613 | } |
| 7614 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7615 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7616 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7617 | |
| 7618 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7619 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7620 | // versions a signing cipher. |
| 7621 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7622 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7623 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7624 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7625 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7626 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7627 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7628 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7629 | var allAlgorithms []signatureAlgorithm |
| 7630 | for _, alg := range testSignatureAlgorithms { |
| 7631 | if alg.id != 0 { |
| 7632 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7633 | } |
| 7634 | } |
| 7635 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7636 | // Make sure each signature algorithm works. Include some fake values in |
| 7637 | // the list and ensure they're ignored. |
| 7638 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7639 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7640 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7641 | continue |
| 7642 | } |
| 7643 | |
| 7644 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7645 | // or remove it in C. |
| 7646 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7647 | continue |
| 7648 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7649 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7650 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7651 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7652 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7653 | shouldSignFail = true |
| 7654 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7655 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7656 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7657 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7658 | shouldSignFail = true |
| 7659 | shouldVerifyFail = true |
| 7660 | } |
| 7661 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7662 | // the curve has to match the hash size. |
| 7663 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7664 | shouldSignFail = true |
| 7665 | shouldVerifyFail = true |
| 7666 | } |
| 7667 | |
| 7668 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7669 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7670 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7671 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7672 | |
| 7673 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7674 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7675 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7676 | } |
| 7677 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7678 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7679 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7680 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7681 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7682 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7683 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7684 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7685 | config: Config{ |
| 7686 | MaxVersion: ver.version, |
| 7687 | ClientAuth: RequireAnyClientCert, |
| 7688 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7689 | fakeSigAlg1, |
| 7690 | alg.id, |
| 7691 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7692 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7693 | }, |
| 7694 | flags: []string{ |
| 7695 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7696 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7697 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7698 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7699 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7700 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7701 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7702 | expectedError: signError, |
| 7703 | expectedPeerSignatureAlgorithm: alg.id, |
| 7704 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7705 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7706 | testCases = append(testCases, testCase{ |
| 7707 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7708 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7709 | config: Config{ |
| 7710 | MaxVersion: ver.version, |
| 7711 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7712 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7713 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7714 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7715 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7716 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7717 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7718 | // Some signature algorithms may not be advertised. |
| 7719 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7720 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7721 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7722 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7723 | flags: []string{ |
| 7724 | "-require-any-client-certificate", |
| 7725 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7726 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7727 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7728 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7729 | // Resume the session to assert the peer signature |
| 7730 | // algorithm is reported on both handshakes. |
| 7731 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7732 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7733 | expectedError: verifyError, |
| 7734 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7735 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7736 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7737 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7738 | testCases = append(testCases, testCase{ |
| 7739 | testType: serverTest, |
| 7740 | name: "ServerAuth-Sign" + suffix, |
| 7741 | config: Config{ |
| 7742 | MaxVersion: ver.version, |
| 7743 | CipherSuites: signingCiphers, |
| 7744 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7745 | fakeSigAlg1, |
| 7746 | alg.id, |
| 7747 | fakeSigAlg2, |
| 7748 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7749 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7750 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7751 | flags: []string{ |
| 7752 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7753 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7754 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7755 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7756 | }, |
| 7757 | shouldFail: shouldSignFail, |
| 7758 | expectedError: signError, |
| 7759 | expectedPeerSignatureAlgorithm: alg.id, |
| 7760 | }) |
| 7761 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7762 | |
| 7763 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7764 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7765 | config: Config{ |
| 7766 | MaxVersion: ver.version, |
| 7767 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7768 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7769 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7770 | alg.id, |
| 7771 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7772 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7773 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7774 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7775 | // Some signature algorithms may not be advertised. |
| 7776 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7777 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7778 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7779 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7780 | flags: []string{ |
| 7781 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7782 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7783 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7784 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7785 | // Resume the session to assert the peer signature |
| 7786 | // algorithm is reported on both handshakes. |
| 7787 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7788 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7789 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7790 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7791 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7792 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7793 | testCases = append(testCases, testCase{ |
| 7794 | testType: serverTest, |
| 7795 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7796 | config: Config{ |
| 7797 | MaxVersion: ver.version, |
| 7798 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7799 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7800 | alg.id, |
| 7801 | }, |
| 7802 | Bugs: ProtocolBugs{ |
| 7803 | InvalidSignature: true, |
| 7804 | }, |
| 7805 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7806 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7807 | flags: []string{ |
| 7808 | "-require-any-client-certificate", |
| 7809 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7810 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7811 | }, |
| 7812 | shouldFail: true, |
| 7813 | expectedError: ":BAD_SIGNATURE:", |
| 7814 | }) |
| 7815 | |
| 7816 | testCases = append(testCases, testCase{ |
| 7817 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7818 | config: Config{ |
| 7819 | MaxVersion: ver.version, |
| 7820 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7821 | CipherSuites: signingCiphers, |
| 7822 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7823 | alg.id, |
| 7824 | }, |
| 7825 | Bugs: ProtocolBugs{ |
| 7826 | InvalidSignature: true, |
| 7827 | }, |
| 7828 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7829 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7830 | flags: []string{ |
| 7831 | "-enable-all-curves", |
| 7832 | "-enable-ed25519", |
| 7833 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7834 | shouldFail: true, |
| 7835 | expectedError: ":BAD_SIGNATURE:", |
| 7836 | }) |
| 7837 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7838 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7839 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7840 | testCases = append(testCases, testCase{ |
| 7841 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7842 | config: Config{ |
| 7843 | MaxVersion: ver.version, |
| 7844 | ClientAuth: RequireAnyClientCert, |
| 7845 | VerifySignatureAlgorithms: allAlgorithms, |
| 7846 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7847 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7848 | flags: []string{ |
| 7849 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7850 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7851 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7852 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7853 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7854 | }, |
| 7855 | expectedPeerSignatureAlgorithm: alg.id, |
| 7856 | }) |
| 7857 | |
| 7858 | testCases = append(testCases, testCase{ |
| 7859 | testType: serverTest, |
| 7860 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7861 | config: Config{ |
| 7862 | MaxVersion: ver.version, |
| 7863 | CipherSuites: signingCiphers, |
| 7864 | VerifySignatureAlgorithms: allAlgorithms, |
| 7865 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7866 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7867 | flags: []string{ |
| 7868 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7869 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7870 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7871 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7872 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7873 | }, |
| 7874 | expectedPeerSignatureAlgorithm: alg.id, |
| 7875 | }) |
| 7876 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7877 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7878 | } |
| 7879 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7880 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7881 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7882 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7883 | config: Config{ |
| 7884 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7885 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7886 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7887 | signatureECDSAWithP521AndSHA512, |
| 7888 | signatureRSAPKCS1WithSHA384, |
| 7889 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7890 | }, |
| 7891 | }, |
| 7892 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7893 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7894 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7895 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7896 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7897 | }) |
| 7898 | |
| 7899 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7900 | name: "ClientAuth-SignatureType-TLS13", |
| 7901 | config: Config{ |
| 7902 | ClientAuth: RequireAnyClientCert, |
| 7903 | MaxVersion: VersionTLS13, |
| 7904 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7905 | signatureECDSAWithP521AndSHA512, |
| 7906 | signatureRSAPKCS1WithSHA384, |
| 7907 | signatureRSAPSSWithSHA384, |
| 7908 | signatureECDSAWithSHA1, |
| 7909 | }, |
| 7910 | }, |
| 7911 | flags: []string{ |
| 7912 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7913 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7914 | }, |
| 7915 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7916 | }) |
| 7917 | |
| 7918 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7919 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7920 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7921 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7922 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7923 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7924 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7925 | signatureECDSAWithP521AndSHA512, |
| 7926 | signatureRSAPKCS1WithSHA384, |
| 7927 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7928 | }, |
| 7929 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7930 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7931 | }) |
| 7932 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7933 | testCases = append(testCases, testCase{ |
| 7934 | testType: serverTest, |
| 7935 | name: "ServerAuth-SignatureType-TLS13", |
| 7936 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7937 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7938 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7939 | signatureECDSAWithP521AndSHA512, |
| 7940 | signatureRSAPKCS1WithSHA384, |
| 7941 | signatureRSAPSSWithSHA384, |
| 7942 | signatureECDSAWithSHA1, |
| 7943 | }, |
| 7944 | }, |
| 7945 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7946 | }) |
| 7947 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7948 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7949 | testCases = append(testCases, testCase{ |
| 7950 | testType: serverTest, |
| 7951 | name: "Verify-ClientAuth-SignatureType", |
| 7952 | config: Config{ |
| 7953 | MaxVersion: VersionTLS12, |
| 7954 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7955 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7956 | signatureRSAPKCS1WithSHA256, |
| 7957 | }, |
| 7958 | Bugs: ProtocolBugs{ |
| 7959 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7960 | }, |
| 7961 | }, |
| 7962 | flags: []string{ |
| 7963 | "-require-any-client-certificate", |
| 7964 | }, |
| 7965 | shouldFail: true, |
| 7966 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7967 | }) |
| 7968 | |
| 7969 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7970 | testType: serverTest, |
| 7971 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7972 | config: Config{ |
| 7973 | MaxVersion: VersionTLS13, |
| 7974 | Certificates: []Certificate{rsaCertificate}, |
| 7975 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7976 | signatureRSAPSSWithSHA256, |
| 7977 | }, |
| 7978 | Bugs: ProtocolBugs{ |
| 7979 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7980 | }, |
| 7981 | }, |
| 7982 | flags: []string{ |
| 7983 | "-require-any-client-certificate", |
| 7984 | }, |
| 7985 | shouldFail: true, |
| 7986 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7987 | }) |
| 7988 | |
| 7989 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7990 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7991 | config: Config{ |
| 7992 | MaxVersion: VersionTLS12, |
| 7993 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7994 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7995 | signatureRSAPKCS1WithSHA256, |
| 7996 | }, |
| 7997 | Bugs: ProtocolBugs{ |
| 7998 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7999 | }, |
| 8000 | }, |
| 8001 | shouldFail: true, |
| 8002 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8003 | }) |
| 8004 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8005 | testCases = append(testCases, testCase{ |
| 8006 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 8007 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8008 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8009 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8010 | signatureRSAPSSWithSHA256, |
| 8011 | }, |
| 8012 | Bugs: ProtocolBugs{ |
| 8013 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8014 | }, |
| 8015 | }, |
| 8016 | shouldFail: true, |
| 8017 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8018 | }) |
| 8019 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8020 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 8021 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8022 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8023 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8024 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8025 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8026 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8027 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8028 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8029 | }, |
| 8030 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8031 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8032 | }, |
| 8033 | }, |
| 8034 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8035 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8036 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8037 | }, |
| 8038 | }) |
| 8039 | |
| 8040 | testCases = append(testCases, testCase{ |
| 8041 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8042 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8043 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8044 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8045 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8046 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8047 | }, |
| 8048 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8049 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8050 | }, |
| 8051 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8052 | flags: []string{ |
| 8053 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8054 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8055 | }, |
| 8056 | }) |
| 8057 | |
| 8058 | testCases = append(testCases, testCase{ |
| 8059 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 8060 | config: Config{ |
| 8061 | MaxVersion: VersionTLS12, |
| 8062 | ClientAuth: RequireAnyClientCert, |
| 8063 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8064 | signatureECDSAWithSHA1, |
| 8065 | }, |
| 8066 | Bugs: ProtocolBugs{ |
| 8067 | NoSignatureAlgorithms: true, |
| 8068 | }, |
| 8069 | }, |
| 8070 | flags: []string{ |
| 8071 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8072 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8073 | }, |
| 8074 | }) |
| 8075 | |
| 8076 | testCases = append(testCases, testCase{ |
| 8077 | testType: serverTest, |
| 8078 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 8079 | config: Config{ |
| 8080 | MaxVersion: VersionTLS12, |
| 8081 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8082 | signatureECDSAWithSHA1, |
| 8083 | }, |
| 8084 | Bugs: ProtocolBugs{ |
| 8085 | NoSignatureAlgorithms: true, |
| 8086 | }, |
| 8087 | }, |
| 8088 | flags: []string{ |
| 8089 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8090 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8091 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8092 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8093 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8094 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8095 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8096 | config: Config{ |
| 8097 | MaxVersion: VersionTLS13, |
| 8098 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8099 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8100 | signatureRSAPKCS1WithSHA1, |
| 8101 | }, |
| 8102 | Bugs: ProtocolBugs{ |
| 8103 | NoSignatureAlgorithms: true, |
| 8104 | }, |
| 8105 | }, |
| 8106 | flags: []string{ |
| 8107 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8108 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8109 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8110 | shouldFail: true, |
| 8111 | // An empty CertificateRequest signature algorithm list is a |
| 8112 | // syntax error in TLS 1.3. |
| 8113 | expectedError: ":DECODE_ERROR:", |
| 8114 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8115 | }) |
| 8116 | |
| 8117 | testCases = append(testCases, testCase{ |
| 8118 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8119 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8120 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8121 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8122 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8123 | signatureRSAPKCS1WithSHA1, |
| 8124 | }, |
| 8125 | Bugs: ProtocolBugs{ |
| 8126 | NoSignatureAlgorithms: true, |
| 8127 | }, |
| 8128 | }, |
| 8129 | shouldFail: true, |
| 8130 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8131 | }) |
| 8132 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8133 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8134 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8135 | testCases = append(testCases, testCase{ |
| 8136 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8137 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8138 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8139 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8140 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8141 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8142 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8143 | }, |
| 8144 | Bugs: ProtocolBugs{ |
| 8145 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8146 | }, |
| 8147 | }, |
| 8148 | flags: []string{"-require-any-client-certificate"}, |
| 8149 | shouldFail: true, |
| 8150 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8151 | }) |
| 8152 | |
| 8153 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8154 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8155 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8156 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8157 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8158 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8159 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8160 | }, |
| 8161 | Bugs: ProtocolBugs{ |
| 8162 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8163 | }, |
| 8164 | }, |
| 8165 | shouldFail: true, |
| 8166 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8167 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8168 | testCases = append(testCases, testCase{ |
| 8169 | testType: serverTest, |
| 8170 | name: "ClientAuth-Enforced-TLS13", |
| 8171 | config: Config{ |
| 8172 | MaxVersion: VersionTLS13, |
| 8173 | Certificates: []Certificate{rsaCertificate}, |
| 8174 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8175 | signatureRSAPKCS1WithMD5, |
| 8176 | }, |
| 8177 | Bugs: ProtocolBugs{ |
| 8178 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8179 | IgnoreSignatureVersionChecks: true, |
| 8180 | }, |
| 8181 | }, |
| 8182 | flags: []string{"-require-any-client-certificate"}, |
| 8183 | shouldFail: true, |
| 8184 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8185 | }) |
| 8186 | |
| 8187 | testCases = append(testCases, testCase{ |
| 8188 | name: "ServerAuth-Enforced-TLS13", |
| 8189 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8190 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8191 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8192 | signatureRSAPKCS1WithMD5, |
| 8193 | }, |
| 8194 | Bugs: ProtocolBugs{ |
| 8195 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8196 | IgnoreSignatureVersionChecks: true, |
| 8197 | }, |
| 8198 | }, |
| 8199 | shouldFail: true, |
| 8200 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8201 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8202 | |
| 8203 | // Test that the agreed upon digest respects the client preferences and |
| 8204 | // the server digests. |
| 8205 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8206 | name: "NoCommonAlgorithms-Digests", |
| 8207 | config: Config{ |
| 8208 | MaxVersion: VersionTLS12, |
| 8209 | ClientAuth: RequireAnyClientCert, |
| 8210 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8211 | signatureRSAPKCS1WithSHA512, |
| 8212 | signatureRSAPKCS1WithSHA1, |
| 8213 | }, |
| 8214 | }, |
| 8215 | flags: []string{ |
| 8216 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8217 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8218 | "-digest-prefs", "SHA256", |
| 8219 | }, |
| 8220 | shouldFail: true, |
| 8221 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8222 | }) |
| 8223 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8224 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8225 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8226 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8227 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8228 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8229 | signatureRSAPKCS1WithSHA512, |
| 8230 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8231 | }, |
| 8232 | }, |
| 8233 | flags: []string{ |
| 8234 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8235 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8236 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8237 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8238 | shouldFail: true, |
| 8239 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8240 | }) |
| 8241 | testCases = append(testCases, testCase{ |
| 8242 | name: "NoCommonAlgorithms-TLS13", |
| 8243 | config: Config{ |
| 8244 | MaxVersion: VersionTLS13, |
| 8245 | ClientAuth: RequireAnyClientCert, |
| 8246 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8247 | signatureRSAPSSWithSHA512, |
| 8248 | signatureRSAPSSWithSHA384, |
| 8249 | }, |
| 8250 | }, |
| 8251 | flags: []string{ |
| 8252 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8253 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8254 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 8255 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8256 | shouldFail: true, |
| 8257 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8258 | }) |
| 8259 | testCases = append(testCases, testCase{ |
| 8260 | name: "Agree-Digest-SHA256", |
| 8261 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8262 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8263 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8264 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8265 | signatureRSAPKCS1WithSHA1, |
| 8266 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8267 | }, |
| 8268 | }, |
| 8269 | flags: []string{ |
| 8270 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8271 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8272 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8273 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8274 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8275 | }) |
| 8276 | testCases = append(testCases, testCase{ |
| 8277 | name: "Agree-Digest-SHA1", |
| 8278 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8279 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8280 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8281 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8282 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8283 | }, |
| 8284 | }, |
| 8285 | flags: []string{ |
| 8286 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8287 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8288 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8289 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8290 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8291 | }) |
| 8292 | testCases = append(testCases, testCase{ |
| 8293 | name: "Agree-Digest-Default", |
| 8294 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8295 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8296 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8297 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8298 | signatureRSAPKCS1WithSHA256, |
| 8299 | signatureECDSAWithP256AndSHA256, |
| 8300 | signatureRSAPKCS1WithSHA1, |
| 8301 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8302 | }, |
| 8303 | }, |
| 8304 | flags: []string{ |
| 8305 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8306 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8307 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8308 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8309 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8310 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8311 | // Test that the signing preference list may include extra algorithms |
| 8312 | // without negotiation problems. |
| 8313 | testCases = append(testCases, testCase{ |
| 8314 | testType: serverTest, |
| 8315 | name: "FilterExtraAlgorithms", |
| 8316 | config: Config{ |
| 8317 | MaxVersion: VersionTLS12, |
| 8318 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8319 | signatureRSAPKCS1WithSHA256, |
| 8320 | }, |
| 8321 | }, |
| 8322 | flags: []string{ |
| 8323 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8324 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8325 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8326 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8327 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8328 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8329 | }, |
| 8330 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8331 | }) |
| 8332 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8333 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8334 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8335 | testCases = append(testCases, testCase{ |
| 8336 | name: "CheckLeafCurve", |
| 8337 | config: Config{ |
| 8338 | MaxVersion: VersionTLS12, |
| 8339 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8340 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8341 | }, |
| 8342 | flags: []string{"-p384-only"}, |
| 8343 | shouldFail: true, |
| 8344 | expectedError: ":BAD_ECC_CERT:", |
| 8345 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8346 | |
| 8347 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8348 | testCases = append(testCases, testCase{ |
| 8349 | name: "CheckLeafCurve-TLS13", |
| 8350 | config: Config{ |
| 8351 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8352 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8353 | }, |
| 8354 | flags: []string{"-p384-only"}, |
| 8355 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8356 | |
| 8357 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8358 | testCases = append(testCases, testCase{ |
| 8359 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8360 | config: Config{ |
| 8361 | MaxVersion: VersionTLS12, |
| 8362 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8363 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8364 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8365 | signatureECDSAWithP384AndSHA384, |
| 8366 | }, |
| 8367 | }, |
| 8368 | }) |
| 8369 | |
| 8370 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8371 | testCases = append(testCases, testCase{ |
| 8372 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8373 | config: Config{ |
| 8374 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8375 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8376 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8377 | signatureECDSAWithP384AndSHA384, |
| 8378 | }, |
| 8379 | Bugs: ProtocolBugs{ |
| 8380 | SkipECDSACurveCheck: true, |
| 8381 | }, |
| 8382 | }, |
| 8383 | shouldFail: true, |
| 8384 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8385 | }) |
| 8386 | |
| 8387 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8388 | // account. |
| 8389 | testCases = append(testCases, testCase{ |
| 8390 | testType: serverTest, |
| 8391 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8392 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8393 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8394 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8395 | signatureECDSAWithP384AndSHA384, |
| 8396 | signatureECDSAWithP256AndSHA256, |
| 8397 | }, |
| 8398 | }, |
| 8399 | flags: []string{ |
| 8400 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8401 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8402 | }, |
| 8403 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8404 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8405 | |
| 8406 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8407 | // server does not attempt to sign in that case. |
| 8408 | testCases = append(testCases, testCase{ |
| 8409 | testType: serverTest, |
| 8410 | name: "RSA-PSS-Large", |
| 8411 | config: Config{ |
| 8412 | MaxVersion: VersionTLS13, |
| 8413 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8414 | signatureRSAPSSWithSHA512, |
| 8415 | }, |
| 8416 | }, |
| 8417 | flags: []string{ |
| 8418 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8419 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8420 | }, |
| 8421 | shouldFail: true, |
| 8422 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8423 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8424 | |
| 8425 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8426 | testCases = append(testCases, testCase{ |
| 8427 | testType: clientTest, |
| 8428 | name: "RSA-PSS-Default-Verify", |
| 8429 | config: Config{ |
| 8430 | MaxVersion: VersionTLS12, |
| 8431 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8432 | signatureRSAPSSWithSHA256, |
| 8433 | }, |
| 8434 | }, |
| 8435 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8436 | }) |
| 8437 | |
| 8438 | testCases = append(testCases, testCase{ |
| 8439 | testType: serverTest, |
| 8440 | name: "RSA-PSS-Default-Sign", |
| 8441 | config: Config{ |
| 8442 | MaxVersion: VersionTLS12, |
| 8443 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8444 | signatureRSAPSSWithSHA256, |
| 8445 | }, |
| 8446 | }, |
| 8447 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8448 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8449 | |
| 8450 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8451 | // Ed25519's signature algorithm. |
| 8452 | testCases = append(testCases, testCase{ |
| 8453 | testType: clientTest, |
| 8454 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8455 | config: Config{ |
| 8456 | MaxVersion: VersionTLS11, |
| 8457 | Certificates: []Certificate{ed25519Certificate}, |
| 8458 | Bugs: ProtocolBugs{ |
| 8459 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8460 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8461 | }, |
| 8462 | }, |
| 8463 | flags: []string{"-enable-ed25519"}, |
| 8464 | shouldFail: true, |
| 8465 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8466 | }) |
| 8467 | testCases = append(testCases, testCase{ |
| 8468 | testType: serverTest, |
| 8469 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8470 | config: Config{ |
| 8471 | MaxVersion: VersionTLS11, |
| 8472 | }, |
| 8473 | flags: []string{ |
| 8474 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8475 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8476 | }, |
| 8477 | shouldFail: true, |
| 8478 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8479 | }) |
| 8480 | testCases = append(testCases, testCase{ |
| 8481 | testType: serverTest, |
| 8482 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8483 | config: Config{ |
| 8484 | MaxVersion: VersionTLS11, |
| 8485 | Certificates: []Certificate{ed25519Certificate}, |
| 8486 | Bugs: ProtocolBugs{ |
| 8487 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8488 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8489 | }, |
| 8490 | }, |
| 8491 | flags: []string{ |
| 8492 | "-enable-ed25519", |
| 8493 | "-require-any-client-certificate", |
| 8494 | }, |
| 8495 | shouldFail: true, |
| 8496 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8497 | }) |
| 8498 | testCases = append(testCases, testCase{ |
| 8499 | testType: clientTest, |
| 8500 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8501 | config: Config{ |
| 8502 | MaxVersion: VersionTLS11, |
| 8503 | ClientAuth: RequireAnyClientCert, |
| 8504 | }, |
| 8505 | flags: []string{ |
| 8506 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8507 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8508 | }, |
| 8509 | shouldFail: true, |
| 8510 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8511 | }) |
| 8512 | |
| 8513 | // Test Ed25519 is not advertised by default. |
| 8514 | testCases = append(testCases, testCase{ |
| 8515 | testType: clientTest, |
| 8516 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8517 | config: Config{ |
| 8518 | Certificates: []Certificate{ed25519Certificate}, |
| 8519 | }, |
| 8520 | shouldFail: true, |
| 8521 | expectedLocalError: "tls: no common signature algorithms", |
| 8522 | }) |
| 8523 | |
| 8524 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8525 | // preferences. |
| 8526 | testCases = append(testCases, testCase{ |
| 8527 | testType: clientTest, |
| 8528 | name: "Ed25519DefaultDisable-NoAccept", |
| 8529 | config: Config{ |
| 8530 | Certificates: []Certificate{ed25519Certificate}, |
| 8531 | Bugs: ProtocolBugs{ |
| 8532 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8533 | }, |
| 8534 | }, |
| 8535 | shouldFail: true, |
| 8536 | expectedLocalError: "remote error: illegal parameter", |
| 8537 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8538 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8539 | |
| 8540 | // Test that configuring verify preferences changes what the client |
| 8541 | // advertises. |
| 8542 | testCases = append(testCases, testCase{ |
| 8543 | name: "VerifyPreferences-Advertised", |
| 8544 | config: Config{ |
| 8545 | Certificates: []Certificate{rsaCertificate}, |
| 8546 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8547 | signatureRSAPSSWithSHA256, |
| 8548 | signatureRSAPSSWithSHA384, |
| 8549 | signatureRSAPSSWithSHA512, |
| 8550 | }, |
| 8551 | }, |
| 8552 | flags: []string{ |
| 8553 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8554 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8555 | }, |
| 8556 | }) |
| 8557 | |
| 8558 | // Test that the client advertises a set which the runner can find |
| 8559 | // nothing in common with. |
| 8560 | testCases = append(testCases, testCase{ |
| 8561 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8562 | config: Config{ |
| 8563 | Certificates: []Certificate{rsaCertificate}, |
| 8564 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8565 | signatureRSAPSSWithSHA256, |
| 8566 | signatureRSAPSSWithSHA512, |
| 8567 | }, |
| 8568 | }, |
| 8569 | flags: []string{ |
| 8570 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8571 | }, |
| 8572 | shouldFail: true, |
| 8573 | expectedLocalError: "tls: no common signature algorithms", |
| 8574 | }) |
| 8575 | |
| 8576 | // Test that the client enforces its preferences when configured. |
| 8577 | testCases = append(testCases, testCase{ |
| 8578 | name: "VerifyPreferences-Enforced", |
| 8579 | config: Config{ |
| 8580 | Certificates: []Certificate{rsaCertificate}, |
| 8581 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8582 | signatureRSAPSSWithSHA256, |
| 8583 | signatureRSAPSSWithSHA512, |
| 8584 | }, |
| 8585 | Bugs: ProtocolBugs{ |
| 8586 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8587 | }, |
| 8588 | }, |
| 8589 | flags: []string{ |
| 8590 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8591 | }, |
| 8592 | shouldFail: true, |
| 8593 | expectedLocalError: "remote error: illegal parameter", |
| 8594 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8595 | }) |
| 8596 | |
| 8597 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8598 | // boolean toggle. |
| 8599 | testCases = append(testCases, testCase{ |
| 8600 | name: "VerifyPreferences-Ed25519", |
| 8601 | config: Config{ |
| 8602 | Certificates: []Certificate{ed25519Certificate}, |
| 8603 | }, |
| 8604 | flags: []string{ |
| 8605 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8606 | }, |
| 8607 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8608 | } |
| 8609 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8610 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8611 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8612 | var timeouts = []time.Duration{ |
| 8613 | 1 * time.Second, |
| 8614 | 2 * time.Second, |
| 8615 | 4 * time.Second, |
| 8616 | 8 * time.Second, |
| 8617 | 16 * time.Second, |
| 8618 | 32 * time.Second, |
| 8619 | 60 * time.Second, |
| 8620 | 60 * time.Second, |
| 8621 | 60 * time.Second, |
| 8622 | 60 * time.Second, |
| 8623 | 60 * time.Second, |
| 8624 | 60 * time.Second, |
| 8625 | 60 * time.Second, |
| 8626 | } |
| 8627 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8628 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8629 | // initial timeout duration was set to 250ms. |
| 8630 | var shortTimeouts = []time.Duration{ |
| 8631 | 250 * time.Millisecond, |
| 8632 | 500 * time.Millisecond, |
| 8633 | 1 * time.Second, |
| 8634 | 2 * time.Second, |
| 8635 | 4 * time.Second, |
| 8636 | 8 * time.Second, |
| 8637 | 16 * time.Second, |
| 8638 | 32 * time.Second, |
| 8639 | 60 * time.Second, |
| 8640 | 60 * time.Second, |
| 8641 | 60 * time.Second, |
| 8642 | 60 * time.Second, |
| 8643 | 60 * time.Second, |
| 8644 | } |
| 8645 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8646 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8647 | // These tests work by coordinating some behavior on both the shim and |
| 8648 | // the runner. |
| 8649 | // |
| 8650 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8651 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8652 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8653 | // timeout in the shim and acts as a synchronization point to help the |
| 8654 | // runner bracket each handshake flight. |
| 8655 | // |
| 8656 | // We assume the shim does not read from the channel eagerly. It must |
| 8657 | // first wait until it has sent flight N and is ready to receive |
| 8658 | // handshake flight N+1. At this point, it will process the timeout |
| 8659 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8660 | // as if the shim was idle for the specified amount of time. |
| 8661 | // |
| 8662 | // The runner then drops all packets received before the ACK and |
| 8663 | // continues waiting for flight N. This ordering results in one attempt |
| 8664 | // at sending flight N to be dropped. For the test to complete, the |
| 8665 | // shim must send flight N again, testing that the shim implements DTLS |
| 8666 | // retransmit on a timeout. |
| 8667 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8668 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8669 | // likely be more epochs to cross and the final message's retransmit may |
| 8670 | // be more complex. |
| 8671 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8672 | // Test that this is indeed the timeout schedule. Stress all |
| 8673 | // four patterns of handshake. |
| 8674 | for i := 1; i < len(timeouts); i++ { |
| 8675 | number := strconv.Itoa(i) |
| 8676 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8677 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8678 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8679 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8680 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8681 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8682 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8683 | }, |
| 8684 | }, |
| 8685 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8686 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8687 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8688 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8689 | protocol: dtls, |
| 8690 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8691 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8692 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8693 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8694 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8695 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8696 | }, |
| 8697 | }, |
| 8698 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8699 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8700 | }) |
| 8701 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8702 | |
| 8703 | // Test that exceeding the timeout schedule hits a read |
| 8704 | // timeout. |
| 8705 | testCases = append(testCases, testCase{ |
| 8706 | protocol: dtls, |
| 8707 | name: "DTLS-Retransmit-Timeout", |
| 8708 | config: Config{ |
| 8709 | MaxVersion: VersionTLS12, |
| 8710 | Bugs: ProtocolBugs{ |
| 8711 | TimeoutSchedule: timeouts, |
| 8712 | }, |
| 8713 | }, |
| 8714 | resumeSession: true, |
| 8715 | flags: []string{"-async"}, |
| 8716 | shouldFail: true, |
| 8717 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8718 | }) |
| 8719 | |
| 8720 | // Test that timeout handling has a fudge factor, due to API |
| 8721 | // problems. |
| 8722 | testCases = append(testCases, testCase{ |
| 8723 | protocol: dtls, |
| 8724 | name: "DTLS-Retransmit-Fudge", |
| 8725 | config: Config{ |
| 8726 | MaxVersion: VersionTLS12, |
| 8727 | Bugs: ProtocolBugs{ |
| 8728 | TimeoutSchedule: []time.Duration{ |
| 8729 | timeouts[0] - 10*time.Millisecond, |
| 8730 | }, |
| 8731 | }, |
| 8732 | }, |
| 8733 | resumeSession: true, |
| 8734 | flags: []string{"-async"}, |
| 8735 | }) |
| 8736 | |
| 8737 | // Test that the final Finished retransmitting isn't |
| 8738 | // duplicated if the peer badly fragments everything. |
| 8739 | testCases = append(testCases, testCase{ |
| 8740 | testType: serverTest, |
| 8741 | protocol: dtls, |
| 8742 | name: "DTLS-Retransmit-Fragmented", |
| 8743 | config: Config{ |
| 8744 | MaxVersion: VersionTLS12, |
| 8745 | Bugs: ProtocolBugs{ |
| 8746 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8747 | MaxHandshakeRecordLength: 2, |
| 8748 | }, |
| 8749 | }, |
| 8750 | flags: []string{"-async"}, |
| 8751 | }) |
| 8752 | |
| 8753 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8754 | testCases = append(testCases, testCase{ |
| 8755 | protocol: dtls, |
| 8756 | name: "DTLS-Retransmit-Short-Client", |
| 8757 | config: Config{ |
| 8758 | MaxVersion: VersionTLS12, |
| 8759 | Bugs: ProtocolBugs{ |
| 8760 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8761 | }, |
| 8762 | }, |
| 8763 | resumeSession: true, |
| 8764 | flags: []string{ |
| 8765 | "-async", |
| 8766 | "-initial-timeout-duration-ms", "250", |
| 8767 | }, |
| 8768 | }) |
| 8769 | testCases = append(testCases, testCase{ |
| 8770 | protocol: dtls, |
| 8771 | testType: serverTest, |
| 8772 | name: "DTLS-Retransmit-Short-Server", |
| 8773 | config: Config{ |
| 8774 | MaxVersion: VersionTLS12, |
| 8775 | Bugs: ProtocolBugs{ |
| 8776 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8777 | }, |
| 8778 | }, |
| 8779 | resumeSession: true, |
| 8780 | flags: []string{ |
| 8781 | "-async", |
| 8782 | "-initial-timeout-duration-ms", "250", |
| 8783 | }, |
| 8784 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8785 | } |
| 8786 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8787 | func addExportKeyingMaterialTests() { |
| 8788 | for _, vers := range tlsVersions { |
| 8789 | if vers.version == VersionSSL30 { |
| 8790 | continue |
| 8791 | } |
| 8792 | testCases = append(testCases, testCase{ |
| 8793 | name: "ExportKeyingMaterial-" + vers.name, |
| 8794 | config: Config{ |
| 8795 | MaxVersion: vers.version, |
| 8796 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8797 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8798 | exportKeyingMaterial: 1024, |
| 8799 | exportLabel: "label", |
| 8800 | exportContext: "context", |
| 8801 | useExportContext: true, |
| 8802 | }) |
| 8803 | testCases = append(testCases, testCase{ |
| 8804 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8805 | config: Config{ |
| 8806 | MaxVersion: vers.version, |
| 8807 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8808 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8809 | exportKeyingMaterial: 1024, |
| 8810 | }) |
| 8811 | testCases = append(testCases, testCase{ |
| 8812 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8813 | config: Config{ |
| 8814 | MaxVersion: vers.version, |
| 8815 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8816 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8817 | exportKeyingMaterial: 1024, |
| 8818 | useExportContext: true, |
| 8819 | }) |
| 8820 | testCases = append(testCases, testCase{ |
| 8821 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8822 | config: Config{ |
| 8823 | MaxVersion: vers.version, |
| 8824 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8825 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8826 | exportKeyingMaterial: 1, |
| 8827 | exportLabel: "label", |
| 8828 | exportContext: "context", |
| 8829 | useExportContext: true, |
| 8830 | }) |
| 8831 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8832 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8833 | testCases = append(testCases, testCase{ |
| 8834 | name: "ExportKeyingMaterial-SSL3", |
| 8835 | config: Config{ |
| 8836 | MaxVersion: VersionSSL30, |
| 8837 | }, |
| 8838 | exportKeyingMaterial: 1024, |
| 8839 | exportLabel: "label", |
| 8840 | exportContext: "context", |
| 8841 | useExportContext: true, |
| 8842 | shouldFail: true, |
| 8843 | expectedError: "failed to export keying material", |
| 8844 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8845 | |
| 8846 | // Exporters work during a False Start. |
| 8847 | testCases = append(testCases, testCase{ |
| 8848 | name: "ExportKeyingMaterial-FalseStart", |
| 8849 | config: Config{ |
| 8850 | MaxVersion: VersionTLS12, |
| 8851 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8852 | NextProtos: []string{"foo"}, |
| 8853 | Bugs: ProtocolBugs{ |
| 8854 | ExpectFalseStart: true, |
| 8855 | }, |
| 8856 | }, |
| 8857 | flags: []string{ |
| 8858 | "-false-start", |
| 8859 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8860 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8861 | }, |
| 8862 | shimWritesFirst: true, |
| 8863 | exportKeyingMaterial: 1024, |
| 8864 | exportLabel: "label", |
| 8865 | exportContext: "context", |
| 8866 | useExportContext: true, |
| 8867 | }) |
| 8868 | |
| 8869 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8870 | // triggering the exporter after every SSL_read call and configuring the |
| 8871 | // shim to run asynchronously. |
| 8872 | testCases = append(testCases, testCase{ |
| 8873 | name: "ExportKeyingMaterial-Renegotiate", |
| 8874 | config: Config{ |
| 8875 | MaxVersion: VersionTLS12, |
| 8876 | }, |
| 8877 | renegotiate: 1, |
| 8878 | flags: []string{ |
| 8879 | "-async", |
| 8880 | "-use-exporter-between-reads", |
| 8881 | "-renegotiate-freely", |
| 8882 | "-expect-total-renegotiations", "1", |
| 8883 | }, |
| 8884 | shouldFail: true, |
| 8885 | expectedError: "failed to export keying material", |
| 8886 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8887 | } |
| 8888 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8889 | func addTLSUniqueTests() { |
| 8890 | for _, isClient := range []bool{false, true} { |
| 8891 | for _, isResumption := range []bool{false, true} { |
| 8892 | for _, hasEMS := range []bool{false, true} { |
| 8893 | var suffix string |
| 8894 | if isResumption { |
| 8895 | suffix = "Resume-" |
| 8896 | } else { |
| 8897 | suffix = "Full-" |
| 8898 | } |
| 8899 | |
| 8900 | if hasEMS { |
| 8901 | suffix += "EMS-" |
| 8902 | } else { |
| 8903 | suffix += "NoEMS-" |
| 8904 | } |
| 8905 | |
| 8906 | if isClient { |
| 8907 | suffix += "Client" |
| 8908 | } else { |
| 8909 | suffix += "Server" |
| 8910 | } |
| 8911 | |
| 8912 | test := testCase{ |
| 8913 | name: "TLSUnique-" + suffix, |
| 8914 | testTLSUnique: true, |
| 8915 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8916 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8917 | Bugs: ProtocolBugs{ |
| 8918 | NoExtendedMasterSecret: !hasEMS, |
| 8919 | }, |
| 8920 | }, |
| 8921 | } |
| 8922 | |
| 8923 | if isResumption { |
| 8924 | test.resumeSession = true |
| 8925 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8926 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8927 | Bugs: ProtocolBugs{ |
| 8928 | NoExtendedMasterSecret: !hasEMS, |
| 8929 | }, |
| 8930 | } |
| 8931 | } |
| 8932 | |
| 8933 | if isResumption && !hasEMS { |
| 8934 | test.shouldFail = true |
| 8935 | test.expectedError = "failed to get tls-unique" |
| 8936 | } |
| 8937 | |
| 8938 | testCases = append(testCases, test) |
| 8939 | } |
| 8940 | } |
| 8941 | } |
| 8942 | } |
| 8943 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8944 | func addCustomExtensionTests() { |
| 8945 | expectedContents := "custom extension" |
| 8946 | emptyString := "" |
| 8947 | |
| 8948 | for _, isClient := range []bool{false, true} { |
| 8949 | suffix := "Server" |
| 8950 | flag := "-enable-server-custom-extension" |
| 8951 | testType := serverTest |
| 8952 | if isClient { |
| 8953 | suffix = "Client" |
| 8954 | flag = "-enable-client-custom-extension" |
| 8955 | testType = clientTest |
| 8956 | } |
| 8957 | |
| 8958 | testCases = append(testCases, testCase{ |
| 8959 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8960 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8961 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8962 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8963 | Bugs: ProtocolBugs{ |
| 8964 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8965 | ExpectedCustomExtension: &expectedContents, |
| 8966 | }, |
| 8967 | }, |
| 8968 | flags: []string{flag}, |
| 8969 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8970 | testCases = append(testCases, testCase{ |
| 8971 | testType: testType, |
| 8972 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8973 | config: Config{ |
| 8974 | MaxVersion: VersionTLS13, |
| 8975 | Bugs: ProtocolBugs{ |
| 8976 | CustomExtension: expectedContents, |
| 8977 | ExpectedCustomExtension: &expectedContents, |
| 8978 | }, |
| 8979 | }, |
| 8980 | flags: []string{flag}, |
| 8981 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8982 | |
| 8983 | // If the parse callback fails, the handshake should also fail. |
| 8984 | testCases = append(testCases, testCase{ |
| 8985 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8986 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8987 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8988 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8989 | Bugs: ProtocolBugs{ |
| 8990 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8991 | ExpectedCustomExtension: &expectedContents, |
| 8992 | }, |
| 8993 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8994 | flags: []string{flag}, |
| 8995 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8996 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8997 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8998 | testCases = append(testCases, testCase{ |
| 8999 | testType: testType, |
| 9000 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 9001 | config: Config{ |
| 9002 | MaxVersion: VersionTLS13, |
| 9003 | Bugs: ProtocolBugs{ |
| 9004 | CustomExtension: expectedContents + "foo", |
| 9005 | ExpectedCustomExtension: &expectedContents, |
| 9006 | }, |
| 9007 | }, |
| 9008 | flags: []string{flag}, |
| 9009 | shouldFail: true, |
| 9010 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9011 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9012 | |
| 9013 | // If the add callback fails, the handshake should also fail. |
| 9014 | testCases = append(testCases, testCase{ |
| 9015 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9016 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9017 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9018 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9019 | Bugs: ProtocolBugs{ |
| 9020 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9021 | ExpectedCustomExtension: &expectedContents, |
| 9022 | }, |
| 9023 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9024 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9025 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9026 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9027 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9028 | testCases = append(testCases, testCase{ |
| 9029 | testType: testType, |
| 9030 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 9031 | config: Config{ |
| 9032 | MaxVersion: VersionTLS13, |
| 9033 | Bugs: ProtocolBugs{ |
| 9034 | CustomExtension: expectedContents, |
| 9035 | ExpectedCustomExtension: &expectedContents, |
| 9036 | }, |
| 9037 | }, |
| 9038 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9039 | shouldFail: true, |
| 9040 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9041 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9042 | |
| 9043 | // If the add callback returns zero, no extension should be |
| 9044 | // added. |
| 9045 | skipCustomExtension := expectedContents |
| 9046 | if isClient { |
| 9047 | // For the case where the client skips sending the |
| 9048 | // custom extension, the server must not “echo” it. |
| 9049 | skipCustomExtension = "" |
| 9050 | } |
| 9051 | testCases = append(testCases, testCase{ |
| 9052 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9053 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9054 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9055 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9056 | Bugs: ProtocolBugs{ |
| 9057 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9058 | ExpectedCustomExtension: &emptyString, |
| 9059 | }, |
| 9060 | }, |
| 9061 | flags: []string{flag, "-custom-extension-skip"}, |
| 9062 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9063 | testCases = append(testCases, testCase{ |
| 9064 | testType: testType, |
| 9065 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 9066 | config: Config{ |
| 9067 | MaxVersion: VersionTLS13, |
| 9068 | Bugs: ProtocolBugs{ |
| 9069 | CustomExtension: skipCustomExtension, |
| 9070 | ExpectedCustomExtension: &emptyString, |
| 9071 | }, |
| 9072 | }, |
| 9073 | flags: []string{flag, "-custom-extension-skip"}, |
| 9074 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9075 | } |
| 9076 | |
Steven Valdez | f4ecc84 | 2017-08-10 14:02:56 -0400 | [diff] [blame^] | 9077 | // If the client sends both early data and custom extension, the handshake |
| 9078 | // should succeed as long as both the extensions aren't returned by the |
| 9079 | // server. |
| 9080 | testCases = append(testCases, testCase{ |
| 9081 | testType: clientTest, |
| 9082 | name: "CustomExtensions-Client-EarlyData-None", |
| 9083 | config: Config{ |
| 9084 | MaxVersion: VersionTLS13, |
| 9085 | MaxEarlyDataSize: 16384, |
| 9086 | Bugs: ProtocolBugs{ |
| 9087 | ExpectedCustomExtension: &expectedContents, |
| 9088 | AlwaysRejectEarlyData: true, |
| 9089 | }, |
| 9090 | }, |
| 9091 | resumeSession: true, |
| 9092 | flags: []string{ |
| 9093 | "-enable-client-custom-extension", |
| 9094 | "-enable-early-data", |
| 9095 | "-expect-early-data-info", |
| 9096 | "-expect-reject-early-data", |
| 9097 | }, |
| 9098 | }) |
| 9099 | |
| 9100 | testCases = append(testCases, testCase{ |
| 9101 | testType: clientTest, |
| 9102 | name: "CustomExtensions-Client-EarlyData-EarlyDataAccepted", |
| 9103 | config: Config{ |
| 9104 | MaxVersion: VersionTLS13, |
| 9105 | MaxEarlyDataSize: 16384, |
| 9106 | Bugs: ProtocolBugs{ |
| 9107 | ExpectedCustomExtension: &expectedContents, |
| 9108 | }, |
| 9109 | }, |
| 9110 | resumeSession: true, |
| 9111 | flags: []string{ |
| 9112 | "-enable-client-custom-extension", |
| 9113 | "-enable-early-data", |
| 9114 | "-expect-early-data-info", |
| 9115 | "-expect-accept-early-data", |
| 9116 | }, |
| 9117 | }) |
| 9118 | |
| 9119 | testCases = append(testCases, testCase{ |
| 9120 | testType: clientTest, |
| 9121 | name: "CustomExtensions-Client-EarlyData-CustomExtensionAccepted", |
| 9122 | config: Config{ |
| 9123 | MaxVersion: VersionTLS13, |
| 9124 | MaxEarlyDataSize: 16384, |
| 9125 | Bugs: ProtocolBugs{ |
| 9126 | AlwaysRejectEarlyData: true, |
| 9127 | CustomExtension: expectedContents, |
| 9128 | ExpectedCustomExtension: &expectedContents, |
| 9129 | }, |
| 9130 | }, |
| 9131 | resumeSession: true, |
| 9132 | flags: []string{ |
| 9133 | "-enable-client-custom-extension", |
| 9134 | "-enable-early-data", |
| 9135 | "-expect-early-data-info", |
| 9136 | "-expect-reject-early-data", |
| 9137 | }, |
| 9138 | }) |
| 9139 | |
| 9140 | testCases = append(testCases, testCase{ |
| 9141 | testType: clientTest, |
| 9142 | name: "CustomExtensions-Client-EarlyDataAndCustomExtensions", |
| 9143 | config: Config{ |
| 9144 | MaxVersion: VersionTLS13, |
| 9145 | MaxEarlyDataSize: 16384, |
| 9146 | Bugs: ProtocolBugs{ |
| 9147 | CustomExtension: expectedContents, |
| 9148 | ExpectedCustomExtension: &expectedContents, |
| 9149 | }, |
| 9150 | }, |
| 9151 | resumeConfig: &Config{ |
| 9152 | MaxVersion: VersionTLS13, |
| 9153 | MaxEarlyDataSize: 16384, |
| 9154 | Bugs: ProtocolBugs{ |
| 9155 | CustomExtension: expectedContents, |
| 9156 | ExpectedCustomExtension: &expectedContents, |
| 9157 | SendEarlyDataExtension: true, |
| 9158 | }, |
| 9159 | }, |
| 9160 | resumeSession: true, |
| 9161 | shouldFail: true, |
| 9162 | expectedError: ":UNEXPECTED_EXTENSION_ON_EARLY_DATA:", |
| 9163 | flags: []string{ |
| 9164 | "-enable-client-custom-extension", |
| 9165 | "-enable-early-data", |
| 9166 | "-expect-early-data-info", |
| 9167 | }, |
| 9168 | }) |
| 9169 | |
| 9170 | // If the server receives both early data and custom extension, only the |
| 9171 | // custom extension should be accepted. |
| 9172 | testCases = append(testCases, testCase{ |
| 9173 | testType: serverTest, |
| 9174 | name: "CustomExtensions-Server-EarlyDataAccepted", |
| 9175 | config: Config{ |
| 9176 | MaxVersion: VersionTLS13, |
| 9177 | MaxEarlyDataSize: 16384, |
| 9178 | Bugs: ProtocolBugs{ |
| 9179 | CustomExtension: expectedContents, |
| 9180 | ExpectedCustomExtension: &expectedContents, |
| 9181 | ExpectEarlyDataAccepted: false, |
| 9182 | }, |
| 9183 | }, |
| 9184 | resumeSession: true, |
| 9185 | flags: []string{ |
| 9186 | "-enable-server-custom-extension", |
| 9187 | "-enable-early-data", |
| 9188 | "-expect-early-data-info", |
| 9189 | }, |
| 9190 | }) |
| 9191 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9192 | // The custom extension add callback should not be called if the client |
| 9193 | // doesn't send the extension. |
| 9194 | testCases = append(testCases, testCase{ |
| 9195 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9196 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9197 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9198 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9199 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9200 | ExpectedCustomExtension: &emptyString, |
| 9201 | }, |
| 9202 | }, |
| 9203 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9204 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9205 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9206 | testCases = append(testCases, testCase{ |
| 9207 | testType: serverTest, |
| 9208 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9209 | config: Config{ |
| 9210 | MaxVersion: VersionTLS13, |
| 9211 | Bugs: ProtocolBugs{ |
| 9212 | ExpectedCustomExtension: &emptyString, |
| 9213 | }, |
| 9214 | }, |
| 9215 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9216 | }) |
| 9217 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9218 | // Test an unknown extension from the server. |
| 9219 | testCases = append(testCases, testCase{ |
| 9220 | testType: clientTest, |
| 9221 | name: "UnknownExtension-Client", |
| 9222 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9223 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9224 | Bugs: ProtocolBugs{ |
| 9225 | CustomExtension: expectedContents, |
| 9226 | }, |
| 9227 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9228 | shouldFail: true, |
| 9229 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9230 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9231 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9232 | testCases = append(testCases, testCase{ |
| 9233 | testType: clientTest, |
| 9234 | name: "UnknownExtension-Client-TLS13", |
| 9235 | config: Config{ |
| 9236 | MaxVersion: VersionTLS13, |
| 9237 | Bugs: ProtocolBugs{ |
| 9238 | CustomExtension: expectedContents, |
| 9239 | }, |
| 9240 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9241 | shouldFail: true, |
| 9242 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9243 | expectedLocalError: "remote error: unsupported extension", |
| 9244 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9245 | testCases = append(testCases, testCase{ |
| 9246 | testType: clientTest, |
| 9247 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9248 | config: Config{ |
| 9249 | MaxVersion: VersionTLS13, |
| 9250 | Bugs: ProtocolBugs{ |
| 9251 | CustomUnencryptedExtension: expectedContents, |
| 9252 | }, |
| 9253 | }, |
| 9254 | shouldFail: true, |
| 9255 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9256 | // The shim must send an alert, but alerts at this point do not |
| 9257 | // get successfully decrypted by the runner. |
| 9258 | expectedLocalError: "local error: bad record MAC", |
| 9259 | }) |
| 9260 | testCases = append(testCases, testCase{ |
| 9261 | testType: clientTest, |
| 9262 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9263 | config: Config{ |
| 9264 | MaxVersion: VersionTLS13, |
| 9265 | Bugs: ProtocolBugs{ |
| 9266 | SendUnencryptedALPN: "foo", |
| 9267 | }, |
| 9268 | }, |
| 9269 | flags: []string{ |
| 9270 | "-advertise-alpn", "\x03foo\x03bar", |
| 9271 | }, |
| 9272 | shouldFail: true, |
| 9273 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9274 | // The shim must send an alert, but alerts at this point do not |
| 9275 | // get successfully decrypted by the runner. |
| 9276 | expectedLocalError: "local error: bad record MAC", |
| 9277 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9278 | |
| 9279 | // Test a known but unoffered extension from the server. |
| 9280 | testCases = append(testCases, testCase{ |
| 9281 | testType: clientTest, |
| 9282 | name: "UnofferedExtension-Client", |
| 9283 | config: Config{ |
| 9284 | MaxVersion: VersionTLS12, |
| 9285 | Bugs: ProtocolBugs{ |
| 9286 | SendALPN: "alpn", |
| 9287 | }, |
| 9288 | }, |
| 9289 | shouldFail: true, |
| 9290 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9291 | expectedLocalError: "remote error: unsupported extension", |
| 9292 | }) |
| 9293 | testCases = append(testCases, testCase{ |
| 9294 | testType: clientTest, |
| 9295 | name: "UnofferedExtension-Client-TLS13", |
| 9296 | config: Config{ |
| 9297 | MaxVersion: VersionTLS13, |
| 9298 | Bugs: ProtocolBugs{ |
| 9299 | SendALPN: "alpn", |
| 9300 | }, |
| 9301 | }, |
| 9302 | shouldFail: true, |
| 9303 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9304 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9305 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9306 | } |
| 9307 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9308 | func addRSAClientKeyExchangeTests() { |
| 9309 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9310 | testCases = append(testCases, testCase{ |
| 9311 | testType: serverTest, |
| 9312 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9313 | config: Config{ |
| 9314 | // Ensure the ClientHello version and final |
| 9315 | // version are different, to detect if the |
| 9316 | // server uses the wrong one. |
| 9317 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9318 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9319 | Bugs: ProtocolBugs{ |
| 9320 | BadRSAClientKeyExchange: bad, |
| 9321 | }, |
| 9322 | }, |
| 9323 | shouldFail: true, |
| 9324 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9325 | }) |
| 9326 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9327 | |
| 9328 | // The server must compare whatever was in ClientHello.version for the |
| 9329 | // RSA premaster. |
| 9330 | testCases = append(testCases, testCase{ |
| 9331 | testType: serverTest, |
| 9332 | name: "SendClientVersion-RSA", |
| 9333 | config: Config{ |
| 9334 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9335 | Bugs: ProtocolBugs{ |
| 9336 | SendClientVersion: 0x1234, |
| 9337 | }, |
| 9338 | }, |
| 9339 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9340 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9341 | } |
| 9342 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9343 | var testCurves = []struct { |
| 9344 | name string |
| 9345 | id CurveID |
| 9346 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9347 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9348 | {"P-256", CurveP256}, |
| 9349 | {"P-384", CurveP384}, |
| 9350 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9351 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9352 | } |
| 9353 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9354 | const bogusCurve = 0x1234 |
| 9355 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9356 | func addCurveTests() { |
| 9357 | for _, curve := range testCurves { |
| 9358 | testCases = append(testCases, testCase{ |
| 9359 | name: "CurveTest-Client-" + curve.name, |
| 9360 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9361 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9362 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9363 | CurvePreferences: []CurveID{curve.id}, |
| 9364 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9365 | flags: []string{ |
| 9366 | "-enable-all-curves", |
| 9367 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9368 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9369 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9370 | }) |
| 9371 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9372 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9373 | config: Config{ |
| 9374 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9375 | CurvePreferences: []CurveID{curve.id}, |
| 9376 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9377 | flags: []string{ |
| 9378 | "-enable-all-curves", |
| 9379 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9380 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9381 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9382 | }) |
| 9383 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9384 | testType: serverTest, |
| 9385 | name: "CurveTest-Server-" + curve.name, |
| 9386 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9387 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9388 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9389 | CurvePreferences: []CurveID{curve.id}, |
| 9390 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9391 | flags: []string{ |
| 9392 | "-enable-all-curves", |
| 9393 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9394 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9395 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9396 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9397 | testCases = append(testCases, testCase{ |
| 9398 | testType: serverTest, |
| 9399 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9400 | config: Config{ |
| 9401 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9402 | CurvePreferences: []CurveID{curve.id}, |
| 9403 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9404 | flags: []string{ |
| 9405 | "-enable-all-curves", |
| 9406 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9407 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9408 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9409 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9410 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9411 | |
| 9412 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9413 | testCases = append(testCases, testCase{ |
| 9414 | testType: serverTest, |
| 9415 | name: "UnknownCurve", |
| 9416 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9417 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9418 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9419 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9420 | }, |
| 9421 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9422 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9423 | // The server must be tolerant to bogus curves. |
| 9424 | testCases = append(testCases, testCase{ |
| 9425 | testType: serverTest, |
| 9426 | name: "UnknownCurve-TLS13", |
| 9427 | config: Config{ |
| 9428 | MaxVersion: VersionTLS13, |
| 9429 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9430 | }, |
| 9431 | }) |
| 9432 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9433 | // The server must not consider ECDHE ciphers when there are no |
| 9434 | // supported curves. |
| 9435 | testCases = append(testCases, testCase{ |
| 9436 | testType: serverTest, |
| 9437 | name: "NoSupportedCurves", |
| 9438 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9439 | MaxVersion: VersionTLS12, |
| 9440 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9441 | Bugs: ProtocolBugs{ |
| 9442 | NoSupportedCurves: true, |
| 9443 | }, |
| 9444 | }, |
| 9445 | shouldFail: true, |
| 9446 | expectedError: ":NO_SHARED_CIPHER:", |
| 9447 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9448 | testCases = append(testCases, testCase{ |
| 9449 | testType: serverTest, |
| 9450 | name: "NoSupportedCurves-TLS13", |
| 9451 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9452 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9453 | Bugs: ProtocolBugs{ |
| 9454 | NoSupportedCurves: true, |
| 9455 | }, |
| 9456 | }, |
| 9457 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9458 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9459 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9460 | |
| 9461 | // The server must fall back to another cipher when there are no |
| 9462 | // supported curves. |
| 9463 | testCases = append(testCases, testCase{ |
| 9464 | testType: serverTest, |
| 9465 | name: "NoCommonCurves", |
| 9466 | config: Config{ |
| 9467 | MaxVersion: VersionTLS12, |
| 9468 | CipherSuites: []uint16{ |
| 9469 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9470 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9471 | }, |
| 9472 | CurvePreferences: []CurveID{CurveP224}, |
| 9473 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9474 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9475 | }) |
| 9476 | |
| 9477 | // The client must reject bogus curves and disabled curves. |
| 9478 | testCases = append(testCases, testCase{ |
| 9479 | name: "BadECDHECurve", |
| 9480 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9481 | MaxVersion: VersionTLS12, |
| 9482 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9483 | Bugs: ProtocolBugs{ |
| 9484 | SendCurve: bogusCurve, |
| 9485 | }, |
| 9486 | }, |
| 9487 | shouldFail: true, |
| 9488 | expectedError: ":WRONG_CURVE:", |
| 9489 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9490 | testCases = append(testCases, testCase{ |
| 9491 | name: "BadECDHECurve-TLS13", |
| 9492 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9493 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9494 | Bugs: ProtocolBugs{ |
| 9495 | SendCurve: bogusCurve, |
| 9496 | }, |
| 9497 | }, |
| 9498 | shouldFail: true, |
| 9499 | expectedError: ":WRONG_CURVE:", |
| 9500 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9501 | |
| 9502 | testCases = append(testCases, testCase{ |
| 9503 | name: "UnsupportedCurve", |
| 9504 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9505 | MaxVersion: VersionTLS12, |
| 9506 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9507 | CurvePreferences: []CurveID{CurveP256}, |
| 9508 | Bugs: ProtocolBugs{ |
| 9509 | IgnorePeerCurvePreferences: true, |
| 9510 | }, |
| 9511 | }, |
| 9512 | flags: []string{"-p384-only"}, |
| 9513 | shouldFail: true, |
| 9514 | expectedError: ":WRONG_CURVE:", |
| 9515 | }) |
| 9516 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9517 | testCases = append(testCases, testCase{ |
| 9518 | // TODO(davidben): Add a TLS 1.3 version where |
| 9519 | // HelloRetryRequest requests an unsupported curve. |
| 9520 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9521 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9522 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9523 | CurvePreferences: []CurveID{CurveP384}, |
| 9524 | Bugs: ProtocolBugs{ |
| 9525 | SendCurve: CurveP256, |
| 9526 | }, |
| 9527 | }, |
| 9528 | flags: []string{"-p384-only"}, |
| 9529 | shouldFail: true, |
| 9530 | expectedError: ":WRONG_CURVE:", |
| 9531 | }) |
| 9532 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9533 | // Test invalid curve points. |
| 9534 | testCases = append(testCases, testCase{ |
| 9535 | name: "InvalidECDHPoint-Client", |
| 9536 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9537 | MaxVersion: VersionTLS12, |
| 9538 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9539 | CurvePreferences: []CurveID{CurveP256}, |
| 9540 | Bugs: ProtocolBugs{ |
| 9541 | InvalidECDHPoint: true, |
| 9542 | }, |
| 9543 | }, |
| 9544 | shouldFail: true, |
| 9545 | expectedError: ":INVALID_ENCODING:", |
| 9546 | }) |
| 9547 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9548 | name: "InvalidECDHPoint-Client-TLS13", |
| 9549 | config: Config{ |
| 9550 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9551 | CurvePreferences: []CurveID{CurveP256}, |
| 9552 | Bugs: ProtocolBugs{ |
| 9553 | InvalidECDHPoint: true, |
| 9554 | }, |
| 9555 | }, |
| 9556 | shouldFail: true, |
| 9557 | expectedError: ":INVALID_ENCODING:", |
| 9558 | }) |
| 9559 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9560 | testType: serverTest, |
| 9561 | name: "InvalidECDHPoint-Server", |
| 9562 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9563 | MaxVersion: VersionTLS12, |
| 9564 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9565 | CurvePreferences: []CurveID{CurveP256}, |
| 9566 | Bugs: ProtocolBugs{ |
| 9567 | InvalidECDHPoint: true, |
| 9568 | }, |
| 9569 | }, |
| 9570 | shouldFail: true, |
| 9571 | expectedError: ":INVALID_ENCODING:", |
| 9572 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9573 | testCases = append(testCases, testCase{ |
| 9574 | testType: serverTest, |
| 9575 | name: "InvalidECDHPoint-Server-TLS13", |
| 9576 | config: Config{ |
| 9577 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9578 | CurvePreferences: []CurveID{CurveP256}, |
| 9579 | Bugs: ProtocolBugs{ |
| 9580 | InvalidECDHPoint: true, |
| 9581 | }, |
| 9582 | }, |
| 9583 | shouldFail: true, |
| 9584 | expectedError: ":INVALID_ENCODING:", |
| 9585 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9586 | |
| 9587 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9588 | testCases = append(testCases, testCase{ |
| 9589 | name: "CurveID-Resume-Client", |
| 9590 | config: Config{ |
| 9591 | MaxVersion: VersionTLS12, |
| 9592 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9593 | CurvePreferences: []CurveID{CurveX25519}, |
| 9594 | }, |
| 9595 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9596 | resumeSession: true, |
| 9597 | }) |
| 9598 | testCases = append(testCases, testCase{ |
| 9599 | testType: serverTest, |
| 9600 | name: "CurveID-Resume-Server", |
| 9601 | config: Config{ |
| 9602 | MaxVersion: VersionTLS12, |
| 9603 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9604 | CurvePreferences: []CurveID{CurveX25519}, |
| 9605 | }, |
| 9606 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9607 | resumeSession: true, |
| 9608 | }) |
| 9609 | |
| 9610 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9611 | // one should be reported. |
| 9612 | testCases = append(testCases, testCase{ |
| 9613 | name: "CurveID-Resume-Client-TLS13", |
| 9614 | config: Config{ |
| 9615 | MaxVersion: VersionTLS13, |
| 9616 | CurvePreferences: []CurveID{CurveX25519}, |
| 9617 | }, |
| 9618 | resumeConfig: &Config{ |
| 9619 | MaxVersion: VersionTLS13, |
| 9620 | CurvePreferences: []CurveID{CurveP256}, |
| 9621 | }, |
| 9622 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9623 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9624 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9625 | }, |
| 9626 | resumeSession: true, |
| 9627 | }) |
| 9628 | testCases = append(testCases, testCase{ |
| 9629 | testType: serverTest, |
| 9630 | name: "CurveID-Resume-Server-TLS13", |
| 9631 | config: Config{ |
| 9632 | MaxVersion: VersionTLS13, |
| 9633 | CurvePreferences: []CurveID{CurveX25519}, |
| 9634 | }, |
| 9635 | resumeConfig: &Config{ |
| 9636 | MaxVersion: VersionTLS13, |
| 9637 | CurvePreferences: []CurveID{CurveP256}, |
| 9638 | }, |
| 9639 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9640 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9641 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9642 | }, |
| 9643 | resumeSession: true, |
| 9644 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9645 | |
| 9646 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9647 | testCases = append(testCases, testCase{ |
| 9648 | name: "PointFormat-ServerHello-TLS12", |
| 9649 | config: Config{ |
| 9650 | MaxVersion: VersionTLS12, |
| 9651 | Bugs: ProtocolBugs{ |
| 9652 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9653 | }, |
| 9654 | }, |
| 9655 | }) |
| 9656 | testCases = append(testCases, testCase{ |
| 9657 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9658 | config: Config{ |
| 9659 | MaxVersion: VersionTLS13, |
| 9660 | Bugs: ProtocolBugs{ |
| 9661 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9662 | }, |
| 9663 | }, |
| 9664 | shouldFail: true, |
| 9665 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9666 | }) |
| 9667 | |
| 9668 | // Test that we tolerate unknown point formats, as long as |
| 9669 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9670 | // check they are still functional. |
| 9671 | testCases = append(testCases, testCase{ |
| 9672 | name: "PointFormat-Client-Tolerance", |
| 9673 | config: Config{ |
| 9674 | MaxVersion: VersionTLS12, |
| 9675 | Bugs: ProtocolBugs{ |
| 9676 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9677 | }, |
| 9678 | }, |
| 9679 | }) |
| 9680 | testCases = append(testCases, testCase{ |
| 9681 | testType: serverTest, |
| 9682 | name: "PointFormat-Server-Tolerance", |
| 9683 | config: Config{ |
| 9684 | MaxVersion: VersionTLS12, |
| 9685 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9686 | Bugs: ProtocolBugs{ |
| 9687 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9688 | }, |
| 9689 | }, |
| 9690 | }) |
| 9691 | |
| 9692 | // Test TLS 1.2 does not require the point format extension to be |
| 9693 | // present. |
| 9694 | testCases = append(testCases, testCase{ |
| 9695 | name: "PointFormat-Client-Missing", |
| 9696 | config: Config{ |
| 9697 | MaxVersion: VersionTLS12, |
| 9698 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9699 | Bugs: ProtocolBugs{ |
| 9700 | SendSupportedPointFormats: []byte{}, |
| 9701 | }, |
| 9702 | }, |
| 9703 | }) |
| 9704 | testCases = append(testCases, testCase{ |
| 9705 | testType: serverTest, |
| 9706 | name: "PointFormat-Server-Missing", |
| 9707 | config: Config{ |
| 9708 | MaxVersion: VersionTLS12, |
| 9709 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9710 | Bugs: ProtocolBugs{ |
| 9711 | SendSupportedPointFormats: []byte{}, |
| 9712 | }, |
| 9713 | }, |
| 9714 | }) |
| 9715 | |
| 9716 | // If the point format extension is present, uncompressed points must be |
| 9717 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9718 | testCases = append(testCases, testCase{ |
| 9719 | name: "PointFormat-Client-MissingUncompressed", |
| 9720 | config: Config{ |
| 9721 | MaxVersion: VersionTLS12, |
| 9722 | Bugs: ProtocolBugs{ |
| 9723 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9724 | }, |
| 9725 | }, |
| 9726 | shouldFail: true, |
| 9727 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9728 | }) |
| 9729 | testCases = append(testCases, testCase{ |
| 9730 | testType: serverTest, |
| 9731 | name: "PointFormat-Server-MissingUncompressed", |
| 9732 | config: Config{ |
| 9733 | MaxVersion: VersionTLS12, |
| 9734 | Bugs: ProtocolBugs{ |
| 9735 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9736 | }, |
| 9737 | }, |
| 9738 | shouldFail: true, |
| 9739 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9740 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9741 | } |
| 9742 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9743 | func addTLS13RecordTests() { |
| 9744 | testCases = append(testCases, testCase{ |
| 9745 | name: "TLS13-RecordPadding", |
| 9746 | config: Config{ |
| 9747 | MaxVersion: VersionTLS13, |
| 9748 | MinVersion: VersionTLS13, |
| 9749 | Bugs: ProtocolBugs{ |
| 9750 | RecordPadding: 10, |
| 9751 | }, |
| 9752 | }, |
| 9753 | }) |
| 9754 | |
| 9755 | testCases = append(testCases, testCase{ |
| 9756 | name: "TLS13-EmptyRecords", |
| 9757 | config: Config{ |
| 9758 | MaxVersion: VersionTLS13, |
| 9759 | MinVersion: VersionTLS13, |
| 9760 | Bugs: ProtocolBugs{ |
| 9761 | OmitRecordContents: true, |
| 9762 | }, |
| 9763 | }, |
| 9764 | shouldFail: true, |
| 9765 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9766 | }) |
| 9767 | |
| 9768 | testCases = append(testCases, testCase{ |
| 9769 | name: "TLS13-OnlyPadding", |
| 9770 | config: Config{ |
| 9771 | MaxVersion: VersionTLS13, |
| 9772 | MinVersion: VersionTLS13, |
| 9773 | Bugs: ProtocolBugs{ |
| 9774 | OmitRecordContents: true, |
| 9775 | RecordPadding: 10, |
| 9776 | }, |
| 9777 | }, |
| 9778 | shouldFail: true, |
| 9779 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9780 | }) |
| 9781 | |
| 9782 | testCases = append(testCases, testCase{ |
| 9783 | name: "TLS13-WrongOuterRecord", |
| 9784 | config: Config{ |
| 9785 | MaxVersion: VersionTLS13, |
| 9786 | MinVersion: VersionTLS13, |
| 9787 | Bugs: ProtocolBugs{ |
| 9788 | OuterRecordType: recordTypeHandshake, |
| 9789 | }, |
| 9790 | }, |
| 9791 | shouldFail: true, |
| 9792 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9793 | }) |
| 9794 | } |
| 9795 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9796 | func addSessionTicketTests() { |
| 9797 | testCases = append(testCases, testCase{ |
| 9798 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9799 | // mean the server changed its mind on sending a ticket. |
| 9800 | name: "SendEmptySessionTicket", |
| 9801 | config: Config{ |
| 9802 | MaxVersion: VersionTLS12, |
| 9803 | Bugs: ProtocolBugs{ |
| 9804 | SendEmptySessionTicket: true, |
| 9805 | }, |
| 9806 | }, |
| 9807 | flags: []string{"-expect-no-session"}, |
| 9808 | }) |
| 9809 | |
| 9810 | // Test that the server ignores unknown PSK modes. |
| 9811 | testCases = append(testCases, testCase{ |
| 9812 | testType: serverTest, |
| 9813 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9814 | config: Config{ |
| 9815 | MaxVersion: VersionTLS13, |
| 9816 | Bugs: ProtocolBugs{ |
| 9817 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9818 | }, |
| 9819 | }, |
| 9820 | resumeSession: true, |
| 9821 | expectedResumeVersion: VersionTLS13, |
| 9822 | }) |
| 9823 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9824 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9825 | testCases = append(testCases, testCase{ |
| 9826 | testType: serverTest, |
| 9827 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9828 | config: Config{ |
| 9829 | MaxVersion: VersionTLS13, |
| 9830 | Bugs: ProtocolBugs{ |
| 9831 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9832 | ExpectNoNewSessionTicket: true, |
| 9833 | }, |
| 9834 | }, |
| 9835 | }) |
| 9836 | |
| 9837 | // 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] | 9838 | testCases = append(testCases, testCase{ |
| 9839 | testType: serverTest, |
| 9840 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9841 | config: Config{ |
| 9842 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9843 | }, |
| 9844 | resumeConfig: &Config{ |
| 9845 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9846 | Bugs: ProtocolBugs{ |
| 9847 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9848 | }, |
| 9849 | }, |
| 9850 | resumeSession: true, |
| 9851 | expectResumeRejected: true, |
| 9852 | }) |
| 9853 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9854 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9855 | testCases = append(testCases, testCase{ |
| 9856 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9857 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9858 | config: Config{ |
| 9859 | MaxVersion: VersionTLS13, |
| 9860 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9861 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9862 | }, |
| 9863 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9864 | resumeSession: true, |
| 9865 | flags: []string{ |
| 9866 | "-resumption-delay", "10", |
| 9867 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9868 | }) |
| 9869 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9870 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9871 | testCases = append(testCases, testCase{ |
| 9872 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9873 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9874 | config: Config{ |
| 9875 | MaxVersion: VersionTLS13, |
| 9876 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9877 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9878 | }, |
| 9879 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9880 | resumeSession: true, |
| 9881 | shouldFail: true, |
| 9882 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9883 | }) |
| 9884 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9885 | // Test that the server's ticket age skew reporting works. |
| 9886 | testCases = append(testCases, testCase{ |
| 9887 | testType: serverTest, |
| 9888 | name: "TLS13-TicketAgeSkew-Forward", |
| 9889 | config: Config{ |
| 9890 | MaxVersion: VersionTLS13, |
| 9891 | Bugs: ProtocolBugs{ |
| 9892 | SendTicketAge: 15 * time.Second, |
| 9893 | }, |
| 9894 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9895 | resumeSession: true, |
| 9896 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9897 | flags: []string{ |
| 9898 | "-resumption-delay", "10", |
| 9899 | "-expect-ticket-age-skew", "5", |
| 9900 | }, |
| 9901 | }) |
| 9902 | testCases = append(testCases, testCase{ |
| 9903 | testType: serverTest, |
| 9904 | name: "TLS13-TicketAgeSkew-Backward", |
| 9905 | config: Config{ |
| 9906 | MaxVersion: VersionTLS13, |
| 9907 | Bugs: ProtocolBugs{ |
| 9908 | SendTicketAge: 5 * time.Second, |
| 9909 | }, |
| 9910 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9911 | resumeSession: true, |
| 9912 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9913 | flags: []string{ |
| 9914 | "-resumption-delay", "10", |
| 9915 | "-expect-ticket-age-skew", "-5", |
| 9916 | }, |
| 9917 | }) |
| 9918 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9919 | testCases = append(testCases, testCase{ |
| 9920 | testType: clientTest, |
| 9921 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9922 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9923 | MaxVersion: VersionTLS13, |
| 9924 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9925 | }, |
| 9926 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9927 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9928 | "-expect-early-data-info", |
| 9929 | }, |
| 9930 | }) |
| 9931 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9932 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9933 | testCases = append(testCases, testCase{ |
| 9934 | testType: clientTest, |
| 9935 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9936 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9937 | MaxVersion: VersionTLS13, |
| 9938 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9939 | }, |
| 9940 | }) |
| 9941 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9942 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9943 | testType: clientTest, |
| 9944 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9945 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9946 | MaxVersion: VersionTLS13, |
| 9947 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9948 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9949 | DuplicateTicketEarlyDataInfo: true, |
| 9950 | }, |
| 9951 | }, |
| 9952 | shouldFail: true, |
| 9953 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9954 | expectedLocalError: "remote error: illegal parameter", |
| 9955 | }) |
| 9956 | |
| 9957 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9958 | testType: serverTest, |
| 9959 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9960 | config: Config{ |
| 9961 | MaxVersion: VersionTLS13, |
| 9962 | Bugs: ProtocolBugs{ |
| 9963 | ExpectTicketEarlyDataInfo: true, |
| 9964 | }, |
| 9965 | }, |
| 9966 | flags: []string{ |
| 9967 | "-enable-early-data", |
| 9968 | }, |
| 9969 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9970 | |
| 9971 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9972 | // is honored. |
| 9973 | testCases = append(testCases, testCase{ |
| 9974 | testType: clientTest, |
| 9975 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9976 | config: Config{ |
| 9977 | MaxVersion: VersionTLS13, |
| 9978 | Bugs: ProtocolBugs{ |
| 9979 | SendTicketLifetime: 20 * time.Second, |
| 9980 | }, |
| 9981 | }, |
| 9982 | flags: []string{ |
| 9983 | "-resumption-delay", "19", |
| 9984 | }, |
| 9985 | resumeSession: true, |
| 9986 | }) |
| 9987 | testCases = append(testCases, testCase{ |
| 9988 | testType: clientTest, |
| 9989 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9990 | config: Config{ |
| 9991 | MaxVersion: VersionTLS13, |
| 9992 | Bugs: ProtocolBugs{ |
| 9993 | SendTicketLifetime: 20 * time.Second, |
| 9994 | // The client should not offer the expired session. |
| 9995 | ExpectNoTLS13PSK: true, |
| 9996 | }, |
| 9997 | }, |
| 9998 | flags: []string{ |
| 9999 | "-resumption-delay", "21", |
| 10000 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 10001 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 10002 | expectResumeRejected: true, |
| 10003 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 10004 | } |
| 10005 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10006 | func addChangeCipherSpecTests() { |
| 10007 | // Test missing ChangeCipherSpecs. |
| 10008 | testCases = append(testCases, testCase{ |
| 10009 | name: "SkipChangeCipherSpec-Client", |
| 10010 | config: Config{ |
| 10011 | MaxVersion: VersionTLS12, |
| 10012 | Bugs: ProtocolBugs{ |
| 10013 | SkipChangeCipherSpec: true, |
| 10014 | }, |
| 10015 | }, |
| 10016 | shouldFail: true, |
| 10017 | expectedError: ":UNEXPECTED_RECORD:", |
| 10018 | }) |
| 10019 | testCases = append(testCases, testCase{ |
| 10020 | testType: serverTest, |
| 10021 | name: "SkipChangeCipherSpec-Server", |
| 10022 | config: Config{ |
| 10023 | MaxVersion: VersionTLS12, |
| 10024 | Bugs: ProtocolBugs{ |
| 10025 | SkipChangeCipherSpec: true, |
| 10026 | }, |
| 10027 | }, |
| 10028 | shouldFail: true, |
| 10029 | expectedError: ":UNEXPECTED_RECORD:", |
| 10030 | }) |
| 10031 | testCases = append(testCases, testCase{ |
| 10032 | testType: serverTest, |
| 10033 | name: "SkipChangeCipherSpec-Server-NPN", |
| 10034 | config: Config{ |
| 10035 | MaxVersion: VersionTLS12, |
| 10036 | NextProtos: []string{"bar"}, |
| 10037 | Bugs: ProtocolBugs{ |
| 10038 | SkipChangeCipherSpec: true, |
| 10039 | }, |
| 10040 | }, |
| 10041 | flags: []string{ |
| 10042 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10043 | }, |
| 10044 | shouldFail: true, |
| 10045 | expectedError: ":UNEXPECTED_RECORD:", |
| 10046 | }) |
| 10047 | |
| 10048 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 10049 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 10050 | // rejected. Test both with and without handshake packing to handle both |
| 10051 | // when the partial post-CCS message is in its own record and when it is |
| 10052 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10053 | for _, packed := range []bool{false, true} { |
| 10054 | var suffix string |
| 10055 | if packed { |
| 10056 | suffix = "-Packed" |
| 10057 | } |
| 10058 | |
| 10059 | testCases = append(testCases, testCase{ |
| 10060 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 10061 | config: Config{ |
| 10062 | MaxVersion: VersionTLS12, |
| 10063 | Bugs: ProtocolBugs{ |
| 10064 | FragmentAcrossChangeCipherSpec: true, |
| 10065 | PackHandshakeFlight: packed, |
| 10066 | }, |
| 10067 | }, |
| 10068 | shouldFail: true, |
| 10069 | expectedError: ":UNEXPECTED_RECORD:", |
| 10070 | }) |
| 10071 | testCases = append(testCases, testCase{ |
| 10072 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 10073 | config: Config{ |
| 10074 | MaxVersion: VersionTLS12, |
| 10075 | }, |
| 10076 | resumeSession: true, |
| 10077 | resumeConfig: &Config{ |
| 10078 | MaxVersion: VersionTLS12, |
| 10079 | Bugs: ProtocolBugs{ |
| 10080 | FragmentAcrossChangeCipherSpec: true, |
| 10081 | PackHandshakeFlight: packed, |
| 10082 | }, |
| 10083 | }, |
| 10084 | shouldFail: true, |
| 10085 | expectedError: ":UNEXPECTED_RECORD:", |
| 10086 | }) |
| 10087 | testCases = append(testCases, testCase{ |
| 10088 | testType: serverTest, |
| 10089 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 10090 | config: Config{ |
| 10091 | MaxVersion: VersionTLS12, |
| 10092 | Bugs: ProtocolBugs{ |
| 10093 | FragmentAcrossChangeCipherSpec: true, |
| 10094 | PackHandshakeFlight: packed, |
| 10095 | }, |
| 10096 | }, |
| 10097 | shouldFail: true, |
| 10098 | expectedError: ":UNEXPECTED_RECORD:", |
| 10099 | }) |
| 10100 | testCases = append(testCases, testCase{ |
| 10101 | testType: serverTest, |
| 10102 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 10103 | config: Config{ |
| 10104 | MaxVersion: VersionTLS12, |
| 10105 | }, |
| 10106 | resumeSession: true, |
| 10107 | resumeConfig: &Config{ |
| 10108 | MaxVersion: VersionTLS12, |
| 10109 | Bugs: ProtocolBugs{ |
| 10110 | FragmentAcrossChangeCipherSpec: true, |
| 10111 | PackHandshakeFlight: packed, |
| 10112 | }, |
| 10113 | }, |
| 10114 | shouldFail: true, |
| 10115 | expectedError: ":UNEXPECTED_RECORD:", |
| 10116 | }) |
| 10117 | testCases = append(testCases, testCase{ |
| 10118 | testType: serverTest, |
| 10119 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 10120 | config: Config{ |
| 10121 | MaxVersion: VersionTLS12, |
| 10122 | NextProtos: []string{"bar"}, |
| 10123 | Bugs: ProtocolBugs{ |
| 10124 | FragmentAcrossChangeCipherSpec: true, |
| 10125 | PackHandshakeFlight: packed, |
| 10126 | }, |
| 10127 | }, |
| 10128 | flags: []string{ |
| 10129 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10130 | }, |
| 10131 | shouldFail: true, |
| 10132 | expectedError: ":UNEXPECTED_RECORD:", |
| 10133 | }) |
| 10134 | } |
| 10135 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 10136 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 10137 | // messages in the handshake queue. Do this by testing the server |
| 10138 | // reading the client Finished, reversing the flight so Finished comes |
| 10139 | // first. |
| 10140 | testCases = append(testCases, testCase{ |
| 10141 | protocol: dtls, |
| 10142 | testType: serverTest, |
| 10143 | name: "SendUnencryptedFinished-DTLS", |
| 10144 | config: Config{ |
| 10145 | MaxVersion: VersionTLS12, |
| 10146 | Bugs: ProtocolBugs{ |
| 10147 | SendUnencryptedFinished: true, |
| 10148 | ReverseHandshakeFragments: true, |
| 10149 | }, |
| 10150 | }, |
| 10151 | shouldFail: true, |
| 10152 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10153 | }) |
| 10154 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10155 | // Test synchronization between encryption changes and the handshake in |
| 10156 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 10157 | testCases = append(testCases, testCase{ |
| 10158 | name: "PartialEncryptedExtensionsWithServerHello", |
| 10159 | config: Config{ |
| 10160 | MaxVersion: VersionTLS13, |
| 10161 | Bugs: ProtocolBugs{ |
| 10162 | PartialEncryptedExtensionsWithServerHello: true, |
| 10163 | }, |
| 10164 | }, |
| 10165 | shouldFail: true, |
| 10166 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10167 | }) |
| 10168 | testCases = append(testCases, testCase{ |
| 10169 | testType: serverTest, |
| 10170 | name: "PartialClientFinishedWithClientHello", |
| 10171 | config: Config{ |
| 10172 | MaxVersion: VersionTLS13, |
| 10173 | Bugs: ProtocolBugs{ |
| 10174 | PartialClientFinishedWithClientHello: true, |
| 10175 | }, |
| 10176 | }, |
| 10177 | shouldFail: true, |
| 10178 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10179 | }) |
| 10180 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10181 | // Test that early ChangeCipherSpecs are handled correctly. |
| 10182 | testCases = append(testCases, testCase{ |
| 10183 | testType: serverTest, |
| 10184 | name: "EarlyChangeCipherSpec-server-1", |
| 10185 | config: Config{ |
| 10186 | MaxVersion: VersionTLS12, |
| 10187 | Bugs: ProtocolBugs{ |
| 10188 | EarlyChangeCipherSpec: 1, |
| 10189 | }, |
| 10190 | }, |
| 10191 | shouldFail: true, |
| 10192 | expectedError: ":UNEXPECTED_RECORD:", |
| 10193 | }) |
| 10194 | testCases = append(testCases, testCase{ |
| 10195 | testType: serverTest, |
| 10196 | name: "EarlyChangeCipherSpec-server-2", |
| 10197 | config: Config{ |
| 10198 | MaxVersion: VersionTLS12, |
| 10199 | Bugs: ProtocolBugs{ |
| 10200 | EarlyChangeCipherSpec: 2, |
| 10201 | }, |
| 10202 | }, |
| 10203 | shouldFail: true, |
| 10204 | expectedError: ":UNEXPECTED_RECORD:", |
| 10205 | }) |
| 10206 | testCases = append(testCases, testCase{ |
| 10207 | protocol: dtls, |
| 10208 | name: "StrayChangeCipherSpec", |
| 10209 | config: Config{ |
| 10210 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10211 | // that stray ChangeCipherSpec messages are |
| 10212 | // rejected. |
| 10213 | MaxVersion: VersionTLS12, |
| 10214 | Bugs: ProtocolBugs{ |
| 10215 | StrayChangeCipherSpec: true, |
| 10216 | }, |
| 10217 | }, |
| 10218 | }) |
| 10219 | |
David Benjamin | b0c761e | 2017-06-25 22:42:55 -0400 | [diff] [blame] | 10220 | // Test that reordered ChangeCipherSpecs are tolerated. |
| 10221 | testCases = append(testCases, testCase{ |
| 10222 | protocol: dtls, |
| 10223 | name: "ReorderChangeCipherSpec-DTLS-Client", |
| 10224 | config: Config{ |
| 10225 | MaxVersion: VersionTLS12, |
| 10226 | Bugs: ProtocolBugs{ |
| 10227 | ReorderChangeCipherSpec: true, |
| 10228 | }, |
| 10229 | }, |
| 10230 | resumeSession: true, |
| 10231 | }) |
| 10232 | testCases = append(testCases, testCase{ |
| 10233 | testType: serverTest, |
| 10234 | protocol: dtls, |
| 10235 | name: "ReorderChangeCipherSpec-DTLS-Server", |
| 10236 | config: Config{ |
| 10237 | MaxVersion: VersionTLS12, |
| 10238 | Bugs: ProtocolBugs{ |
| 10239 | ReorderChangeCipherSpec: true, |
| 10240 | }, |
| 10241 | }, |
| 10242 | resumeSession: true, |
| 10243 | }) |
| 10244 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10245 | // Test that the contents of ChangeCipherSpec are checked. |
| 10246 | testCases = append(testCases, testCase{ |
| 10247 | name: "BadChangeCipherSpec-1", |
| 10248 | config: Config{ |
| 10249 | MaxVersion: VersionTLS12, |
| 10250 | Bugs: ProtocolBugs{ |
| 10251 | BadChangeCipherSpec: []byte{2}, |
| 10252 | }, |
| 10253 | }, |
| 10254 | shouldFail: true, |
| 10255 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10256 | }) |
| 10257 | testCases = append(testCases, testCase{ |
| 10258 | name: "BadChangeCipherSpec-2", |
| 10259 | config: Config{ |
| 10260 | MaxVersion: VersionTLS12, |
| 10261 | Bugs: ProtocolBugs{ |
| 10262 | BadChangeCipherSpec: []byte{1, 1}, |
| 10263 | }, |
| 10264 | }, |
| 10265 | shouldFail: true, |
| 10266 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10267 | }) |
| 10268 | testCases = append(testCases, testCase{ |
| 10269 | protocol: dtls, |
| 10270 | name: "BadChangeCipherSpec-DTLS-1", |
| 10271 | config: Config{ |
| 10272 | MaxVersion: VersionTLS12, |
| 10273 | Bugs: ProtocolBugs{ |
| 10274 | BadChangeCipherSpec: []byte{2}, |
| 10275 | }, |
| 10276 | }, |
| 10277 | shouldFail: true, |
| 10278 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10279 | }) |
| 10280 | testCases = append(testCases, testCase{ |
| 10281 | protocol: dtls, |
| 10282 | name: "BadChangeCipherSpec-DTLS-2", |
| 10283 | config: Config{ |
| 10284 | MaxVersion: VersionTLS12, |
| 10285 | Bugs: ProtocolBugs{ |
| 10286 | BadChangeCipherSpec: []byte{1, 1}, |
| 10287 | }, |
| 10288 | }, |
| 10289 | shouldFail: true, |
| 10290 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10291 | }) |
| 10292 | } |
| 10293 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10294 | type perMessageTest struct { |
| 10295 | messageType uint8 |
| 10296 | test testCase |
| 10297 | } |
| 10298 | |
| 10299 | // makePerMessageTests returns a series of test templates which cover each |
| 10300 | // message in the TLS handshake. These may be used with bugs like |
| 10301 | // WrongMessageType to fully test a per-message bug. |
| 10302 | func makePerMessageTests() []perMessageTest { |
| 10303 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10304 | for _, protocol := range []protocol{tls, dtls} { |
| 10305 | var suffix string |
| 10306 | if protocol == dtls { |
| 10307 | suffix = "-DTLS" |
| 10308 | } |
| 10309 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10310 | ret = append(ret, perMessageTest{ |
| 10311 | messageType: typeClientHello, |
| 10312 | test: testCase{ |
| 10313 | protocol: protocol, |
| 10314 | testType: serverTest, |
| 10315 | name: "ClientHello" + suffix, |
| 10316 | config: Config{ |
| 10317 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10318 | }, |
| 10319 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10320 | }) |
| 10321 | |
| 10322 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10323 | ret = append(ret, perMessageTest{ |
| 10324 | messageType: typeHelloVerifyRequest, |
| 10325 | test: testCase{ |
| 10326 | protocol: protocol, |
| 10327 | name: "HelloVerifyRequest" + suffix, |
| 10328 | config: Config{ |
| 10329 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10330 | }, |
| 10331 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10332 | }) |
| 10333 | } |
| 10334 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10335 | ret = append(ret, perMessageTest{ |
| 10336 | messageType: typeServerHello, |
| 10337 | test: testCase{ |
| 10338 | protocol: protocol, |
| 10339 | name: "ServerHello" + suffix, |
| 10340 | config: Config{ |
| 10341 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10342 | }, |
| 10343 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10344 | }) |
| 10345 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10346 | ret = append(ret, perMessageTest{ |
| 10347 | messageType: typeCertificate, |
| 10348 | test: testCase{ |
| 10349 | protocol: protocol, |
| 10350 | name: "ServerCertificate" + suffix, |
| 10351 | config: Config{ |
| 10352 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10353 | }, |
| 10354 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10355 | }) |
| 10356 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10357 | ret = append(ret, perMessageTest{ |
| 10358 | messageType: typeCertificateStatus, |
| 10359 | test: testCase{ |
| 10360 | protocol: protocol, |
| 10361 | name: "CertificateStatus" + suffix, |
| 10362 | config: Config{ |
| 10363 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10364 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10365 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10366 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10367 | }) |
| 10368 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10369 | ret = append(ret, perMessageTest{ |
| 10370 | messageType: typeServerKeyExchange, |
| 10371 | test: testCase{ |
| 10372 | protocol: protocol, |
| 10373 | name: "ServerKeyExchange" + suffix, |
| 10374 | config: Config{ |
| 10375 | MaxVersion: VersionTLS12, |
| 10376 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10377 | }, |
| 10378 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10379 | }) |
| 10380 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10381 | ret = append(ret, perMessageTest{ |
| 10382 | messageType: typeCertificateRequest, |
| 10383 | test: testCase{ |
| 10384 | protocol: protocol, |
| 10385 | name: "CertificateRequest" + suffix, |
| 10386 | config: Config{ |
| 10387 | MaxVersion: VersionTLS12, |
| 10388 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10389 | }, |
| 10390 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10391 | }) |
| 10392 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10393 | ret = append(ret, perMessageTest{ |
| 10394 | messageType: typeServerHelloDone, |
| 10395 | test: testCase{ |
| 10396 | protocol: protocol, |
| 10397 | name: "ServerHelloDone" + suffix, |
| 10398 | config: Config{ |
| 10399 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10400 | }, |
| 10401 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10402 | }) |
| 10403 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10404 | ret = append(ret, perMessageTest{ |
| 10405 | messageType: typeCertificate, |
| 10406 | test: testCase{ |
| 10407 | testType: serverTest, |
| 10408 | protocol: protocol, |
| 10409 | name: "ClientCertificate" + suffix, |
| 10410 | config: Config{ |
| 10411 | Certificates: []Certificate{rsaCertificate}, |
| 10412 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10413 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10414 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10415 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10416 | }) |
| 10417 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10418 | ret = append(ret, perMessageTest{ |
| 10419 | messageType: typeCertificateVerify, |
| 10420 | test: testCase{ |
| 10421 | testType: serverTest, |
| 10422 | protocol: protocol, |
| 10423 | name: "CertificateVerify" + suffix, |
| 10424 | config: Config{ |
| 10425 | Certificates: []Certificate{rsaCertificate}, |
| 10426 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10427 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10428 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10429 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10430 | }) |
| 10431 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10432 | ret = append(ret, perMessageTest{ |
| 10433 | messageType: typeClientKeyExchange, |
| 10434 | test: testCase{ |
| 10435 | testType: serverTest, |
| 10436 | protocol: protocol, |
| 10437 | name: "ClientKeyExchange" + suffix, |
| 10438 | config: Config{ |
| 10439 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10440 | }, |
| 10441 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10442 | }) |
| 10443 | |
| 10444 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10445 | ret = append(ret, perMessageTest{ |
| 10446 | messageType: typeNextProtocol, |
| 10447 | test: testCase{ |
| 10448 | testType: serverTest, |
| 10449 | protocol: protocol, |
| 10450 | name: "NextProtocol" + suffix, |
| 10451 | config: Config{ |
| 10452 | MaxVersion: VersionTLS12, |
| 10453 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10454 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10455 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10456 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10457 | }) |
| 10458 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10459 | ret = append(ret, perMessageTest{ |
| 10460 | messageType: typeChannelID, |
| 10461 | test: testCase{ |
| 10462 | testType: serverTest, |
| 10463 | protocol: protocol, |
| 10464 | name: "ChannelID" + suffix, |
| 10465 | config: Config{ |
| 10466 | MaxVersion: VersionTLS12, |
| 10467 | ChannelID: channelIDKey, |
| 10468 | }, |
| 10469 | flags: []string{ |
| 10470 | "-expect-channel-id", |
| 10471 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10472 | }, |
| 10473 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10474 | }) |
| 10475 | } |
| 10476 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10477 | ret = append(ret, perMessageTest{ |
| 10478 | messageType: typeFinished, |
| 10479 | test: testCase{ |
| 10480 | testType: serverTest, |
| 10481 | protocol: protocol, |
| 10482 | name: "ClientFinished" + suffix, |
| 10483 | config: Config{ |
| 10484 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10485 | }, |
| 10486 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10487 | }) |
| 10488 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10489 | ret = append(ret, perMessageTest{ |
| 10490 | messageType: typeNewSessionTicket, |
| 10491 | test: testCase{ |
| 10492 | protocol: protocol, |
| 10493 | name: "NewSessionTicket" + suffix, |
| 10494 | config: Config{ |
| 10495 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10496 | }, |
| 10497 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10498 | }) |
| 10499 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10500 | ret = append(ret, perMessageTest{ |
| 10501 | messageType: typeFinished, |
| 10502 | test: testCase{ |
| 10503 | protocol: protocol, |
| 10504 | name: "ServerFinished" + suffix, |
| 10505 | config: Config{ |
| 10506 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10507 | }, |
| 10508 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10509 | }) |
| 10510 | |
| 10511 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10512 | |
| 10513 | ret = append(ret, perMessageTest{ |
| 10514 | messageType: typeClientHello, |
| 10515 | test: testCase{ |
| 10516 | testType: serverTest, |
| 10517 | name: "TLS13-ClientHello", |
| 10518 | config: Config{ |
| 10519 | MaxVersion: VersionTLS13, |
| 10520 | }, |
| 10521 | }, |
| 10522 | }) |
| 10523 | |
| 10524 | ret = append(ret, perMessageTest{ |
| 10525 | messageType: typeServerHello, |
| 10526 | test: testCase{ |
| 10527 | name: "TLS13-ServerHello", |
| 10528 | config: Config{ |
| 10529 | MaxVersion: VersionTLS13, |
| 10530 | }, |
| 10531 | }, |
| 10532 | }) |
| 10533 | |
| 10534 | ret = append(ret, perMessageTest{ |
| 10535 | messageType: typeEncryptedExtensions, |
| 10536 | test: testCase{ |
| 10537 | name: "TLS13-EncryptedExtensions", |
| 10538 | config: Config{ |
| 10539 | MaxVersion: VersionTLS13, |
| 10540 | }, |
| 10541 | }, |
| 10542 | }) |
| 10543 | |
| 10544 | ret = append(ret, perMessageTest{ |
| 10545 | messageType: typeCertificateRequest, |
| 10546 | test: testCase{ |
| 10547 | name: "TLS13-CertificateRequest", |
| 10548 | config: Config{ |
| 10549 | MaxVersion: VersionTLS13, |
| 10550 | ClientAuth: RequireAnyClientCert, |
| 10551 | }, |
| 10552 | }, |
| 10553 | }) |
| 10554 | |
| 10555 | ret = append(ret, perMessageTest{ |
| 10556 | messageType: typeCertificate, |
| 10557 | test: testCase{ |
| 10558 | name: "TLS13-ServerCertificate", |
| 10559 | config: Config{ |
| 10560 | MaxVersion: VersionTLS13, |
| 10561 | }, |
| 10562 | }, |
| 10563 | }) |
| 10564 | |
| 10565 | ret = append(ret, perMessageTest{ |
| 10566 | messageType: typeCertificateVerify, |
| 10567 | test: testCase{ |
| 10568 | name: "TLS13-ServerCertificateVerify", |
| 10569 | config: Config{ |
| 10570 | MaxVersion: VersionTLS13, |
| 10571 | }, |
| 10572 | }, |
| 10573 | }) |
| 10574 | |
| 10575 | ret = append(ret, perMessageTest{ |
| 10576 | messageType: typeFinished, |
| 10577 | test: testCase{ |
| 10578 | name: "TLS13-ServerFinished", |
| 10579 | config: Config{ |
| 10580 | MaxVersion: VersionTLS13, |
| 10581 | }, |
| 10582 | }, |
| 10583 | }) |
| 10584 | |
| 10585 | ret = append(ret, perMessageTest{ |
| 10586 | messageType: typeCertificate, |
| 10587 | test: testCase{ |
| 10588 | testType: serverTest, |
| 10589 | name: "TLS13-ClientCertificate", |
| 10590 | config: Config{ |
| 10591 | Certificates: []Certificate{rsaCertificate}, |
| 10592 | MaxVersion: VersionTLS13, |
| 10593 | }, |
| 10594 | flags: []string{"-require-any-client-certificate"}, |
| 10595 | }, |
| 10596 | }) |
| 10597 | |
| 10598 | ret = append(ret, perMessageTest{ |
| 10599 | messageType: typeCertificateVerify, |
| 10600 | test: testCase{ |
| 10601 | testType: serverTest, |
| 10602 | name: "TLS13-ClientCertificateVerify", |
| 10603 | config: Config{ |
| 10604 | Certificates: []Certificate{rsaCertificate}, |
| 10605 | MaxVersion: VersionTLS13, |
| 10606 | }, |
| 10607 | flags: []string{"-require-any-client-certificate"}, |
| 10608 | }, |
| 10609 | }) |
| 10610 | |
| 10611 | ret = append(ret, perMessageTest{ |
| 10612 | messageType: typeFinished, |
| 10613 | test: testCase{ |
| 10614 | testType: serverTest, |
| 10615 | name: "TLS13-ClientFinished", |
| 10616 | config: Config{ |
| 10617 | MaxVersion: VersionTLS13, |
| 10618 | }, |
| 10619 | }, |
| 10620 | }) |
| 10621 | |
| 10622 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10623 | } |
| 10624 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10625 | func addWrongMessageTypeTests() { |
| 10626 | for _, t := range makePerMessageTests() { |
| 10627 | t.test.name = "WrongMessageType-" + t.test.name |
| 10628 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10629 | t.test.shouldFail = true |
| 10630 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10631 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10632 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10633 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10634 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10635 | // an unencrypted alert while the server expects |
| 10636 | // encryption, so the alert is not readable by runner. |
| 10637 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10638 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10639 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10640 | testCases = append(testCases, t.test) |
| 10641 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10642 | |
| 10643 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10644 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10645 | // TLS 1.2. Test that we do not do this. |
| 10646 | testCases = append(testCases, testCase{ |
| 10647 | name: "SendServerHelloAsHelloRetryRequest", |
| 10648 | config: Config{ |
| 10649 | MaxVersion: VersionTLS12, |
| 10650 | Bugs: ProtocolBugs{ |
| 10651 | SendServerHelloAsHelloRetryRequest: true, |
| 10652 | }, |
| 10653 | }, |
| 10654 | shouldFail: true, |
| 10655 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10656 | expectedLocalError: "remote error: unexpected message", |
| 10657 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10658 | } |
| 10659 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10660 | func addTrailingMessageDataTests() { |
| 10661 | for _, t := range makePerMessageTests() { |
| 10662 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10663 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10664 | t.test.shouldFail = true |
| 10665 | t.test.expectedError = ":DECODE_ERROR:" |
| 10666 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10667 | |
| 10668 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10669 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10670 | // an unencrypted alert while the server expects |
| 10671 | // encryption, so the alert is not readable by runner. |
| 10672 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10673 | } |
| 10674 | |
| 10675 | if t.messageType == typeFinished { |
| 10676 | // Bad Finished messages read as the verify data having |
| 10677 | // the wrong length. |
| 10678 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10679 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10680 | } |
| 10681 | |
| 10682 | testCases = append(testCases, t.test) |
| 10683 | } |
| 10684 | } |
| 10685 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10686 | func addTLS13HandshakeTests() { |
| 10687 | testCases = append(testCases, testCase{ |
| 10688 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10689 | name: "NegotiatePSKResumption-TLS13", |
| 10690 | config: Config{ |
| 10691 | MaxVersion: VersionTLS13, |
| 10692 | Bugs: ProtocolBugs{ |
| 10693 | NegotiatePSKResumption: true, |
| 10694 | }, |
| 10695 | }, |
| 10696 | resumeSession: true, |
| 10697 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10698 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10699 | }) |
| 10700 | |
| 10701 | testCases = append(testCases, testCase{ |
| 10702 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10703 | name: "MissingKeyShare-Client", |
| 10704 | config: Config{ |
| 10705 | MaxVersion: VersionTLS13, |
| 10706 | Bugs: ProtocolBugs{ |
| 10707 | MissingKeyShare: true, |
| 10708 | }, |
| 10709 | }, |
| 10710 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10711 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10712 | }) |
| 10713 | |
| 10714 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10715 | testType: serverTest, |
| 10716 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10717 | config: Config{ |
| 10718 | MaxVersion: VersionTLS13, |
| 10719 | Bugs: ProtocolBugs{ |
| 10720 | MissingKeyShare: true, |
| 10721 | }, |
| 10722 | }, |
| 10723 | shouldFail: true, |
| 10724 | expectedError: ":MISSING_KEY_SHARE:", |
| 10725 | }) |
| 10726 | |
| 10727 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10728 | testType: serverTest, |
| 10729 | name: "DuplicateKeyShares", |
| 10730 | config: Config{ |
| 10731 | MaxVersion: VersionTLS13, |
| 10732 | Bugs: ProtocolBugs{ |
| 10733 | DuplicateKeyShares: true, |
| 10734 | }, |
| 10735 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10736 | shouldFail: true, |
| 10737 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10738 | }) |
| 10739 | |
| 10740 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10741 | testType: serverTest, |
| 10742 | name: "SkipEarlyData", |
| 10743 | config: Config{ |
| 10744 | MaxVersion: VersionTLS13, |
| 10745 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10746 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10747 | }, |
| 10748 | }, |
| 10749 | }) |
| 10750 | |
| 10751 | testCases = append(testCases, testCase{ |
| 10752 | testType: serverTest, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 10753 | name: "SkipEarlyData-TLS13Experiment", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10754 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10755 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10756 | Bugs: ProtocolBugs{ |
| 10757 | SendFakeEarlyDataLength: 4, |
| 10758 | }, |
| 10759 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10760 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10761 | }) |
| 10762 | |
| 10763 | testCases = append(testCases, testCase{ |
| 10764 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10765 | name: "SkipEarlyData-TLS13RecordTypeExperiment", |
| 10766 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10767 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10768 | Bugs: ProtocolBugs{ |
| 10769 | SendFakeEarlyDataLength: 4, |
| 10770 | }, |
| 10771 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10772 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10773 | }) |
| 10774 | |
| 10775 | testCases = append(testCases, testCase{ |
| 10776 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10777 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10778 | config: Config{ |
| 10779 | MaxVersion: VersionTLS13, |
| 10780 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10781 | SendFakeEarlyDataLength: 4, |
| 10782 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10783 | }, |
| 10784 | }, |
| 10785 | shouldFail: true, |
| 10786 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10787 | }) |
| 10788 | |
| 10789 | testCases = append(testCases, testCase{ |
| 10790 | testType: serverTest, |
| 10791 | name: "SkipEarlyData-TooMuchData", |
| 10792 | config: Config{ |
| 10793 | MaxVersion: VersionTLS13, |
| 10794 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10795 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10796 | }, |
| 10797 | }, |
| 10798 | shouldFail: true, |
| 10799 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10800 | }) |
| 10801 | |
| 10802 | testCases = append(testCases, testCase{ |
| 10803 | testType: serverTest, |
| 10804 | name: "SkipEarlyData-Interleaved", |
| 10805 | config: Config{ |
| 10806 | MaxVersion: VersionTLS13, |
| 10807 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10808 | SendFakeEarlyDataLength: 4, |
| 10809 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10810 | }, |
| 10811 | }, |
| 10812 | shouldFail: true, |
| 10813 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10814 | }) |
| 10815 | |
| 10816 | testCases = append(testCases, testCase{ |
| 10817 | testType: serverTest, |
| 10818 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10819 | config: Config{ |
| 10820 | MaxVersion: VersionTLS13, |
| 10821 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10822 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10823 | }, |
| 10824 | }, |
| 10825 | shouldFail: true, |
| 10826 | expectedError: ":UNEXPECTED_RECORD:", |
| 10827 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10828 | }) |
| 10829 | |
| 10830 | testCases = append(testCases, testCase{ |
| 10831 | testType: serverTest, |
| 10832 | name: "SkipEarlyData-HRR", |
| 10833 | config: Config{ |
| 10834 | MaxVersion: VersionTLS13, |
| 10835 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10836 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10837 | }, |
| 10838 | DefaultCurves: []CurveID{}, |
| 10839 | }, |
| 10840 | }) |
| 10841 | |
| 10842 | testCases = append(testCases, testCase{ |
| 10843 | testType: serverTest, |
| 10844 | name: "SkipEarlyData-HRR-Interleaved", |
| 10845 | config: Config{ |
| 10846 | MaxVersion: VersionTLS13, |
| 10847 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10848 | SendFakeEarlyDataLength: 4, |
| 10849 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10850 | }, |
| 10851 | DefaultCurves: []CurveID{}, |
| 10852 | }, |
| 10853 | shouldFail: true, |
| 10854 | expectedError: ":UNEXPECTED_RECORD:", |
| 10855 | }) |
| 10856 | |
| 10857 | testCases = append(testCases, testCase{ |
| 10858 | testType: serverTest, |
| 10859 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10860 | config: Config{ |
| 10861 | MaxVersion: VersionTLS13, |
| 10862 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10863 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10864 | }, |
| 10865 | DefaultCurves: []CurveID{}, |
| 10866 | }, |
| 10867 | shouldFail: true, |
| 10868 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10869 | }) |
| 10870 | |
| 10871 | // Test that skipping early data looking for cleartext correctly |
| 10872 | // processes an alert record. |
| 10873 | testCases = append(testCases, testCase{ |
| 10874 | testType: serverTest, |
| 10875 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10876 | config: Config{ |
| 10877 | MaxVersion: VersionTLS13, |
| 10878 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10879 | SendEarlyAlert: true, |
| 10880 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10881 | }, |
| 10882 | DefaultCurves: []CurveID{}, |
| 10883 | }, |
| 10884 | shouldFail: true, |
| 10885 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10886 | }) |
| 10887 | |
| 10888 | testCases = append(testCases, testCase{ |
| 10889 | testType: serverTest, |
| 10890 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10891 | config: Config{ |
| 10892 | MaxVersion: VersionTLS13, |
| 10893 | Bugs: ProtocolBugs{ |
| 10894 | SendEarlyDataOnSecondClientHello: true, |
| 10895 | }, |
| 10896 | DefaultCurves: []CurveID{}, |
| 10897 | }, |
| 10898 | shouldFail: true, |
| 10899 | expectedLocalError: "remote error: bad record MAC", |
| 10900 | }) |
| 10901 | |
| 10902 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10903 | testType: clientTest, |
| 10904 | name: "EmptyEncryptedExtensions", |
| 10905 | config: Config{ |
| 10906 | MaxVersion: VersionTLS13, |
| 10907 | Bugs: ProtocolBugs{ |
| 10908 | EmptyEncryptedExtensions: true, |
| 10909 | }, |
| 10910 | }, |
| 10911 | shouldFail: true, |
| 10912 | expectedLocalError: "remote error: error decoding message", |
| 10913 | }) |
| 10914 | |
| 10915 | testCases = append(testCases, testCase{ |
| 10916 | testType: clientTest, |
| 10917 | name: "EncryptedExtensionsWithKeyShare", |
| 10918 | config: Config{ |
| 10919 | MaxVersion: VersionTLS13, |
| 10920 | Bugs: ProtocolBugs{ |
| 10921 | EncryptedExtensionsWithKeyShare: true, |
| 10922 | }, |
| 10923 | }, |
| 10924 | shouldFail: true, |
| 10925 | expectedLocalError: "remote error: unsupported extension", |
| 10926 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10927 | |
| 10928 | testCases = append(testCases, testCase{ |
| 10929 | testType: serverTest, |
| 10930 | name: "SendHelloRetryRequest", |
| 10931 | config: Config{ |
| 10932 | MaxVersion: VersionTLS13, |
| 10933 | // Require a HelloRetryRequest for every curve. |
| 10934 | DefaultCurves: []CurveID{}, |
| 10935 | }, |
| 10936 | expectedCurveID: CurveX25519, |
| 10937 | }) |
| 10938 | |
| 10939 | testCases = append(testCases, testCase{ |
| 10940 | testType: serverTest, |
| 10941 | name: "SendHelloRetryRequest-2", |
| 10942 | config: Config{ |
| 10943 | MaxVersion: VersionTLS13, |
| 10944 | DefaultCurves: []CurveID{CurveP384}, |
| 10945 | }, |
| 10946 | // Although the ClientHello did not predict our preferred curve, |
| 10947 | // we always select it whether it is predicted or not. |
| 10948 | expectedCurveID: CurveX25519, |
| 10949 | }) |
| 10950 | |
| 10951 | testCases = append(testCases, testCase{ |
| 10952 | name: "UnknownCurve-HelloRetryRequest", |
| 10953 | config: Config{ |
| 10954 | MaxVersion: VersionTLS13, |
| 10955 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10956 | CurvePreferences: []CurveID{CurveP384}, |
| 10957 | Bugs: ProtocolBugs{ |
| 10958 | SendHelloRetryRequestCurve: bogusCurve, |
| 10959 | }, |
| 10960 | }, |
| 10961 | shouldFail: true, |
| 10962 | expectedError: ":WRONG_CURVE:", |
| 10963 | }) |
| 10964 | |
| 10965 | testCases = append(testCases, testCase{ |
| 10966 | name: "DisabledCurve-HelloRetryRequest", |
| 10967 | config: Config{ |
| 10968 | MaxVersion: VersionTLS13, |
| 10969 | CurvePreferences: []CurveID{CurveP256}, |
| 10970 | Bugs: ProtocolBugs{ |
| 10971 | IgnorePeerCurvePreferences: true, |
| 10972 | }, |
| 10973 | }, |
| 10974 | flags: []string{"-p384-only"}, |
| 10975 | shouldFail: true, |
| 10976 | expectedError: ":WRONG_CURVE:", |
| 10977 | }) |
| 10978 | |
| 10979 | testCases = append(testCases, testCase{ |
| 10980 | name: "UnnecessaryHelloRetryRequest", |
| 10981 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10982 | MaxVersion: VersionTLS13, |
| 10983 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10984 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10985 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10986 | }, |
| 10987 | }, |
| 10988 | shouldFail: true, |
| 10989 | expectedError: ":WRONG_CURVE:", |
| 10990 | }) |
| 10991 | |
| 10992 | testCases = append(testCases, testCase{ |
| 10993 | name: "SecondHelloRetryRequest", |
| 10994 | config: Config{ |
| 10995 | MaxVersion: VersionTLS13, |
| 10996 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10997 | CurvePreferences: []CurveID{CurveP384}, |
| 10998 | Bugs: ProtocolBugs{ |
| 10999 | SecondHelloRetryRequest: true, |
| 11000 | }, |
| 11001 | }, |
| 11002 | shouldFail: true, |
| 11003 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 11004 | }) |
| 11005 | |
| 11006 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 11007 | name: "HelloRetryRequest-Empty", |
| 11008 | config: Config{ |
| 11009 | MaxVersion: VersionTLS13, |
| 11010 | Bugs: ProtocolBugs{ |
| 11011 | AlwaysSendHelloRetryRequest: true, |
| 11012 | }, |
| 11013 | }, |
| 11014 | shouldFail: true, |
| 11015 | expectedError: ":DECODE_ERROR:", |
| 11016 | }) |
| 11017 | |
| 11018 | testCases = append(testCases, testCase{ |
| 11019 | name: "HelloRetryRequest-DuplicateCurve", |
| 11020 | config: Config{ |
| 11021 | MaxVersion: VersionTLS13, |
| 11022 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 11023 | // configuration. Assert this ExpectMissingKeyShare. |
| 11024 | CurvePreferences: []CurveID{CurveP384}, |
| 11025 | Bugs: ProtocolBugs{ |
| 11026 | ExpectMissingKeyShare: true, |
| 11027 | DuplicateHelloRetryRequestExtensions: true, |
| 11028 | }, |
| 11029 | }, |
| 11030 | shouldFail: true, |
| 11031 | expectedError: ":DUPLICATE_EXTENSION:", |
| 11032 | expectedLocalError: "remote error: illegal parameter", |
| 11033 | }) |
| 11034 | |
| 11035 | testCases = append(testCases, testCase{ |
| 11036 | name: "HelloRetryRequest-Cookie", |
| 11037 | config: Config{ |
| 11038 | MaxVersion: VersionTLS13, |
| 11039 | Bugs: ProtocolBugs{ |
| 11040 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11041 | }, |
| 11042 | }, |
| 11043 | }) |
| 11044 | |
| 11045 | testCases = append(testCases, testCase{ |
| 11046 | name: "HelloRetryRequest-DuplicateCookie", |
| 11047 | config: Config{ |
| 11048 | MaxVersion: VersionTLS13, |
| 11049 | Bugs: ProtocolBugs{ |
| 11050 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11051 | DuplicateHelloRetryRequestExtensions: true, |
| 11052 | }, |
| 11053 | }, |
| 11054 | shouldFail: true, |
| 11055 | expectedError: ":DUPLICATE_EXTENSION:", |
| 11056 | expectedLocalError: "remote error: illegal parameter", |
| 11057 | }) |
| 11058 | |
| 11059 | testCases = append(testCases, testCase{ |
| 11060 | name: "HelloRetryRequest-EmptyCookie", |
| 11061 | config: Config{ |
| 11062 | MaxVersion: VersionTLS13, |
| 11063 | Bugs: ProtocolBugs{ |
| 11064 | SendHelloRetryRequestCookie: []byte{}, |
| 11065 | }, |
| 11066 | }, |
| 11067 | shouldFail: true, |
| 11068 | expectedError: ":DECODE_ERROR:", |
| 11069 | }) |
| 11070 | |
| 11071 | testCases = append(testCases, testCase{ |
| 11072 | name: "HelloRetryRequest-Cookie-Curve", |
| 11073 | config: Config{ |
| 11074 | MaxVersion: VersionTLS13, |
| 11075 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11076 | CurvePreferences: []CurveID{CurveP384}, |
| 11077 | Bugs: ProtocolBugs{ |
| 11078 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 11079 | ExpectMissingKeyShare: true, |
| 11080 | }, |
| 11081 | }, |
| 11082 | }) |
| 11083 | |
| 11084 | testCases = append(testCases, testCase{ |
| 11085 | name: "HelloRetryRequest-Unknown", |
| 11086 | config: Config{ |
| 11087 | MaxVersion: VersionTLS13, |
| 11088 | Bugs: ProtocolBugs{ |
| 11089 | CustomHelloRetryRequestExtension: "extension", |
| 11090 | }, |
| 11091 | }, |
| 11092 | shouldFail: true, |
| 11093 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11094 | expectedLocalError: "remote error: unsupported extension", |
| 11095 | }) |
| 11096 | |
| 11097 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 11098 | testType: serverTest, |
| 11099 | name: "SecondClientHelloMissingKeyShare", |
| 11100 | config: Config{ |
| 11101 | MaxVersion: VersionTLS13, |
| 11102 | DefaultCurves: []CurveID{}, |
| 11103 | Bugs: ProtocolBugs{ |
| 11104 | SecondClientHelloMissingKeyShare: true, |
| 11105 | }, |
| 11106 | }, |
| 11107 | shouldFail: true, |
| 11108 | expectedError: ":MISSING_KEY_SHARE:", |
| 11109 | }) |
| 11110 | |
| 11111 | testCases = append(testCases, testCase{ |
| 11112 | testType: serverTest, |
| 11113 | name: "SecondClientHelloWrongCurve", |
| 11114 | config: Config{ |
| 11115 | MaxVersion: VersionTLS13, |
| 11116 | DefaultCurves: []CurveID{}, |
| 11117 | Bugs: ProtocolBugs{ |
| 11118 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 11119 | }, |
| 11120 | }, |
| 11121 | shouldFail: true, |
| 11122 | expectedError: ":WRONG_CURVE:", |
| 11123 | }) |
| 11124 | |
| 11125 | testCases = append(testCases, testCase{ |
| 11126 | name: "HelloRetryRequestVersionMismatch", |
| 11127 | config: Config{ |
| 11128 | MaxVersion: VersionTLS13, |
| 11129 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11130 | CurvePreferences: []CurveID{CurveP384}, |
| 11131 | Bugs: ProtocolBugs{ |
| 11132 | SendServerHelloVersion: 0x0305, |
| 11133 | }, |
| 11134 | }, |
| 11135 | shouldFail: true, |
| 11136 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11137 | }) |
| 11138 | |
| 11139 | testCases = append(testCases, testCase{ |
| 11140 | name: "HelloRetryRequestCurveMismatch", |
| 11141 | config: Config{ |
| 11142 | MaxVersion: VersionTLS13, |
| 11143 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11144 | CurvePreferences: []CurveID{CurveP384}, |
| 11145 | Bugs: ProtocolBugs{ |
| 11146 | // Send P-384 (correct) in the HelloRetryRequest. |
| 11147 | SendHelloRetryRequestCurve: CurveP384, |
| 11148 | // But send P-256 in the ServerHello. |
| 11149 | SendCurve: CurveP256, |
| 11150 | }, |
| 11151 | }, |
| 11152 | shouldFail: true, |
| 11153 | expectedError: ":WRONG_CURVE:", |
| 11154 | }) |
| 11155 | |
| 11156 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 11157 | // without sending it. |
| 11158 | testCases = append(testCases, testCase{ |
| 11159 | name: "SkipHelloRetryRequest", |
| 11160 | config: Config{ |
| 11161 | MaxVersion: VersionTLS13, |
| 11162 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11163 | CurvePreferences: []CurveID{CurveP384}, |
| 11164 | Bugs: ProtocolBugs{ |
| 11165 | SkipHelloRetryRequest: true, |
| 11166 | }, |
| 11167 | }, |
| 11168 | shouldFail: true, |
| 11169 | expectedError: ":WRONG_CURVE:", |
| 11170 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 11171 | |
| 11172 | testCases = append(testCases, testCase{ |
| 11173 | name: "TLS13-RequestContextInHandshake", |
| 11174 | config: Config{ |
| 11175 | MaxVersion: VersionTLS13, |
| 11176 | MinVersion: VersionTLS13, |
| 11177 | ClientAuth: RequireAnyClientCert, |
| 11178 | Bugs: ProtocolBugs{ |
| 11179 | SendRequestContext: []byte("request context"), |
| 11180 | }, |
| 11181 | }, |
| 11182 | flags: []string{ |
| 11183 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11184 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 11185 | }, |
| 11186 | shouldFail: true, |
| 11187 | expectedError: ":DECODE_ERROR:", |
| 11188 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 11189 | |
| 11190 | testCases = append(testCases, testCase{ |
| 11191 | testType: serverTest, |
| 11192 | name: "TLS13-TrailingKeyShareData", |
| 11193 | config: Config{ |
| 11194 | MaxVersion: VersionTLS13, |
| 11195 | Bugs: ProtocolBugs{ |
| 11196 | TrailingKeyShareData: true, |
| 11197 | }, |
| 11198 | }, |
| 11199 | shouldFail: true, |
| 11200 | expectedError: ":DECODE_ERROR:", |
| 11201 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 11202 | |
| 11203 | testCases = append(testCases, testCase{ |
| 11204 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 11205 | config: Config{ |
| 11206 | MaxVersion: VersionTLS13, |
| 11207 | Bugs: ProtocolBugs{ |
| 11208 | AlwaysSelectPSKIdentity: true, |
| 11209 | }, |
| 11210 | }, |
| 11211 | shouldFail: true, |
| 11212 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11213 | }) |
| 11214 | |
| 11215 | testCases = append(testCases, testCase{ |
| 11216 | name: "TLS13-InvalidPSKIdentity", |
| 11217 | config: Config{ |
| 11218 | MaxVersion: VersionTLS13, |
| 11219 | Bugs: ProtocolBugs{ |
| 11220 | SelectPSKIdentityOnResume: 1, |
| 11221 | }, |
| 11222 | }, |
| 11223 | resumeSession: true, |
| 11224 | shouldFail: true, |
| 11225 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 11226 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11227 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11228 | testCases = append(testCases, testCase{ |
| 11229 | testType: serverTest, |
| 11230 | name: "TLS13-ExtraPSKIdentity", |
| 11231 | config: Config{ |
| 11232 | MaxVersion: VersionTLS13, |
| 11233 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11234 | ExtraPSKIdentity: true, |
| 11235 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11236 | }, |
| 11237 | }, |
| 11238 | resumeSession: true, |
| 11239 | }) |
| 11240 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11241 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11242 | testCases = append(testCases, testCase{ |
| 11243 | name: "TLS13-CustomTicketExtension", |
| 11244 | config: Config{ |
| 11245 | MaxVersion: VersionTLS13, |
| 11246 | Bugs: ProtocolBugs{ |
| 11247 | CustomTicketExtension: "1234", |
| 11248 | }, |
| 11249 | }, |
| 11250 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11251 | |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11252 | for _, noSessionID := range []bool{false, true} { |
| 11253 | prefix := "TLS13Experiment" |
| 11254 | variant := TLS13Experiment |
| 11255 | if noSessionID { |
| 11256 | prefix = "TLS13NoSessionIDExperiment" |
| 11257 | variant = TLS13NoSessionIDExperiment |
| 11258 | } |
| 11259 | |
| 11260 | // Test that enabling a TLS 1.3 variant does not interfere with |
| 11261 | // TLS 1.2 session ID resumption. |
| 11262 | testCases = append(testCases, testCase{ |
| 11263 | testType: clientTest, |
| 11264 | name: prefix + "-ResumeTLS12SessionID", |
| 11265 | config: Config{ |
| 11266 | MaxVersion: VersionTLS12, |
| 11267 | SessionTicketsDisabled: true, |
| 11268 | }, |
| 11269 | resumeSession: true, |
| 11270 | flags: []string{"-tls13-variant", strconv.Itoa(variant)}, |
| 11271 | }) |
| 11272 | |
| 11273 | // Test that the server correctly echoes back session IDs of |
| 11274 | // various lengths. |
| 11275 | testCases = append(testCases, testCase{ |
| 11276 | testType: serverTest, |
| 11277 | name: prefix + "-EmptySessionID", |
| 11278 | config: Config{ |
| 11279 | MaxVersion: VersionTLS13, |
| 11280 | Bugs: ProtocolBugs{ |
| 11281 | SendClientHelloSessionID: []byte{}, |
| 11282 | }, |
| 11283 | }, |
| 11284 | tls13Variant: variant, |
| 11285 | }) |
| 11286 | |
| 11287 | testCases = append(testCases, testCase{ |
| 11288 | testType: serverTest, |
| 11289 | name: prefix + "-ShortSessionID", |
| 11290 | config: Config{ |
| 11291 | MaxVersion: VersionTLS13, |
| 11292 | Bugs: ProtocolBugs{ |
| 11293 | SendClientHelloSessionID: make([]byte, 16), |
| 11294 | }, |
| 11295 | }, |
| 11296 | tls13Variant: variant, |
| 11297 | }) |
| 11298 | |
| 11299 | testCases = append(testCases, testCase{ |
| 11300 | testType: serverTest, |
| 11301 | name: prefix + "-FullSessionID", |
| 11302 | config: Config{ |
| 11303 | MaxVersion: VersionTLS13, |
| 11304 | Bugs: ProtocolBugs{ |
| 11305 | SendClientHelloSessionID: make([]byte, 32), |
| 11306 | }, |
| 11307 | }, |
| 11308 | tls13Variant: variant, |
| 11309 | }) |
| 11310 | } |
| 11311 | |
| 11312 | // Test that the client sends a fake session ID in TLS13Experiment. |
| 11313 | testCases = append(testCases, testCase{ |
| 11314 | testType: clientTest, |
| 11315 | name: "TLS13Experiment-RequireSessionID", |
| 11316 | config: Config{ |
| 11317 | MaxVersion: VersionTLS13, |
| 11318 | Bugs: ProtocolBugs{ |
| 11319 | ExpectClientHelloSessionID: true, |
| 11320 | }, |
| 11321 | }, |
| 11322 | tls13Variant: TLS13Experiment, |
| 11323 | }) |
| 11324 | |
| 11325 | // Test that the client does not send a fake session ID in |
| 11326 | // TLS13NoSessionIDExperiment. |
| 11327 | testCases = append(testCases, testCase{ |
| 11328 | testType: clientTest, |
| 11329 | name: "TLS13NoSessionIDExperiment-RequireEmptySessionID", |
| 11330 | config: Config{ |
| 11331 | MaxVersion: VersionTLS13, |
| 11332 | Bugs: ProtocolBugs{ |
| 11333 | ExpectEmptyClientHelloSessionID: true, |
| 11334 | }, |
| 11335 | }, |
| 11336 | tls13Variant: TLS13NoSessionIDExperiment, |
| 11337 | }) |
| 11338 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11339 | testCases = append(testCases, testCase{ |
| 11340 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11341 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11342 | config: Config{ |
| 11343 | MaxVersion: VersionTLS13, |
| 11344 | MaxEarlyDataSize: 16384, |
| 11345 | }, |
| 11346 | resumeConfig: &Config{ |
| 11347 | MaxVersion: VersionTLS13, |
| 11348 | MaxEarlyDataSize: 16384, |
| 11349 | Bugs: ProtocolBugs{ |
| 11350 | AlwaysRejectEarlyData: true, |
| 11351 | }, |
| 11352 | }, |
| 11353 | resumeSession: true, |
| 11354 | flags: []string{ |
| 11355 | "-enable-early-data", |
| 11356 | "-expect-early-data-info", |
| 11357 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11358 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11359 | }, |
| 11360 | }) |
| 11361 | |
| 11362 | testCases = append(testCases, testCase{ |
| 11363 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11364 | name: "TLS13Experiment-EarlyData-Reject-Client", |
| 11365 | config: Config{ |
| 11366 | MaxVersion: VersionTLS13, |
| 11367 | MaxEarlyDataSize: 16384, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11368 | }, |
| 11369 | resumeConfig: &Config{ |
| 11370 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11371 | MaxEarlyDataSize: 16384, |
| 11372 | Bugs: ProtocolBugs{ |
| 11373 | AlwaysRejectEarlyData: true, |
| 11374 | }, |
| 11375 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11376 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11377 | resumeSession: true, |
| 11378 | flags: []string{ |
| 11379 | "-enable-early-data", |
| 11380 | "-expect-early-data-info", |
| 11381 | "-expect-reject-early-data", |
| 11382 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11383 | }, |
| 11384 | }) |
| 11385 | |
| 11386 | testCases = append(testCases, testCase{ |
| 11387 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11388 | name: "TLS13RecordTypeExperiment-EarlyData-Reject-Client", |
| 11389 | config: Config{ |
| 11390 | MaxVersion: VersionTLS13, |
| 11391 | MaxEarlyDataSize: 16384, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11392 | }, |
| 11393 | resumeConfig: &Config{ |
| 11394 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11395 | MaxEarlyDataSize: 16384, |
| 11396 | Bugs: ProtocolBugs{ |
| 11397 | AlwaysRejectEarlyData: true, |
| 11398 | }, |
| 11399 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11400 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11401 | resumeSession: true, |
| 11402 | flags: []string{ |
| 11403 | "-enable-early-data", |
| 11404 | "-expect-early-data-info", |
| 11405 | "-expect-reject-early-data", |
| 11406 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11407 | }, |
| 11408 | }) |
| 11409 | |
| 11410 | testCases = append(testCases, testCase{ |
| 11411 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11412 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11413 | config: Config{ |
| 11414 | MaxVersion: VersionTLS13, |
| 11415 | MaxEarlyDataSize: 16384, |
| 11416 | Certificates: []Certificate{rsaCertificate}, |
| 11417 | }, |
| 11418 | resumeConfig: &Config{ |
| 11419 | MaxVersion: VersionTLS13, |
| 11420 | MaxEarlyDataSize: 16384, |
| 11421 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11422 | SessionTicketsDisabled: true, |
| 11423 | }, |
| 11424 | resumeSession: true, |
| 11425 | expectResumeRejected: true, |
| 11426 | flags: []string{ |
| 11427 | "-enable-early-data", |
| 11428 | "-expect-early-data-info", |
| 11429 | "-expect-reject-early-data", |
| 11430 | "-on-resume-shim-writes-first", |
| 11431 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11432 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11433 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11434 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11435 | "-on-retry-expect-no-session", |
| 11436 | }, |
| 11437 | }) |
| 11438 | |
| 11439 | testCases = append(testCases, testCase{ |
| 11440 | testType: clientTest, |
| 11441 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11442 | config: Config{ |
| 11443 | MaxVersion: VersionTLS13, |
| 11444 | MaxEarlyDataSize: 16384, |
| 11445 | }, |
| 11446 | resumeConfig: &Config{ |
| 11447 | MaxVersion: VersionTLS13, |
| 11448 | MaxEarlyDataSize: 16384, |
| 11449 | Bugs: ProtocolBugs{ |
| 11450 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11451 | }, |
| 11452 | }, |
| 11453 | resumeSession: true, |
| 11454 | flags: []string{ |
| 11455 | "-enable-early-data", |
| 11456 | "-expect-early-data-info", |
| 11457 | "-expect-reject-early-data", |
| 11458 | }, |
| 11459 | }) |
| 11460 | |
| 11461 | // The client must check the server does not send the early_data |
| 11462 | // extension while rejecting the session. |
| 11463 | testCases = append(testCases, testCase{ |
| 11464 | testType: clientTest, |
| 11465 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11466 | config: Config{ |
| 11467 | MaxVersion: VersionTLS13, |
| 11468 | MaxEarlyDataSize: 16384, |
| 11469 | }, |
| 11470 | resumeConfig: &Config{ |
| 11471 | MaxVersion: VersionTLS13, |
| 11472 | SessionTicketsDisabled: true, |
| 11473 | Bugs: ProtocolBugs{ |
| 11474 | SendEarlyDataExtension: true, |
| 11475 | }, |
| 11476 | }, |
| 11477 | resumeSession: true, |
| 11478 | flags: []string{ |
| 11479 | "-enable-early-data", |
| 11480 | "-expect-early-data-info", |
| 11481 | }, |
| 11482 | shouldFail: true, |
| 11483 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11484 | }) |
| 11485 | |
| 11486 | // The client must fail with a dedicated error code if the server |
| 11487 | // responds with TLS 1.2 when offering 0-RTT. |
| 11488 | testCases = append(testCases, testCase{ |
| 11489 | testType: clientTest, |
| 11490 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11491 | config: Config{ |
| 11492 | MaxVersion: VersionTLS13, |
| 11493 | MaxEarlyDataSize: 16384, |
| 11494 | }, |
| 11495 | resumeConfig: &Config{ |
| 11496 | MaxVersion: VersionTLS12, |
| 11497 | }, |
| 11498 | resumeSession: true, |
| 11499 | flags: []string{ |
| 11500 | "-enable-early-data", |
| 11501 | "-expect-early-data-info", |
| 11502 | }, |
| 11503 | shouldFail: true, |
| 11504 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11505 | }) |
| 11506 | |
| 11507 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11508 | // the server sent an HRR. |
| 11509 | testCases = append(testCases, testCase{ |
| 11510 | testType: clientTest, |
| 11511 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11512 | config: Config{ |
| 11513 | MaxVersion: VersionTLS13, |
| 11514 | MaxEarlyDataSize: 16384, |
| 11515 | }, |
| 11516 | resumeConfig: &Config{ |
| 11517 | MaxVersion: VersionTLS13, |
| 11518 | MaxEarlyDataSize: 16384, |
| 11519 | Bugs: ProtocolBugs{ |
| 11520 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11521 | SendEarlyDataExtension: true, |
| 11522 | }, |
| 11523 | }, |
| 11524 | resumeSession: true, |
| 11525 | flags: []string{ |
| 11526 | "-enable-early-data", |
| 11527 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11528 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11529 | }, |
| 11530 | shouldFail: true, |
| 11531 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11532 | }) |
| 11533 | |
| 11534 | fooString := "foo" |
| 11535 | barString := "bar" |
| 11536 | |
| 11537 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11538 | // that changed it. |
| 11539 | testCases = append(testCases, testCase{ |
| 11540 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11541 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11542 | config: Config{ |
| 11543 | MaxVersion: VersionTLS13, |
| 11544 | MaxEarlyDataSize: 16384, |
| 11545 | Bugs: ProtocolBugs{ |
| 11546 | ALPNProtocol: &fooString, |
| 11547 | }, |
| 11548 | }, |
| 11549 | resumeConfig: &Config{ |
| 11550 | MaxVersion: VersionTLS13, |
| 11551 | MaxEarlyDataSize: 16384, |
| 11552 | Bugs: ProtocolBugs{ |
| 11553 | ALPNProtocol: &barString, |
| 11554 | }, |
| 11555 | }, |
| 11556 | resumeSession: true, |
| 11557 | flags: []string{ |
| 11558 | "-advertise-alpn", "\x03foo\x03bar", |
| 11559 | "-enable-early-data", |
| 11560 | "-expect-early-data-info", |
| 11561 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11562 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11563 | "-on-resume-expect-alpn", "foo", |
| 11564 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11565 | }, |
| 11566 | }) |
| 11567 | |
| 11568 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11569 | // ALPN was omitted from the first connection. |
| 11570 | testCases = append(testCases, testCase{ |
| 11571 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11572 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11573 | config: Config{ |
| 11574 | MaxVersion: VersionTLS13, |
| 11575 | MaxEarlyDataSize: 16384, |
| 11576 | }, |
| 11577 | resumeConfig: &Config{ |
| 11578 | MaxVersion: VersionTLS13, |
| 11579 | MaxEarlyDataSize: 16384, |
| 11580 | NextProtos: []string{"foo"}, |
| 11581 | }, |
| 11582 | resumeSession: true, |
| 11583 | flags: []string{ |
| 11584 | "-advertise-alpn", "\x03foo\x03bar", |
| 11585 | "-enable-early-data", |
| 11586 | "-expect-early-data-info", |
| 11587 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11588 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11589 | "-on-resume-expect-alpn", "", |
| 11590 | "-on-retry-expect-alpn", "foo", |
| 11591 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11592 | }, |
| 11593 | }) |
| 11594 | |
| 11595 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11596 | // ALPN was omitted from the second connection. |
| 11597 | testCases = append(testCases, testCase{ |
| 11598 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11599 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11600 | config: Config{ |
| 11601 | MaxVersion: VersionTLS13, |
| 11602 | MaxEarlyDataSize: 16384, |
| 11603 | NextProtos: []string{"foo"}, |
| 11604 | }, |
| 11605 | resumeConfig: &Config{ |
| 11606 | MaxVersion: VersionTLS13, |
| 11607 | MaxEarlyDataSize: 16384, |
| 11608 | }, |
| 11609 | resumeSession: true, |
| 11610 | flags: []string{ |
| 11611 | "-advertise-alpn", "\x03foo\x03bar", |
| 11612 | "-enable-early-data", |
| 11613 | "-expect-early-data-info", |
| 11614 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11615 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11616 | "-on-resume-expect-alpn", "foo", |
| 11617 | "-on-retry-expect-alpn", "", |
| 11618 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11619 | }, |
| 11620 | }) |
| 11621 | |
| 11622 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11623 | testCases = append(testCases, testCase{ |
| 11624 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11625 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11626 | config: Config{ |
| 11627 | MaxVersion: VersionTLS13, |
| 11628 | MaxEarlyDataSize: 16384, |
| 11629 | Bugs: ProtocolBugs{ |
| 11630 | ALPNProtocol: &fooString, |
| 11631 | }, |
| 11632 | }, |
| 11633 | resumeConfig: &Config{ |
| 11634 | MaxVersion: VersionTLS13, |
| 11635 | MaxEarlyDataSize: 16384, |
| 11636 | Bugs: ProtocolBugs{ |
| 11637 | AlwaysAcceptEarlyData: true, |
| 11638 | ALPNProtocol: &barString, |
| 11639 | }, |
| 11640 | }, |
| 11641 | resumeSession: true, |
| 11642 | flags: []string{ |
| 11643 | "-advertise-alpn", "\x03foo\x03bar", |
| 11644 | "-enable-early-data", |
| 11645 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11646 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11647 | "-on-resume-expect-alpn", "foo", |
| 11648 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11649 | }, |
| 11650 | shouldFail: true, |
| 11651 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11652 | }) |
| 11653 | |
| 11654 | // Test that the server correctly rejects 0-RTT when the previous |
| 11655 | // session did not allow early data on resumption. |
| 11656 | testCases = append(testCases, testCase{ |
| 11657 | testType: serverTest, |
| 11658 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11659 | config: Config{ |
| 11660 | MaxVersion: VersionTLS13, |
| 11661 | }, |
| 11662 | resumeConfig: &Config{ |
| 11663 | MaxVersion: VersionTLS13, |
| 11664 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11665 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11666 | ExpectEarlyDataAccepted: false, |
| 11667 | }, |
| 11668 | }, |
| 11669 | resumeSession: true, |
| 11670 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11671 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11672 | "-expect-reject-early-data", |
| 11673 | }, |
| 11674 | }) |
| 11675 | |
| 11676 | // Test that we reject early data where ALPN is omitted from the first |
| 11677 | // connection. |
| 11678 | testCases = append(testCases, testCase{ |
| 11679 | testType: serverTest, |
| 11680 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11681 | config: Config{ |
| 11682 | MaxVersion: VersionTLS13, |
| 11683 | NextProtos: []string{}, |
| 11684 | }, |
| 11685 | resumeConfig: &Config{ |
| 11686 | MaxVersion: VersionTLS13, |
| 11687 | NextProtos: []string{"foo"}, |
| 11688 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11689 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11690 | ExpectEarlyDataAccepted: false, |
| 11691 | }, |
| 11692 | }, |
| 11693 | resumeSession: true, |
| 11694 | flags: []string{ |
| 11695 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11696 | "-on-initial-select-alpn", "", |
| 11697 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11698 | }, |
| 11699 | }) |
| 11700 | |
| 11701 | // Test that we reject early data where ALPN is omitted from the second |
| 11702 | // connection. |
| 11703 | testCases = append(testCases, testCase{ |
| 11704 | testType: serverTest, |
| 11705 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11706 | config: Config{ |
| 11707 | MaxVersion: VersionTLS13, |
| 11708 | NextProtos: []string{"foo"}, |
| 11709 | }, |
| 11710 | resumeConfig: &Config{ |
| 11711 | MaxVersion: VersionTLS13, |
| 11712 | NextProtos: []string{}, |
| 11713 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11714 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11715 | ExpectEarlyDataAccepted: false, |
| 11716 | }, |
| 11717 | }, |
| 11718 | resumeSession: true, |
| 11719 | flags: []string{ |
| 11720 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11721 | "-on-initial-select-alpn", "foo", |
| 11722 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11723 | }, |
| 11724 | }) |
| 11725 | |
| 11726 | // Test that we reject early data with mismatched ALPN. |
| 11727 | testCases = append(testCases, testCase{ |
| 11728 | testType: serverTest, |
| 11729 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11730 | config: Config{ |
| 11731 | MaxVersion: VersionTLS13, |
| 11732 | NextProtos: []string{"foo"}, |
| 11733 | }, |
| 11734 | resumeConfig: &Config{ |
| 11735 | MaxVersion: VersionTLS13, |
| 11736 | NextProtos: []string{"bar"}, |
| 11737 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11738 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11739 | ExpectEarlyDataAccepted: false, |
| 11740 | }, |
| 11741 | }, |
| 11742 | resumeSession: true, |
| 11743 | flags: []string{ |
| 11744 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11745 | "-on-initial-select-alpn", "foo", |
| 11746 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11747 | }, |
| 11748 | }) |
| 11749 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11750 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11751 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11752 | testCases = append(testCases, testCase{ |
| 11753 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11754 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11755 | config: Config{ |
| 11756 | MaxVersion: VersionTLS13, |
| 11757 | MaxEarlyDataSize: 16384, |
| 11758 | RequestChannelID: true, |
| 11759 | }, |
| 11760 | resumeSession: true, |
| 11761 | expectChannelID: true, |
| 11762 | shouldFail: true, |
Steven Valdez | f4ecc84 | 2017-08-10 14:02:56 -0400 | [diff] [blame^] | 11763 | expectedError: ":UNEXPECTED_EXTENSION_ON_EARLY_DATA:", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11764 | flags: []string{ |
| 11765 | "-enable-early-data", |
| 11766 | "-expect-early-data-info", |
| 11767 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11768 | }, |
| 11769 | }) |
| 11770 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11771 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11772 | // to decline 0-RTT. |
| 11773 | testCases = append(testCases, testCase{ |
| 11774 | testType: clientTest, |
| 11775 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11776 | config: Config{ |
| 11777 | MaxVersion: VersionTLS13, |
| 11778 | MaxEarlyDataSize: 16384, |
| 11779 | RequestChannelID: true, |
| 11780 | Bugs: ProtocolBugs{ |
| 11781 | AlwaysRejectEarlyData: true, |
| 11782 | }, |
| 11783 | }, |
| 11784 | resumeSession: true, |
| 11785 | expectChannelID: true, |
| 11786 | flags: []string{ |
| 11787 | "-enable-early-data", |
| 11788 | "-expect-early-data-info", |
| 11789 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11790 | "-expect-reject-early-data", |
| 11791 | }, |
| 11792 | }) |
| 11793 | |
| 11794 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11795 | // to decline Channel ID. |
| 11796 | testCases = append(testCases, testCase{ |
| 11797 | testType: clientTest, |
| 11798 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11799 | config: Config{ |
| 11800 | MaxVersion: VersionTLS13, |
| 11801 | MaxEarlyDataSize: 16384, |
| 11802 | }, |
| 11803 | resumeSession: true, |
| 11804 | flags: []string{ |
| 11805 | "-enable-early-data", |
| 11806 | "-expect-early-data-info", |
| 11807 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11808 | "-expect-accept-early-data", |
| 11809 | }, |
| 11810 | }) |
| 11811 | |
| 11812 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11813 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11814 | testCases = append(testCases, testCase{ |
| 11815 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11816 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11817 | config: Config{ |
| 11818 | MaxVersion: VersionTLS13, |
| 11819 | ChannelID: channelIDKey, |
| 11820 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11821 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11822 | ExpectEarlyDataAccepted: false, |
| 11823 | }, |
| 11824 | }, |
| 11825 | resumeSession: true, |
| 11826 | expectChannelID: true, |
| 11827 | flags: []string{ |
| 11828 | "-enable-early-data", |
| 11829 | "-expect-reject-early-data", |
| 11830 | "-expect-channel-id", |
| 11831 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11832 | }, |
| 11833 | }) |
| 11834 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11835 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11836 | // if not offered Channel ID. |
| 11837 | testCases = append(testCases, testCase{ |
| 11838 | testType: serverTest, |
| 11839 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11840 | config: Config{ |
| 11841 | MaxVersion: VersionTLS13, |
| 11842 | Bugs: ProtocolBugs{ |
| 11843 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11844 | ExpectEarlyDataAccepted: true, |
| 11845 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11846 | }, |
| 11847 | }, |
| 11848 | resumeSession: true, |
| 11849 | expectChannelID: false, |
| 11850 | flags: []string{ |
| 11851 | "-enable-early-data", |
| 11852 | "-expect-accept-early-data", |
| 11853 | "-enable-channel-id", |
| 11854 | }, |
| 11855 | }) |
| 11856 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11857 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11858 | // The subsequent records should fail to decrypt. |
| 11859 | testCases = append(testCases, testCase{ |
| 11860 | testType: serverTest, |
| 11861 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11862 | config: Config{ |
| 11863 | MaxVersion: VersionTLS13, |
| 11864 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11865 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11866 | ExpectEarlyDataAccepted: true, |
| 11867 | SkipEndOfEarlyData: true, |
| 11868 | }, |
| 11869 | }, |
| 11870 | resumeSession: true, |
| 11871 | flags: []string{"-enable-early-data"}, |
| 11872 | shouldFail: true, |
| 11873 | expectedLocalError: "remote error: bad record MAC", |
| 11874 | expectedError: ":BAD_DECRYPT:", |
| 11875 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11876 | |
| 11877 | testCases = append(testCases, testCase{ |
| 11878 | testType: serverTest, |
| 11879 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11880 | config: Config{ |
| 11881 | MaxVersion: VersionTLS13, |
| 11882 | }, |
| 11883 | resumeConfig: &Config{ |
| 11884 | MaxVersion: VersionTLS13, |
| 11885 | Bugs: ProtocolBugs{ |
| 11886 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11887 | SendStrayEarlyHandshake: true, |
David Benjamin | 4a37de0 | 2017-08-08 20:15:40 -0400 | [diff] [blame] | 11888 | ExpectEarlyDataAccepted: true, |
| 11889 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11890 | }, |
| 11891 | resumeSession: true, |
| 11892 | shouldFail: true, |
| 11893 | expectedError: ":UNEXPECTED_RECORD:", |
| 11894 | expectedLocalError: "remote error: unexpected message", |
| 11895 | flags: []string{ |
| 11896 | "-enable-early-data", |
| 11897 | }, |
| 11898 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11899 | |
| 11900 | // Test that the client reports TLS 1.3 as the version while sending |
| 11901 | // early data. |
| 11902 | testCases = append(testCases, testCase{ |
| 11903 | testType: clientTest, |
| 11904 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11905 | config: Config{ |
| 11906 | MaxVersion: VersionTLS13, |
| 11907 | MaxEarlyDataSize: 16384, |
| 11908 | }, |
| 11909 | resumeSession: true, |
| 11910 | flags: []string{ |
| 11911 | "-enable-early-data", |
| 11912 | "-expect-early-data-info", |
| 11913 | "-expect-accept-early-data", |
| 11914 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11915 | }, |
| 11916 | }) |
David Benjamin | 4a37de0 | 2017-08-08 20:15:40 -0400 | [diff] [blame] | 11917 | |
| 11918 | // Test that client and server both notice handshake errors after data |
| 11919 | // has started flowing. |
| 11920 | testCases = append(testCases, testCase{ |
| 11921 | testType: clientTest, |
| 11922 | name: "TLS13-EarlyData-Client-BadFinished", |
| 11923 | config: Config{ |
| 11924 | MaxVersion: VersionTLS13, |
| 11925 | MaxEarlyDataSize: 16384, |
| 11926 | }, |
| 11927 | resumeConfig: &Config{ |
| 11928 | MaxVersion: VersionTLS13, |
| 11929 | MaxEarlyDataSize: 16384, |
| 11930 | Bugs: ProtocolBugs{ |
| 11931 | BadFinished: true, |
| 11932 | }, |
| 11933 | }, |
| 11934 | resumeSession: true, |
| 11935 | flags: []string{ |
| 11936 | "-enable-early-data", |
| 11937 | "-expect-early-data-info", |
| 11938 | "-expect-accept-early-data", |
| 11939 | }, |
| 11940 | shouldFail: true, |
| 11941 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 11942 | expectedLocalError: "remote error: error decrypting message", |
| 11943 | }) |
| 11944 | testCases = append(testCases, testCase{ |
| 11945 | testType: serverTest, |
| 11946 | name: "TLS13-EarlyData-Server-BadFinished", |
| 11947 | config: Config{ |
| 11948 | MaxVersion: VersionTLS13, |
| 11949 | MaxEarlyDataSize: 16384, |
| 11950 | }, |
| 11951 | resumeConfig: &Config{ |
| 11952 | MaxVersion: VersionTLS13, |
| 11953 | MaxEarlyDataSize: 16384, |
| 11954 | Bugs: ProtocolBugs{ |
| 11955 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11956 | ExpectEarlyDataAccepted: true, |
| 11957 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11958 | BadFinished: true, |
| 11959 | }, |
| 11960 | }, |
| 11961 | resumeSession: true, |
| 11962 | flags: []string{ |
| 11963 | "-enable-early-data", |
| 11964 | "-expect-accept-early-data", |
| 11965 | }, |
| 11966 | shouldFail: true, |
| 11967 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 11968 | expectedLocalError: "remote error: error decrypting message", |
| 11969 | }) |
Dimitar Vlahovski | bd70845 | 2017-08-10 18:01:06 +0200 | [diff] [blame] | 11970 | testCases = append(testCases, testCase{ |
| 11971 | testType: serverTest, |
| 11972 | name: "TLS13-ServerSkipCertificateVerify", |
| 11973 | config: Config{ |
| 11974 | MinVersion: VersionTLS13, |
| 11975 | MaxVersion: VersionTLS13, |
| 11976 | Certificates: []Certificate{rsaChainCertificate}, |
| 11977 | Bugs: ProtocolBugs{ |
| 11978 | SkipCertificateVerify: true, |
| 11979 | }, |
| 11980 | }, |
| 11981 | expectPeerCertificate: &rsaChainCertificate, |
| 11982 | flags: []string{ |
| 11983 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11984 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11985 | "-require-any-client-certificate", |
| 11986 | }, |
| 11987 | shouldFail: true, |
| 11988 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 11989 | expectedLocalError: "remote error: unexpected message", |
| 11990 | }) |
| 11991 | testCases = append(testCases, testCase{ |
| 11992 | testType: clientTest, |
| 11993 | name: "TLS13-ClientSkipCertificateVerify", |
| 11994 | config: Config{ |
| 11995 | MinVersion: VersionTLS13, |
| 11996 | MaxVersion: VersionTLS13, |
| 11997 | Certificates: []Certificate{rsaChainCertificate}, |
| 11998 | Bugs: ProtocolBugs{ |
| 11999 | SkipCertificateVerify: true, |
| 12000 | }, |
| 12001 | }, |
| 12002 | expectPeerCertificate: &rsaChainCertificate, |
| 12003 | flags: []string{ |
| 12004 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12005 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12006 | }, |
| 12007 | shouldFail: true, |
| 12008 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 12009 | expectedLocalError: "remote error: unexpected message", |
| 12010 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12011 | } |
| 12012 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12013 | func addTLS13CipherPreferenceTests() { |
| 12014 | // Test that client preference is honored if the shim has AES hardware |
| 12015 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 12016 | testCases = append(testCases, testCase{ |
| 12017 | testType: serverTest, |
| 12018 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 12019 | config: Config{ |
| 12020 | MaxVersion: VersionTLS13, |
| 12021 | CipherSuites: []uint16{ |
| 12022 | TLS_CHACHA20_POLY1305_SHA256, |
| 12023 | TLS_AES_128_GCM_SHA256, |
| 12024 | }, |
| 12025 | }, |
| 12026 | flags: []string{ |
| 12027 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 12028 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 12029 | }, |
| 12030 | }) |
| 12031 | |
| 12032 | testCases = append(testCases, testCase{ |
| 12033 | testType: serverTest, |
| 12034 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 12035 | config: Config{ |
| 12036 | MaxVersion: VersionTLS13, |
| 12037 | CipherSuites: []uint16{ |
| 12038 | TLS_AES_128_GCM_SHA256, |
| 12039 | TLS_CHACHA20_POLY1305_SHA256, |
| 12040 | }, |
| 12041 | }, |
| 12042 | flags: []string{ |
| 12043 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 12044 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 12045 | }, |
| 12046 | }) |
| 12047 | |
| 12048 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 12049 | // whether it has AES hardware. |
| 12050 | testCases = append(testCases, testCase{ |
| 12051 | name: "TLS13-CipherPreference-Client", |
| 12052 | config: Config{ |
| 12053 | MaxVersion: VersionTLS13, |
| 12054 | // Use the client cipher order. (This is the default but |
| 12055 | // is listed to be explicit.) |
| 12056 | PreferServerCipherSuites: false, |
| 12057 | }, |
| 12058 | flags: []string{ |
| 12059 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 12060 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 12061 | }, |
| 12062 | }) |
| 12063 | } |
| 12064 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12065 | func addPeekTests() { |
| 12066 | // Test SSL_peek works, including on empty records. |
| 12067 | testCases = append(testCases, testCase{ |
| 12068 | name: "Peek-Basic", |
| 12069 | sendEmptyRecords: 1, |
| 12070 | flags: []string{"-peek-then-read"}, |
| 12071 | }) |
| 12072 | |
| 12073 | // Test SSL_peek can drive the initial handshake. |
| 12074 | testCases = append(testCases, testCase{ |
| 12075 | name: "Peek-ImplicitHandshake", |
| 12076 | flags: []string{ |
| 12077 | "-peek-then-read", |
| 12078 | "-implicit-handshake", |
| 12079 | }, |
| 12080 | }) |
| 12081 | |
| 12082 | // Test SSL_peek can discover and drive a renegotiation. |
| 12083 | testCases = append(testCases, testCase{ |
| 12084 | name: "Peek-Renegotiate", |
| 12085 | config: Config{ |
| 12086 | MaxVersion: VersionTLS12, |
| 12087 | }, |
| 12088 | renegotiate: 1, |
| 12089 | flags: []string{ |
| 12090 | "-peek-then-read", |
| 12091 | "-renegotiate-freely", |
| 12092 | "-expect-total-renegotiations", "1", |
| 12093 | }, |
| 12094 | }) |
| 12095 | |
| 12096 | // Test SSL_peek can discover a close_notify. |
| 12097 | testCases = append(testCases, testCase{ |
| 12098 | name: "Peek-Shutdown", |
| 12099 | config: Config{ |
| 12100 | Bugs: ProtocolBugs{ |
| 12101 | ExpectCloseNotify: true, |
| 12102 | }, |
| 12103 | }, |
| 12104 | flags: []string{ |
| 12105 | "-peek-then-read", |
| 12106 | "-check-close-notify", |
| 12107 | }, |
| 12108 | }) |
| 12109 | |
| 12110 | // Test SSL_peek can discover an alert. |
| 12111 | testCases = append(testCases, testCase{ |
| 12112 | name: "Peek-Alert", |
| 12113 | config: Config{ |
| 12114 | Bugs: ProtocolBugs{ |
| 12115 | SendSpuriousAlert: alertRecordOverflow, |
| 12116 | }, |
| 12117 | }, |
| 12118 | flags: []string{"-peek-then-read"}, |
| 12119 | shouldFail: true, |
| 12120 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 12121 | }) |
| 12122 | |
| 12123 | // Test SSL_peek can handle KeyUpdate. |
| 12124 | testCases = append(testCases, testCase{ |
| 12125 | name: "Peek-KeyUpdate", |
| 12126 | config: Config{ |
| 12127 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12128 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 12129 | sendKeyUpdates: 1, |
| 12130 | keyUpdateRequest: keyUpdateNotRequested, |
| 12131 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12132 | }) |
| 12133 | } |
| 12134 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12135 | func addRecordVersionTests() { |
| 12136 | for _, ver := range tlsVersions { |
| 12137 | // Test that the record version is enforced. |
| 12138 | testCases = append(testCases, testCase{ |
| 12139 | name: "CheckRecordVersion-" + ver.name, |
| 12140 | config: Config{ |
| 12141 | MinVersion: ver.version, |
| 12142 | MaxVersion: ver.version, |
| 12143 | Bugs: ProtocolBugs{ |
| 12144 | SendRecordVersion: 0x03ff, |
| 12145 | }, |
| 12146 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12147 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12148 | shouldFail: true, |
| 12149 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 12150 | }) |
| 12151 | |
| 12152 | // Test that the ClientHello may use any record version, for |
| 12153 | // compatibility reasons. |
| 12154 | testCases = append(testCases, testCase{ |
| 12155 | testType: serverTest, |
| 12156 | name: "LooseInitialRecordVersion-" + ver.name, |
| 12157 | config: Config{ |
| 12158 | MinVersion: ver.version, |
| 12159 | MaxVersion: ver.version, |
| 12160 | Bugs: ProtocolBugs{ |
| 12161 | SendInitialRecordVersion: 0x03ff, |
| 12162 | }, |
| 12163 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12164 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12165 | }) |
| 12166 | |
| 12167 | // Test that garbage ClientHello record versions are rejected. |
| 12168 | testCases = append(testCases, testCase{ |
| 12169 | testType: serverTest, |
| 12170 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 12171 | config: Config{ |
| 12172 | MinVersion: ver.version, |
| 12173 | MaxVersion: ver.version, |
| 12174 | Bugs: ProtocolBugs{ |
| 12175 | SendInitialRecordVersion: 0xffff, |
| 12176 | }, |
| 12177 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12178 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12179 | shouldFail: true, |
| 12180 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 12181 | }) |
| 12182 | } |
| 12183 | } |
| 12184 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12185 | func addCertificateTests() { |
| 12186 | // Test that a certificate chain with intermediate may be sent and |
| 12187 | // received as both client and server. |
| 12188 | for _, ver := range tlsVersions { |
| 12189 | testCases = append(testCases, testCase{ |
| 12190 | testType: clientTest, |
| 12191 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 12192 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 12193 | MinVersion: ver.version, |
| 12194 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12195 | Certificates: []Certificate{rsaChainCertificate}, |
| 12196 | ClientAuth: RequireAnyClientCert, |
| 12197 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12198 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12199 | expectPeerCertificate: &rsaChainCertificate, |
| 12200 | flags: []string{ |
| 12201 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12202 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12203 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12204 | }, |
| 12205 | }) |
| 12206 | |
| 12207 | testCases = append(testCases, testCase{ |
| 12208 | testType: serverTest, |
| 12209 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 12210 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 12211 | MinVersion: ver.version, |
| 12212 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12213 | Certificates: []Certificate{rsaChainCertificate}, |
| 12214 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12215 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12216 | expectPeerCertificate: &rsaChainCertificate, |
| 12217 | flags: []string{ |
| 12218 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12219 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12220 | "-require-any-client-certificate", |
| 12221 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12222 | }, |
| 12223 | }) |
| 12224 | } |
| 12225 | } |
| 12226 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12227 | func addRetainOnlySHA256ClientCertTests() { |
| 12228 | for _, ver := range tlsVersions { |
| 12229 | // Test that enabling |
| 12230 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 12231 | // actually requesting a client certificate is a no-op. |
| 12232 | testCases = append(testCases, testCase{ |
| 12233 | testType: serverTest, |
| 12234 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 12235 | config: Config{ |
| 12236 | MinVersion: ver.version, |
| 12237 | MaxVersion: ver.version, |
| 12238 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12239 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12240 | flags: []string{ |
| 12241 | "-retain-only-sha256-client-cert-initial", |
| 12242 | "-retain-only-sha256-client-cert-resume", |
| 12243 | }, |
| 12244 | resumeSession: true, |
| 12245 | }) |
| 12246 | |
| 12247 | // Test that when retaining only a SHA-256 certificate is |
| 12248 | // enabled, the hash appears as expected. |
| 12249 | testCases = append(testCases, testCase{ |
| 12250 | testType: serverTest, |
| 12251 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 12252 | config: Config{ |
| 12253 | MinVersion: ver.version, |
| 12254 | MaxVersion: ver.version, |
| 12255 | Certificates: []Certificate{rsaCertificate}, |
| 12256 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12257 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12258 | flags: []string{ |
| 12259 | "-verify-peer", |
| 12260 | "-retain-only-sha256-client-cert-initial", |
| 12261 | "-retain-only-sha256-client-cert-resume", |
| 12262 | "-expect-sha256-client-cert-initial", |
| 12263 | "-expect-sha256-client-cert-resume", |
| 12264 | }, |
| 12265 | resumeSession: true, |
| 12266 | }) |
| 12267 | |
| 12268 | // Test that when the config changes from on to off, a |
| 12269 | // resumption is rejected because the server now wants the full |
| 12270 | // certificate chain. |
| 12271 | testCases = append(testCases, testCase{ |
| 12272 | testType: serverTest, |
| 12273 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 12274 | config: Config{ |
| 12275 | MinVersion: ver.version, |
| 12276 | MaxVersion: ver.version, |
| 12277 | Certificates: []Certificate{rsaCertificate}, |
| 12278 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12279 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12280 | flags: []string{ |
| 12281 | "-verify-peer", |
| 12282 | "-retain-only-sha256-client-cert-initial", |
| 12283 | "-expect-sha256-client-cert-initial", |
| 12284 | }, |
| 12285 | resumeSession: true, |
| 12286 | expectResumeRejected: true, |
| 12287 | }) |
| 12288 | |
| 12289 | // Test that when the config changes from off to on, a |
| 12290 | // resumption is rejected because the server now wants just the |
| 12291 | // hash. |
| 12292 | testCases = append(testCases, testCase{ |
| 12293 | testType: serverTest, |
| 12294 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 12295 | config: Config{ |
| 12296 | MinVersion: ver.version, |
| 12297 | MaxVersion: ver.version, |
| 12298 | Certificates: []Certificate{rsaCertificate}, |
| 12299 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12300 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12301 | flags: []string{ |
| 12302 | "-verify-peer", |
| 12303 | "-retain-only-sha256-client-cert-resume", |
| 12304 | "-expect-sha256-client-cert-resume", |
| 12305 | }, |
| 12306 | resumeSession: true, |
| 12307 | expectResumeRejected: true, |
| 12308 | }) |
| 12309 | } |
| 12310 | } |
| 12311 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12312 | func addECDSAKeyUsageTests() { |
| 12313 | p256 := elliptic.P256() |
| 12314 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 12315 | if err != nil { |
| 12316 | panic(err) |
| 12317 | } |
| 12318 | |
| 12319 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 12320 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 12321 | if err != nil { |
| 12322 | panic(err) |
| 12323 | } |
| 12324 | |
| 12325 | template := x509.Certificate{ |
| 12326 | SerialNumber: serialNumber, |
| 12327 | Subject: pkix.Name{ |
| 12328 | Organization: []string{"Acme Co"}, |
| 12329 | }, |
| 12330 | NotBefore: time.Now(), |
| 12331 | NotAfter: time.Now(), |
| 12332 | |
| 12333 | // An ECC certificate with only the keyAgreement key usgae may |
| 12334 | // be used with ECDH, but not ECDSA. |
| 12335 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 12336 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 12337 | BasicConstraintsValid: true, |
| 12338 | } |
| 12339 | |
| 12340 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 12341 | if err != nil { |
| 12342 | panic(err) |
| 12343 | } |
| 12344 | |
| 12345 | cert := Certificate{ |
| 12346 | Certificate: [][]byte{derBytes}, |
| 12347 | PrivateKey: priv, |
| 12348 | } |
| 12349 | |
| 12350 | for _, ver := range tlsVersions { |
| 12351 | if ver.version < VersionTLS12 { |
| 12352 | continue |
| 12353 | } |
| 12354 | |
| 12355 | testCases = append(testCases, testCase{ |
| 12356 | testType: clientTest, |
| 12357 | name: "ECDSAKeyUsage-" + ver.name, |
| 12358 | config: Config{ |
| 12359 | MinVersion: ver.version, |
| 12360 | MaxVersion: ver.version, |
| 12361 | Certificates: []Certificate{cert}, |
| 12362 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12363 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12364 | shouldFail: true, |
| 12365 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 12366 | }) |
| 12367 | } |
| 12368 | } |
| 12369 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12370 | func addExtraHandshakeTests() { |
| 12371 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 12372 | // to ensure there is no transport I/O. |
| 12373 | testCases = append(testCases, testCase{ |
| 12374 | testType: clientTest, |
| 12375 | name: "ExtraHandshake-Client-TLS12", |
| 12376 | config: Config{ |
| 12377 | MinVersion: VersionTLS12, |
| 12378 | MaxVersion: VersionTLS12, |
| 12379 | }, |
| 12380 | flags: []string{ |
| 12381 | "-async", |
| 12382 | "-no-op-extra-handshake", |
| 12383 | }, |
| 12384 | }) |
| 12385 | testCases = append(testCases, testCase{ |
| 12386 | testType: serverTest, |
| 12387 | name: "ExtraHandshake-Server-TLS12", |
| 12388 | config: Config{ |
| 12389 | MinVersion: VersionTLS12, |
| 12390 | MaxVersion: VersionTLS12, |
| 12391 | }, |
| 12392 | flags: []string{ |
| 12393 | "-async", |
| 12394 | "-no-op-extra-handshake", |
| 12395 | }, |
| 12396 | }) |
| 12397 | testCases = append(testCases, testCase{ |
| 12398 | testType: clientTest, |
| 12399 | name: "ExtraHandshake-Client-TLS13", |
| 12400 | config: Config{ |
| 12401 | MinVersion: VersionTLS13, |
| 12402 | MaxVersion: VersionTLS13, |
| 12403 | }, |
| 12404 | flags: []string{ |
| 12405 | "-async", |
| 12406 | "-no-op-extra-handshake", |
| 12407 | }, |
| 12408 | }) |
| 12409 | testCases = append(testCases, testCase{ |
| 12410 | testType: serverTest, |
| 12411 | name: "ExtraHandshake-Server-TLS13", |
| 12412 | config: Config{ |
| 12413 | MinVersion: VersionTLS13, |
| 12414 | MaxVersion: VersionTLS13, |
| 12415 | }, |
| 12416 | flags: []string{ |
| 12417 | "-async", |
| 12418 | "-no-op-extra-handshake", |
| 12419 | }, |
| 12420 | }) |
| 12421 | |
| 12422 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12423 | testCases = append(testCases, testCase{ |
| 12424 | testType: serverTest, |
| 12425 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12426 | config: Config{ |
| 12427 | MaxVersion: VersionTLS13, |
| 12428 | MinVersion: VersionTLS13, |
| 12429 | Bugs: ProtocolBugs{ |
| 12430 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12431 | ExpectEarlyDataAccepted: true, |
| 12432 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12433 | }, |
| 12434 | }, |
| 12435 | messageCount: 2, |
| 12436 | resumeSession: true, |
| 12437 | flags: []string{ |
| 12438 | "-async", |
| 12439 | "-enable-early-data", |
| 12440 | "-expect-accept-early-data", |
| 12441 | "-no-op-extra-handshake", |
| 12442 | }, |
| 12443 | }) |
| 12444 | |
| 12445 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12446 | // Start. We test this by handshaking twice and asserting the False |
| 12447 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12448 | // how the test works. |
| 12449 | testCases = append(testCases, testCase{ |
| 12450 | testType: clientTest, |
| 12451 | name: "ExtraHandshake-FalseStart", |
| 12452 | config: Config{ |
| 12453 | MaxVersion: VersionTLS12, |
| 12454 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12455 | NextProtos: []string{"foo"}, |
| 12456 | Bugs: ProtocolBugs{ |
| 12457 | ExpectFalseStart: true, |
| 12458 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12459 | }, |
| 12460 | }, |
| 12461 | flags: []string{ |
| 12462 | "-handshake-twice", |
| 12463 | "-false-start", |
| 12464 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12465 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12466 | }, |
| 12467 | shimWritesFirst: true, |
| 12468 | shouldFail: true, |
| 12469 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12470 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12471 | }) |
| 12472 | } |
| 12473 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12474 | // Test that omitted and empty extensions blocks are tolerated. |
| 12475 | func addOmitExtensionsTests() { |
| 12476 | for _, ver := range tlsVersions { |
| 12477 | if ver.version > VersionTLS12 { |
| 12478 | continue |
| 12479 | } |
| 12480 | |
| 12481 | testCases = append(testCases, testCase{ |
| 12482 | testType: serverTest, |
| 12483 | name: "OmitExtensions-ClientHello-" + ver.name, |
| 12484 | config: Config{ |
| 12485 | MinVersion: ver.version, |
| 12486 | MaxVersion: ver.version, |
| 12487 | SessionTicketsDisabled: true, |
| 12488 | Bugs: ProtocolBugs{ |
| 12489 | OmitExtensions: true, |
| 12490 | }, |
| 12491 | }, |
| 12492 | }) |
| 12493 | |
| 12494 | testCases = append(testCases, testCase{ |
| 12495 | testType: serverTest, |
| 12496 | name: "EmptyExtensions-ClientHello-" + ver.name, |
| 12497 | config: Config{ |
| 12498 | MinVersion: ver.version, |
| 12499 | MaxVersion: ver.version, |
| 12500 | SessionTicketsDisabled: true, |
| 12501 | Bugs: ProtocolBugs{ |
| 12502 | EmptyExtensions: true, |
| 12503 | }, |
| 12504 | }, |
| 12505 | }) |
| 12506 | |
| 12507 | testCases = append(testCases, testCase{ |
| 12508 | testType: clientTest, |
| 12509 | name: "OmitExtensions-ServerHello-" + ver.name, |
| 12510 | config: Config{ |
| 12511 | MinVersion: ver.version, |
| 12512 | MaxVersion: ver.version, |
| 12513 | SessionTicketsDisabled: true, |
| 12514 | Bugs: ProtocolBugs{ |
| 12515 | OmitExtensions: true, |
| 12516 | // Disable all ServerHello extensions so |
| 12517 | // OmitExtensions works. |
| 12518 | NoExtendedMasterSecret: true, |
| 12519 | NoRenegotiationInfo: true, |
| 12520 | }, |
| 12521 | }, |
| 12522 | }) |
| 12523 | |
| 12524 | testCases = append(testCases, testCase{ |
| 12525 | testType: clientTest, |
| 12526 | name: "EmptyExtensions-ServerHello-" + ver.name, |
| 12527 | config: Config{ |
| 12528 | MinVersion: ver.version, |
| 12529 | MaxVersion: ver.version, |
| 12530 | SessionTicketsDisabled: true, |
| 12531 | Bugs: ProtocolBugs{ |
| 12532 | EmptyExtensions: true, |
| 12533 | // Disable all ServerHello extensions so |
| 12534 | // EmptyExtensions works. |
| 12535 | NoExtendedMasterSecret: true, |
| 12536 | NoRenegotiationInfo: true, |
| 12537 | }, |
| 12538 | }, |
| 12539 | }) |
| 12540 | } |
| 12541 | } |
| 12542 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12543 | 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] | 12544 | defer wg.Done() |
| 12545 | |
| 12546 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12547 | var err error |
| 12548 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12549 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12550 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12551 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12552 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12553 | if err != nil { |
| 12554 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12555 | } |
| 12556 | break |
| 12557 | } |
| 12558 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12559 | } else if *repeatUntilFailure { |
| 12560 | for err == nil { |
| 12561 | statusChan <- statusMsg{test: test, started: true} |
| 12562 | err = runTest(test, shimPath, -1) |
| 12563 | } |
| 12564 | } else { |
| 12565 | statusChan <- statusMsg{test: test, started: true} |
| 12566 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12567 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12568 | statusChan <- statusMsg{test: test, err: err} |
| 12569 | } |
| 12570 | } |
| 12571 | |
| 12572 | type statusMsg struct { |
| 12573 | test *testCase |
| 12574 | started bool |
| 12575 | err error |
| 12576 | } |
| 12577 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12578 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12579 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12580 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12581 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12582 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12583 | if !*pipe { |
| 12584 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12585 | var erase string |
| 12586 | for i := 0; i < lineLen; i++ { |
| 12587 | erase += "\b \b" |
| 12588 | } |
| 12589 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12590 | } |
| 12591 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12592 | if msg.started { |
| 12593 | started++ |
| 12594 | } else { |
| 12595 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12596 | |
| 12597 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12598 | if msg.err == errUnimplemented { |
| 12599 | if *pipe { |
| 12600 | // Print each test instead of a status line. |
| 12601 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12602 | } |
| 12603 | unimplemented++ |
| 12604 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12605 | } else { |
| 12606 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12607 | failed++ |
| 12608 | testOutput.addResult(msg.test.name, "FAIL") |
| 12609 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12610 | } else { |
| 12611 | if *pipe { |
| 12612 | // Print each test instead of a status line. |
| 12613 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12614 | } |
| 12615 | testOutput.addResult(msg.test.name, "PASS") |
| 12616 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12617 | } |
| 12618 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12619 | if !*pipe { |
| 12620 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12621 | 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] | 12622 | lineLen = len(line) |
| 12623 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12624 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12625 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12626 | |
| 12627 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12628 | } |
| 12629 | |
| 12630 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12631 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12632 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12633 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12634 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12635 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12636 | addCipherSuiteTests() |
| 12637 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12638 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12639 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12640 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12641 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12642 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12643 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12644 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12645 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12646 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12647 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12648 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12649 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12650 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12651 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12652 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12653 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12654 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12655 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12656 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12657 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12658 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12659 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12660 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12661 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12662 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12663 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12664 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12665 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12666 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12667 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12668 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12669 | addExtraHandshakeTests() |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12670 | addOmitExtensionsTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12671 | |
| 12672 | var wg sync.WaitGroup |
| 12673 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12674 | statusChan := make(chan statusMsg, *numWorkers) |
| 12675 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12676 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12677 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12678 | if len(*shimConfigFile) != 0 { |
| 12679 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12680 | if err != nil { |
| 12681 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12682 | os.Exit(1) |
| 12683 | } |
| 12684 | |
| 12685 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12686 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12687 | os.Exit(1) |
| 12688 | } |
| 12689 | } |
| 12690 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12691 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12692 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12693 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12694 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12695 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12696 | } |
| 12697 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12698 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12699 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12700 | matched := true |
| 12701 | if len(*testToRun) != 0 { |
| 12702 | var err error |
| 12703 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12704 | if err != nil { |
| 12705 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12706 | os.Exit(1) |
| 12707 | } |
| 12708 | } |
| 12709 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12710 | if !*includeDisabled { |
| 12711 | for pattern := range shimConfig.DisabledTests { |
| 12712 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12713 | if err != nil { |
| 12714 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12715 | os.Exit(1) |
| 12716 | } |
| 12717 | |
| 12718 | if isDisabled { |
| 12719 | matched = false |
| 12720 | break |
| 12721 | } |
| 12722 | } |
| 12723 | } |
| 12724 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12725 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12726 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12727 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12728 | |
| 12729 | // Only run one test if repeating until failure. |
| 12730 | if *repeatUntilFailure { |
| 12731 | break |
| 12732 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12733 | } |
| 12734 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12735 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12736 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12737 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12738 | os.Exit(1) |
| 12739 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12740 | |
| 12741 | close(testChan) |
| 12742 | wg.Wait() |
| 12743 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12744 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12745 | |
| 12746 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12747 | |
| 12748 | if *jsonOutput != "" { |
| 12749 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12750 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12751 | } |
| 12752 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12753 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12754 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12755 | os.Exit(1) |
| 12756 | } |
| 12757 | |
| 12758 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12759 | os.Exit(1) |
| 12760 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12761 | } |