Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 21 | "crypto/rand" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 22 | "crypto/x509" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 23 | "crypto/x509/pkix" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 24 | "encoding/base64" |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 25 | "encoding/hex" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 26 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 27 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 28 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 29 | "flag" |
| 30 | "fmt" |
| 31 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 32 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 33 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 34 | "net" |
| 35 | "os" |
| 36 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 37 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 38 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 39 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 40 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 41 | "strings" |
| 42 | "sync" |
| 43 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 44 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 45 | ) |
| 46 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 47 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 48 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 49 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 50 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 51 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 52 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 53 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask bssl_shim to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
| 54 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 55 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 56 | testToRun = flag.String("test", "", "The pattern to filter tests to run, or empty to run all tests") |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 57 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 58 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 59 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 60 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 61 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 62 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 63 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 64 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 65 | looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 66 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 67 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 68 | repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 69 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 70 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 71 | // ShimConfigurations is used with the “json” package and represents a shim |
| 72 | // config file. |
| 73 | type ShimConfiguration struct { |
| 74 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 75 | // The glob pattern is used to exclude tests from being run and the |
| 76 | // freeform string is unparsed but expected to explain why the test is |
| 77 | // disabled. |
| 78 | DisabledTests map[string]string |
| 79 | |
| 80 | // ErrorMap maps from expected error strings to the correct error |
| 81 | // string for the shim in question. For example, it might map |
| 82 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 83 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 84 | ErrorMap map[string]string |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 85 | |
| 86 | // HalfRTTTickets is the number of half-RTT tickets the client should |
| 87 | // expect before half-RTT data when testing 0-RTT. |
| 88 | HalfRTTTickets int |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 89 | } |
| 90 | |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 91 | // Setup shimConfig defaults aligning with BoringSSL. |
| 92 | var shimConfig ShimConfiguration = ShimConfiguration{ |
| 93 | HalfRTTTickets: 2, |
| 94 | } |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 95 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 96 | type testCert int |
| 97 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 98 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 99 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 100 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 101 | testCertRSAChain |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 102 | testCertECDSAP224 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 103 | testCertECDSAP256 |
| 104 | testCertECDSAP384 |
| 105 | testCertECDSAP521 |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 106 | testCertEd25519 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 107 | ) |
| 108 | |
| 109 | const ( |
| 110 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 111 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 112 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 113 | ecdsaP224CertificateFile = "ecdsa_p224_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 114 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 115 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 116 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 117 | ed25519CertificateFile = "ed25519_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 118 | ) |
| 119 | |
| 120 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 121 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 122 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 123 | rsaChainKeyFile = "rsa_chain_key.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 124 | ecdsaP224KeyFile = "ecdsa_p224_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 125 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 126 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 127 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 128 | ed25519KeyFile = "ed25519_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 129 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 130 | ) |
| 131 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 132 | var ( |
| 133 | rsaCertificate Certificate |
| 134 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 135 | rsaChainCertificate Certificate |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 136 | ecdsaP224Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | ecdsaP256Certificate Certificate |
| 138 | ecdsaP384Certificate Certificate |
| 139 | ecdsaP521Certificate Certificate |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 140 | ed25519Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 141 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 142 | |
| 143 | var testCerts = []struct { |
| 144 | id testCert |
| 145 | certFile, keyFile string |
| 146 | cert *Certificate |
| 147 | }{ |
| 148 | { |
| 149 | id: testCertRSA, |
| 150 | certFile: rsaCertificateFile, |
| 151 | keyFile: rsaKeyFile, |
| 152 | cert: &rsaCertificate, |
| 153 | }, |
| 154 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 155 | id: testCertRSA1024, |
| 156 | certFile: rsa1024CertificateFile, |
| 157 | keyFile: rsa1024KeyFile, |
| 158 | cert: &rsa1024Certificate, |
| 159 | }, |
| 160 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 161 | id: testCertRSAChain, |
| 162 | certFile: rsaChainCertificateFile, |
| 163 | keyFile: rsaChainKeyFile, |
| 164 | cert: &rsaChainCertificate, |
| 165 | }, |
| 166 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 167 | id: testCertECDSAP224, |
| 168 | certFile: ecdsaP224CertificateFile, |
| 169 | keyFile: ecdsaP224KeyFile, |
| 170 | cert: &ecdsaP224Certificate, |
| 171 | }, |
| 172 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 173 | id: testCertECDSAP256, |
| 174 | certFile: ecdsaP256CertificateFile, |
| 175 | keyFile: ecdsaP256KeyFile, |
| 176 | cert: &ecdsaP256Certificate, |
| 177 | }, |
| 178 | { |
| 179 | id: testCertECDSAP384, |
| 180 | certFile: ecdsaP384CertificateFile, |
| 181 | keyFile: ecdsaP384KeyFile, |
| 182 | cert: &ecdsaP384Certificate, |
| 183 | }, |
| 184 | { |
| 185 | id: testCertECDSAP521, |
| 186 | certFile: ecdsaP521CertificateFile, |
| 187 | keyFile: ecdsaP521KeyFile, |
| 188 | cert: &ecdsaP521Certificate, |
| 189 | }, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 190 | { |
| 191 | id: testCertEd25519, |
| 192 | certFile: ed25519CertificateFile, |
| 193 | keyFile: ed25519KeyFile, |
| 194 | cert: &ed25519Certificate, |
| 195 | }, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 196 | } |
| 197 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 198 | var channelIDKey *ecdsa.PrivateKey |
| 199 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 200 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 201 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 202 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 203 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 204 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 205 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 206 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 208 | for i := range testCerts { |
| 209 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 210 | if err != nil { |
| 211 | panic(err) |
| 212 | } |
| 213 | cert.OCSPStaple = testOCSPResponse |
| 214 | cert.SignedCertificateTimestampList = testSCTList |
| 215 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 217 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 218 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 219 | if err != nil { |
| 220 | panic(err) |
| 221 | } |
| 222 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 223 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 224 | panic("bad key type") |
| 225 | } |
| 226 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 227 | if err != nil { |
| 228 | panic(err) |
| 229 | } |
| 230 | if channelIDKey.Curve != elliptic.P256() { |
| 231 | panic("bad curve") |
| 232 | } |
| 233 | |
| 234 | channelIDBytes = make([]byte, 64) |
| 235 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 236 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 237 | } |
| 238 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 239 | func getRunnerCertificate(t testCert) Certificate { |
| 240 | for _, cert := range testCerts { |
| 241 | if cert.id == t { |
| 242 | return *cert.cert |
| 243 | } |
| 244 | } |
| 245 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 246 | } |
| 247 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 248 | func getShimCertificate(t testCert) string { |
| 249 | for _, cert := range testCerts { |
| 250 | if cert.id == t { |
| 251 | return cert.certFile |
| 252 | } |
| 253 | } |
| 254 | panic("Unknown test certificate") |
| 255 | } |
| 256 | |
| 257 | func getShimKey(t testCert) string { |
| 258 | for _, cert := range testCerts { |
| 259 | if cert.id == t { |
| 260 | return cert.keyFile |
| 261 | } |
| 262 | } |
| 263 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 266 | // recordVersionToWire maps a record-layer protocol version to its wire |
| 267 | // representation. |
| 268 | func recordVersionToWire(vers uint16, protocol protocol) uint16 { |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 269 | if protocol == dtls { |
| 270 | switch vers { |
| 271 | case VersionTLS12: |
| 272 | return VersionDTLS12 |
| 273 | case VersionTLS10: |
| 274 | return VersionDTLS10 |
| 275 | } |
| 276 | } else { |
| 277 | switch vers { |
| 278 | case VersionSSL30, VersionTLS10, VersionTLS11, VersionTLS12: |
| 279 | return vers |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
| 283 | panic("unknown version") |
| 284 | } |
| 285 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 286 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 287 | func encodeDERValues(values [][]byte) string { |
| 288 | var ret string |
| 289 | for i, v := range values { |
| 290 | if i > 0 { |
| 291 | ret += "," |
| 292 | } |
| 293 | ret += hex.EncodeToString(v) |
| 294 | } |
| 295 | |
| 296 | return ret |
| 297 | } |
| 298 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 299 | type testType int |
| 300 | |
| 301 | const ( |
| 302 | clientTest testType = iota |
| 303 | serverTest |
| 304 | ) |
| 305 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 306 | type protocol int |
| 307 | |
| 308 | const ( |
| 309 | tls protocol = iota |
| 310 | dtls |
| 311 | ) |
| 312 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 313 | const ( |
| 314 | alpn = 1 |
| 315 | npn = 2 |
| 316 | ) |
| 317 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 318 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 319 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 320 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 321 | name string |
| 322 | config Config |
| 323 | shouldFail bool |
| 324 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 325 | // expectedLocalError, if not empty, contains a substring that must be |
| 326 | // found in the local error. |
| 327 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 328 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 329 | // negotiated. |
| 330 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 331 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 332 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 333 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 334 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 335 | // should be negotiated. |
| 336 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 337 | // expectChannelID controls whether the connection should have |
| 338 | // negotiated a Channel ID with channelIDKey. |
| 339 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 340 | // expectedNextProto controls whether the connection should |
| 341 | // negotiate a next protocol via NPN or ALPN. |
| 342 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 343 | // expectNoNextProto, if true, means that no next protocol should be |
| 344 | // negotiated. |
| 345 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 346 | // expectedNextProtoType, if non-zero, is the expected next |
| 347 | // protocol negotiation mechanism. |
| 348 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 349 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 350 | // should be negotiated. If zero, none should be negotiated. |
| 351 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 352 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 353 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 354 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 355 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 356 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 357 | // algorithm that the peer should have used in the handshake. |
| 358 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 359 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 360 | // have used. |
| 361 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 362 | // messageLen is the length, in bytes, of the test message that will be |
| 363 | // sent. |
| 364 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 365 | // messageCount is the number of test messages that will be sent. |
| 366 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 367 | // certFile is the path to the certificate to use for the server. |
| 368 | certFile string |
| 369 | // keyFile is the path to the private key to use for the server. |
| 370 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 371 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 372 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 373 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 374 | // resumeRenewedSession controls whether a third connection should be |
| 375 | // tested which attempts to resume the second connection's session. |
| 376 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 377 | // expectResumeRejected, if true, specifies that the attempted |
| 378 | // resumption must be rejected by the client. This is only valid for a |
| 379 | // serverTest. |
| 380 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 381 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 382 | // resumption. Unless newSessionsOnResume is set, |
| 383 | // SessionTicketKey, ServerSessionCache, and |
| 384 | // ClientSessionCache are copied from the initial connection's |
| 385 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 386 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 387 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 388 | // use a different session resumption context. |
| 389 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 390 | // noSessionCache, if true, will cause the server to run without a |
| 391 | // session cache. |
| 392 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 393 | // sendPrefix sends a prefix on the socket before actually performing a |
| 394 | // handshake. |
| 395 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 396 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 397 | // message before doing a roundtrip with the runner. |
| 398 | shimWritesFirst bool |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 399 | // readWithUnfinishedWrite behaves like shimWritesFirst, but the shim |
| 400 | // does not complete the write until responding to the first runner |
| 401 | // message. |
| 402 | readWithUnfinishedWrite bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 403 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 404 | // connection immediately after the handshake rather than echoing |
| 405 | // messages from the runner. |
| 406 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 407 | // renegotiate indicates the number of times the connection should be |
| 408 | // renegotiated during the exchange. |
| 409 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 410 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 411 | // HelloRequest when the handshake completes. |
| 412 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 413 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 414 | // switched in just before renegotiation. |
| 415 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 416 | // replayWrites, if true, configures the underlying transport |
| 417 | // to replay every write it makes in DTLS tests. |
| 418 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 419 | // damageFirstWrite, if true, configures the underlying transport to |
| 420 | // damage the final byte of the first application data write. |
| 421 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 422 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 423 | // keying material and verify they match. |
| 424 | exportKeyingMaterial int |
| 425 | exportLabel string |
| 426 | exportContext string |
| 427 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 428 | // flags, if not empty, contains a list of command-line flags that will |
| 429 | // be passed to the shim program. |
| 430 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 431 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 432 | // which will be compared against the expected value. |
| 433 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 434 | // sendEmptyRecords is the number of consecutive empty records to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 435 | // before each test message. |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 436 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 437 | // sendWarningAlerts is the number of consecutive warning alerts to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 438 | // before each test message. |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 439 | sendWarningAlerts int |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 440 | // sendBogusAlertType, if true, causes a bogus alert of invalid type to |
| 441 | // be sent before each test message. |
| 442 | sendBogusAlertType bool |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 443 | // sendKeyUpdates is the number of consecutive key updates to send |
| 444 | // before and after the test message. |
| 445 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 446 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 447 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 448 | // expectMessageDropped, if true, means the test message is expected to |
| 449 | // be dropped by the client rather than echoed back. |
| 450 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 451 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 452 | // is expected to send. |
| 453 | expectPeerCertificate *Certificate |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 454 | // shimPrefix is the prefix that the shim will send to the server. |
| 455 | shimPrefix string |
| 456 | // resumeShimPrefix is the prefix that the shim will send to the server on a |
| 457 | // resumption. |
| 458 | resumeShimPrefix string |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 459 | // tls13Variant, if non-zero, causes both runner and shim to be |
| 460 | // configured with the specified TLS 1.3 variant. This is a convenience |
| 461 | // option for configuring both concurrently. |
| 462 | tls13Variant int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 465 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 466 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 467 | func writeTranscript(test *testCase, path string, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 468 | if len(data) == 0 { |
| 469 | return |
| 470 | } |
| 471 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 472 | settings, err := ioutil.ReadFile(path) |
| 473 | if err != nil { |
| 474 | fmt.Fprintf(os.Stderr, "Error reading %s: %s.\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 475 | return |
| 476 | } |
| 477 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 478 | settings = append(settings, data...) |
| 479 | if err := ioutil.WriteFile(path, settings, 0644); err != nil { |
| 480 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 484 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 485 | type timeoutConn struct { |
| 486 | net.Conn |
| 487 | timeout time.Duration |
| 488 | } |
| 489 | |
| 490 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 491 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 492 | return 0, err |
| 493 | } |
| 494 | return t.Conn.Read(b) |
| 495 | } |
| 496 | |
| 497 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 498 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 499 | return 0, err |
| 500 | } |
| 501 | return t.Conn.Write(b) |
| 502 | } |
| 503 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 504 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, transcriptPrefix string, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 505 | if !test.noSessionCache { |
| 506 | if config.ClientSessionCache == nil { |
| 507 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 508 | } |
| 509 | if config.ServerSessionCache == nil { |
| 510 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 511 | } |
| 512 | } |
| 513 | if test.testType == clientTest { |
| 514 | if len(config.Certificates) == 0 { |
| 515 | config.Certificates = []Certificate{rsaCertificate} |
| 516 | } |
| 517 | } else { |
| 518 | // Supply a ServerName to ensure a constant session cache key, |
| 519 | // rather than falling back to net.Conn.RemoteAddr. |
| 520 | if len(config.ServerName) == 0 { |
| 521 | config.ServerName = "test" |
| 522 | } |
| 523 | } |
| 524 | if *fuzzer { |
| 525 | config.Bugs.NullAllCiphers = true |
| 526 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 527 | if *deterministic { |
| 528 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 529 | } |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 530 | if test.tls13Variant != 0 { |
| 531 | config.TLS13Variant = test.tls13Variant |
| 532 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 533 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 534 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 535 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 536 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 537 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 538 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 539 | } |
| 540 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 541 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 542 | local, peer := "client", "server" |
| 543 | if test.testType == clientTest { |
| 544 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 545 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 546 | connDebug := &recordingConn{ |
| 547 | Conn: conn, |
| 548 | isDatagram: test.protocol == dtls, |
| 549 | local: local, |
| 550 | peer: peer, |
| 551 | } |
| 552 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 553 | if *flagDebug { |
| 554 | defer connDebug.WriteTo(os.Stdout) |
| 555 | } |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 556 | if len(transcriptPrefix) != 0 { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 557 | defer func() { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 558 | path := transcriptPrefix + strconv.Itoa(num) |
| 559 | writeTranscript(test, path, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 560 | }() |
| 561 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 562 | |
| 563 | if config.Bugs.PacketAdaptor != nil { |
| 564 | config.Bugs.PacketAdaptor.debug = connDebug |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if test.replayWrites { |
| 569 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 570 | } |
| 571 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 572 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 573 | if test.damageFirstWrite { |
| 574 | connDamage = newDamageAdaptor(conn) |
| 575 | conn = connDamage |
| 576 | } |
| 577 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 578 | if test.sendPrefix != "" { |
| 579 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 580 | return err |
| 581 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 582 | } |
| 583 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 584 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 585 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 586 | if test.protocol == dtls { |
| 587 | tlsConn = DTLSServer(conn, config) |
| 588 | } else { |
| 589 | tlsConn = Server(conn, config) |
| 590 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 591 | } else { |
| 592 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 593 | if test.protocol == dtls { |
| 594 | tlsConn = DTLSClient(conn, config) |
| 595 | } else { |
| 596 | tlsConn = Client(conn, config) |
| 597 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 598 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 599 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 600 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 601 | if err := tlsConn.Handshake(); err != nil { |
| 602 | return err |
| 603 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 604 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 605 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 606 | // expectations struct that can be specified separately for the two |
| 607 | // legs. |
| 608 | expectedVersion := test.expectedVersion |
| 609 | if isResume && test.expectedResumeVersion != 0 { |
| 610 | expectedVersion = test.expectedResumeVersion |
| 611 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 612 | connState := tlsConn.ConnectionState() |
| 613 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 614 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 615 | } |
| 616 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 617 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 618 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 619 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 620 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 621 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 622 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 623 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 624 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 625 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 626 | if channelID == nil { |
| 627 | return fmt.Errorf("no channel ID negotiated") |
| 628 | } |
| 629 | if channelID.Curve != channelIDKey.Curve || |
| 630 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 631 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 632 | return fmt.Errorf("incorrect channel ID") |
| 633 | } |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 634 | } else if connState.ChannelID != nil { |
| 635 | return fmt.Errorf("channel ID unexpectedly negotiated") |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 636 | } |
| 637 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 638 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 639 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 640 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 641 | } |
| 642 | } |
| 643 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 644 | if test.expectNoNextProto { |
| 645 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 646 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 647 | } |
| 648 | } |
| 649 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 650 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 651 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 652 | return fmt.Errorf("next proto type mismatch") |
| 653 | } |
| 654 | } |
| 655 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 656 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 657 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 658 | } |
| 659 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 660 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 661 | 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] | 662 | } |
| 663 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 664 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 665 | return fmt.Errorf("SCT list mismatch") |
| 666 | } |
| 667 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 668 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 669 | 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] | 670 | } |
| 671 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 672 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 673 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 674 | } |
| 675 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 676 | if test.expectPeerCertificate != nil { |
| 677 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 678 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 679 | } |
| 680 | for i, cert := range connState.PeerCertificates { |
| 681 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 682 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 687 | if test.exportKeyingMaterial > 0 { |
| 688 | actual := make([]byte, test.exportKeyingMaterial) |
| 689 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 690 | return err |
| 691 | } |
| 692 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 693 | if err != nil { |
| 694 | return err |
| 695 | } |
| 696 | if !bytes.Equal(actual, expected) { |
| 697 | return fmt.Errorf("keying material mismatch") |
| 698 | } |
| 699 | } |
| 700 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 701 | if test.testTLSUnique { |
| 702 | var peersValue [12]byte |
| 703 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 704 | return err |
| 705 | } |
| 706 | expected := tlsConn.ConnectionState().TLSUnique |
| 707 | if !bytes.Equal(peersValue[:], expected) { |
| 708 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 709 | } |
| 710 | } |
| 711 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 712 | if test.sendHalfHelloRequest { |
| 713 | tlsConn.SendHalfHelloRequest() |
| 714 | } |
| 715 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 716 | shimPrefix := test.shimPrefix |
| 717 | if isResume { |
| 718 | shimPrefix = test.resumeShimPrefix |
| 719 | } |
| 720 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 721 | shimPrefix = "hello" |
| 722 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 723 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 724 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 725 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 726 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 727 | var buf = make([]byte, len(shimPrefix)) |
| 728 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 729 | if err != nil { |
| 730 | return err |
| 731 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 732 | if string(buf) != shimPrefix { |
| 733 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 734 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 735 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 736 | } |
| 737 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 738 | if test.renegotiateCiphers != nil { |
| 739 | config.CipherSuites = test.renegotiateCiphers |
| 740 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 741 | for i := 0; i < test.renegotiate; i++ { |
| 742 | if err := tlsConn.Renegotiate(); err != nil { |
| 743 | return err |
| 744 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 745 | } |
| 746 | } else if test.renegotiateCiphers != nil { |
| 747 | panic("renegotiateCiphers without renegotiate") |
| 748 | } |
| 749 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 750 | if test.damageFirstWrite { |
| 751 | connDamage.setDamage(true) |
| 752 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 753 | connDamage.setDamage(false) |
| 754 | } |
| 755 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 756 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 757 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 758 | if test.protocol == dtls { |
| 759 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 760 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 761 | // Read until EOF. |
| 762 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 763 | return err |
| 764 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 765 | if messageLen == 0 { |
| 766 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 767 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 768 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 769 | messageCount := test.messageCount |
| 770 | if messageCount == 0 { |
| 771 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 772 | } |
| 773 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 774 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 775 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 776 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 777 | } |
| 778 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 779 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 780 | tlsConn.Write(nil) |
| 781 | } |
| 782 | |
| 783 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 784 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 785 | } |
| 786 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 787 | if test.sendBogusAlertType { |
| 788 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 789 | } |
| 790 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 791 | testMessage := make([]byte, messageLen) |
| 792 | for i := range testMessage { |
| 793 | testMessage[i] = 0x42 ^ byte(j) |
| 794 | } |
| 795 | tlsConn.Write(testMessage) |
| 796 | |
| 797 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 798 | if shimPrefix != "" { |
| 799 | var buf = make([]byte, len(shimPrefix)) |
| 800 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 801 | if err != nil { |
| 802 | return err |
| 803 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 804 | if string(buf) != shimPrefix { |
| 805 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 806 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 807 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 808 | } |
| 809 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 810 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 811 | // The shim will not respond. |
| 812 | continue |
| 813 | } |
| 814 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 815 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 816 | // sends, the shim should respond only once. |
| 817 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 818 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 819 | return err |
| 820 | } |
| 821 | } |
| 822 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 823 | buf := make([]byte, len(testMessage)) |
| 824 | if test.protocol == dtls { |
| 825 | bufTmp := make([]byte, len(buf)+1) |
| 826 | n, err := tlsConn.Read(bufTmp) |
| 827 | if err != nil { |
| 828 | return err |
| 829 | } |
| 830 | if n != len(buf) { |
| 831 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 832 | } |
| 833 | copy(buf, bufTmp) |
| 834 | } else { |
| 835 | _, err := io.ReadFull(tlsConn, buf) |
| 836 | if err != nil { |
| 837 | return err |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | for i, v := range buf { |
| 842 | if v != testMessage[i]^0xff { |
| 843 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 844 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | |
| 848 | return nil |
| 849 | } |
| 850 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 851 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 852 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 853 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 854 | 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] | 855 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 856 | valgrindArgs = append(valgrindArgs, path) |
| 857 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 858 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 859 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 860 | } |
| 861 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 862 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 863 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 864 | xtermArgs = append(xtermArgs, path) |
| 865 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 866 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 867 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 868 | } |
| 869 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 870 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 871 | xtermArgs := []string{"-e", "lldb", "--"} |
| 872 | xtermArgs = append(xtermArgs, path) |
| 873 | xtermArgs = append(xtermArgs, args...) |
| 874 | |
| 875 | return exec.Command("xterm", xtermArgs...) |
| 876 | } |
| 877 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 878 | var ( |
| 879 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 880 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 881 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 882 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 883 | // accept accepts a connection from listener, unless waitChan signals a process |
| 884 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 885 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 886 | type connOrError struct { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 887 | conn net.Conn |
| 888 | err error |
| 889 | startTime, endTime time.Time |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 890 | } |
| 891 | connChan := make(chan connOrError, 1) |
| 892 | go func() { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 893 | startTime := time.Now() |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 894 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 895 | conn, err := listener.Accept() |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 896 | endTime := time.Now() |
| 897 | connChan <- connOrError{conn, err, startTime, endTime} |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 898 | close(connChan) |
| 899 | }() |
| 900 | select { |
| 901 | case result := <-connChan: |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 902 | if result.err != nil { |
| 903 | // TODO(davidben): Remove this logging when |
| 904 | // https://crbug.com/boringssl/199 is resolved. |
| 905 | fmt.Fprintf(os.Stderr, "acceptOrWait failed, startTime=%v, endTime=%v\n", result.startTime, result.endTime) |
| 906 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 907 | return result.conn, result.err |
| 908 | case childErr := <-waitChan: |
| 909 | waitChan <- childErr |
| 910 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 911 | } |
| 912 | } |
| 913 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 914 | func translateExpectedError(errorStr string) string { |
| 915 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 916 | return translated |
| 917 | } |
| 918 | |
| 919 | if *looseErrors { |
| 920 | return "" |
| 921 | } |
| 922 | |
| 923 | return errorStr |
| 924 | } |
| 925 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 926 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 927 | // Help debugging panics on the Go side. |
| 928 | defer func() { |
| 929 | if r := recover(); r != nil { |
| 930 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 931 | panic(r) |
| 932 | } |
| 933 | }() |
| 934 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 935 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 936 | panic("Error expected without shouldFail in " + test.name) |
| 937 | } |
| 938 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 939 | if test.expectResumeRejected && !test.resumeSession { |
| 940 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 941 | } |
| 942 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 943 | for _, ver := range tlsVersions { |
| 944 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 945 | continue |
| 946 | } |
| 947 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 948 | if test.config.MaxVersion == 0 && test.config.MinVersion == 0 && test.expectedVersion == 0 { |
| 949 | 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] | 950 | } |
| 951 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 952 | if ver.tls13Variant != 0 { |
| 953 | var foundFlag bool |
| 954 | for _, flag := range test.flags { |
| 955 | if flag == "-tls13-variant" { |
| 956 | foundFlag = true |
| 957 | break |
| 958 | } |
| 959 | } |
| 960 | if !foundFlag && test.config.TLS13Variant != ver.tls13Variant && test.tls13Variant != ver.tls13Variant { |
| 961 | 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)) |
| 962 | } |
| 963 | } |
| 964 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 965 | } |
| 966 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 967 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 968 | if err != nil { |
| 969 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 970 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 971 | if err != nil { |
| 972 | panic(err) |
| 973 | } |
| 974 | defer func() { |
| 975 | if listener != nil { |
| 976 | listener.Close() |
| 977 | } |
| 978 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 979 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 980 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 981 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 982 | flags = append(flags, "-server") |
| 983 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 984 | flags = append(flags, "-key-file") |
| 985 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 986 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 987 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 988 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | flags = append(flags, "-cert-file") |
| 992 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 993 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 994 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 995 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 996 | } |
| 997 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 998 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 999 | if test.protocol == dtls { |
| 1000 | flags = append(flags, "-dtls") |
| 1001 | } |
| 1002 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1003 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1004 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1005 | resumeCount++ |
| 1006 | if test.resumeRenewedSession { |
| 1007 | resumeCount++ |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | if resumeCount > 0 { |
| 1012 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1013 | } |
| 1014 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 1015 | if test.shimWritesFirst { |
| 1016 | flags = append(flags, "-shim-writes-first") |
| 1017 | } |
| 1018 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 1019 | if test.readWithUnfinishedWrite { |
| 1020 | flags = append(flags, "-read-with-unfinished-write") |
| 1021 | } |
| 1022 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1023 | if test.shimShutsDown { |
| 1024 | flags = append(flags, "-shim-shuts-down") |
| 1025 | } |
| 1026 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1027 | if test.exportKeyingMaterial > 0 { |
| 1028 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 1029 | flags = append(flags, "-export-label", test.exportLabel) |
| 1030 | flags = append(flags, "-export-context", test.exportContext) |
| 1031 | if test.useExportContext { |
| 1032 | flags = append(flags, "-use-export-context") |
| 1033 | } |
| 1034 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 1035 | if test.expectResumeRejected { |
| 1036 | flags = append(flags, "-expect-session-miss") |
| 1037 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1038 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 1039 | if test.testTLSUnique { |
| 1040 | flags = append(flags, "-tls-unique") |
| 1041 | } |
| 1042 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1043 | if test.tls13Variant != 0 { |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1044 | flags = append(flags, "-tls13-variant", strconv.Itoa(test.tls13Variant)) |
| 1045 | } |
| 1046 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1047 | var transcriptPrefix string |
| 1048 | if len(*transcriptDir) != 0 { |
| 1049 | protocol := "tls" |
| 1050 | if test.protocol == dtls { |
| 1051 | protocol = "dtls" |
| 1052 | } |
| 1053 | |
| 1054 | side := "client" |
| 1055 | if test.testType == serverTest { |
| 1056 | side = "server" |
| 1057 | } |
| 1058 | |
| 1059 | dir := filepath.Join(*transcriptDir, protocol, side) |
| 1060 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 1061 | return err |
| 1062 | } |
| 1063 | transcriptPrefix = filepath.Join(dir, test.name+"-") |
| 1064 | flags = append(flags, "-write-settings", transcriptPrefix) |
| 1065 | } |
| 1066 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1067 | flags = append(flags, test.flags...) |
| 1068 | |
| 1069 | var shim *exec.Cmd |
| 1070 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1071 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1072 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1073 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1074 | } else if *useLLDB { |
| 1075 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1076 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1077 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1078 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1079 | shim.Stdin = os.Stdin |
| 1080 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1081 | shim.Stdout = &stdoutBuf |
| 1082 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1083 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1084 | shim.Env = os.Environ() |
| 1085 | 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] | 1086 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1087 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1088 | } |
| 1089 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1090 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1091 | |
| 1092 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1093 | panic(err) |
| 1094 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1095 | waitChan := make(chan error, 1) |
| 1096 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1097 | |
| 1098 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1100 | if *deterministic { |
| 1101 | config.Rand = &deterministicRand{} |
| 1102 | } |
| 1103 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1104 | conn, err := acceptOrWait(listener, waitChan) |
| 1105 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1106 | err = doExchange(test, &config, conn, false /* not a resumption */, transcriptPrefix, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1107 | conn.Close() |
| 1108 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1109 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1110 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1111 | var resumeConfig Config |
| 1112 | if test.resumeConfig != nil { |
| 1113 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1114 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1115 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1116 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1117 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1118 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1119 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1120 | } else { |
| 1121 | resumeConfig = config |
| 1122 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1123 | var connResume net.Conn |
| 1124 | connResume, err = acceptOrWait(listener, waitChan) |
| 1125 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1126 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, transcriptPrefix, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1127 | connResume.Close() |
| 1128 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1129 | } |
| 1130 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1131 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1132 | // open more connections than expected. |
| 1133 | listener.Close() |
| 1134 | listener = nil |
| 1135 | |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1136 | var shimKilledLock sync.Mutex |
| 1137 | var shimKilled bool |
| 1138 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1139 | shimKilledLock.Lock() |
| 1140 | shimKilled = true |
| 1141 | shimKilledLock.Unlock() |
| 1142 | shim.Process.Kill() |
| 1143 | }) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1144 | childErr := <-waitChan |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1145 | waitTimeout.Stop() |
| 1146 | shimKilledLock.Lock() |
| 1147 | if shimKilled && err == nil { |
| 1148 | err = errors.New("timeout waiting for the shim to exit.") |
| 1149 | } |
| 1150 | shimKilledLock.Unlock() |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1151 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1152 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1153 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1154 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1155 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1156 | case 89: |
| 1157 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1158 | case 99: |
| 1159 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1160 | } |
| 1161 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1162 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1163 | // Account for Windows line endings. |
| 1164 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1165 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1166 | |
| 1167 | // Separate the errors from the shim and those from tools like |
| 1168 | // AddressSanitizer. |
| 1169 | var extraStderr string |
| 1170 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1171 | stderr = stderrParts[0] |
| 1172 | extraStderr = stderrParts[1] |
| 1173 | } |
| 1174 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1175 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1176 | expectedError := translateExpectedError(test.expectedError) |
| 1177 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1178 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1179 | localError := "none" |
| 1180 | if err != nil { |
| 1181 | localError = err.Error() |
| 1182 | } |
| 1183 | if len(test.expectedLocalError) != 0 { |
| 1184 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1185 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1186 | |
| 1187 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1188 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1189 | if childErr != nil { |
| 1190 | childError = childErr.Error() |
| 1191 | } |
| 1192 | |
| 1193 | var msg string |
| 1194 | switch { |
| 1195 | case failed && !test.shouldFail: |
| 1196 | msg = "unexpected failure" |
| 1197 | case !failed && test.shouldFail: |
| 1198 | msg = "unexpected success" |
| 1199 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1200 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1201 | default: |
| 1202 | panic("internal error") |
| 1203 | } |
| 1204 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1205 | 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] | 1206 | } |
| 1207 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1208 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1209 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1210 | } |
| 1211 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1212 | if *useValgrind && isValgrindError { |
| 1213 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1214 | } |
| 1215 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1216 | return nil |
| 1217 | } |
| 1218 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1219 | type tlsVersion struct { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1220 | name string |
| 1221 | // version is the protocol version. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1222 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1223 | // excludeFlag is the legacy shim flag to disable the version. |
| 1224 | excludeFlag string |
| 1225 | hasDTLS bool |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1226 | // versionDTLS, if non-zero, is the DTLS-specific representation of the version. |
| 1227 | versionDTLS uint16 |
| 1228 | // versionWire, if non-zero, is the wire representation of the |
| 1229 | // version. Otherwise the wire version is the protocol version or |
| 1230 | // versionDTLS. |
| 1231 | versionWire uint16 |
| 1232 | tls13Variant int |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1236 | // The shim uses the protocol version in its public API, but uses the |
| 1237 | // DTLS-specific version if it exists. |
| 1238 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1239 | return strconv.Itoa(int(vers.versionDTLS)) |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1240 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1241 | return strconv.Itoa(int(vers.version)) |
| 1242 | } |
| 1243 | |
| 1244 | func (vers tlsVersion) wire(protocol protocol) uint16 { |
| 1245 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1246 | return vers.versionDTLS |
| 1247 | } |
| 1248 | if vers.versionWire != 0 { |
| 1249 | return vers.versionWire |
| 1250 | } |
| 1251 | return vers.version |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | var tlsVersions = []tlsVersion{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1255 | { |
| 1256 | name: "SSL3", |
| 1257 | version: VersionSSL30, |
| 1258 | excludeFlag: "-no-ssl3", |
| 1259 | }, |
| 1260 | { |
| 1261 | name: "TLS1", |
| 1262 | version: VersionTLS10, |
| 1263 | excludeFlag: "-no-tls1", |
| 1264 | hasDTLS: true, |
| 1265 | versionDTLS: VersionDTLS10, |
| 1266 | }, |
| 1267 | { |
| 1268 | name: "TLS11", |
| 1269 | version: VersionTLS11, |
| 1270 | excludeFlag: "-no-tls11", |
| 1271 | }, |
| 1272 | { |
| 1273 | name: "TLS12", |
| 1274 | version: VersionTLS12, |
| 1275 | excludeFlag: "-no-tls12", |
| 1276 | hasDTLS: true, |
| 1277 | versionDTLS: VersionDTLS12, |
| 1278 | }, |
| 1279 | { |
| 1280 | name: "TLS13", |
| 1281 | version: VersionTLS13, |
| 1282 | excludeFlag: "-no-tls13", |
| 1283 | versionWire: tls13DraftVersion, |
| 1284 | tls13Variant: TLS13Default, |
| 1285 | }, |
| 1286 | { |
| 1287 | name: "TLS13Experiment", |
| 1288 | version: VersionTLS13, |
| 1289 | excludeFlag: "-no-tls13", |
| 1290 | versionWire: tls13ExperimentVersion, |
| 1291 | tls13Variant: TLS13Experiment, |
| 1292 | }, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 1293 | { |
| 1294 | name: "TLS13RecordTypeExperiment", |
| 1295 | version: VersionTLS13, |
| 1296 | excludeFlag: "-no-tls13", |
| 1297 | versionWire: tls13RecordTypeExperimentVersion, |
| 1298 | tls13Variant: TLS13RecordTypeExperiment, |
| 1299 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | func allVersions(protocol protocol) []tlsVersion { |
| 1303 | if protocol == tls { |
| 1304 | return tlsVersions |
| 1305 | } |
| 1306 | |
| 1307 | var ret []tlsVersion |
| 1308 | for _, vers := range tlsVersions { |
| 1309 | if vers.hasDTLS { |
| 1310 | ret = append(ret, vers) |
| 1311 | } |
| 1312 | } |
| 1313 | return ret |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1316 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1317 | name string |
| 1318 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1319 | } |
| 1320 | |
| 1321 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1322 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1323 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1324 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1325 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1326 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1327 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1328 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1329 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1330 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1331 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1332 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1333 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1334 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1335 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1336 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1337 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1338 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1339 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1340 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1341 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1342 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1343 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1344 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1345 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1346 | {"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] | 1347 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1348 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1349 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1350 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1351 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1354 | func hasComponent(suiteName, component string) bool { |
| 1355 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1356 | } |
| 1357 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1358 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1359 | return hasComponent(suiteName, "GCM") || |
| 1360 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1361 | hasComponent(suiteName, "SHA384") || |
| 1362 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1363 | } |
| 1364 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1365 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1366 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1367 | } |
| 1368 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1369 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1370 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1371 | } |
| 1372 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1373 | func bigFromHex(hex string) *big.Int { |
| 1374 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1375 | if !ok { |
| 1376 | panic("failed to parse hex number 0x" + hex) |
| 1377 | } |
| 1378 | return ret |
| 1379 | } |
| 1380 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1381 | func addBasicTests() { |
| 1382 | basicTests := []testCase{ |
| 1383 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1384 | name: "NoFallbackSCSV", |
| 1385 | config: Config{ |
| 1386 | Bugs: ProtocolBugs{ |
| 1387 | FailIfNotFallbackSCSV: true, |
| 1388 | }, |
| 1389 | }, |
| 1390 | shouldFail: true, |
| 1391 | expectedLocalError: "no fallback SCSV found", |
| 1392 | }, |
| 1393 | { |
| 1394 | name: "SendFallbackSCSV", |
| 1395 | config: Config{ |
| 1396 | Bugs: ProtocolBugs{ |
| 1397 | FailIfNotFallbackSCSV: true, |
| 1398 | }, |
| 1399 | }, |
| 1400 | flags: []string{"-fallback-scsv"}, |
| 1401 | }, |
| 1402 | { |
| 1403 | name: "ClientCertificateTypes", |
| 1404 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1405 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1406 | ClientAuth: RequestClientCert, |
| 1407 | ClientCertificateTypes: []byte{ |
| 1408 | CertTypeDSSSign, |
| 1409 | CertTypeRSASign, |
| 1410 | CertTypeECDSASign, |
| 1411 | }, |
| 1412 | }, |
| 1413 | flags: []string{ |
| 1414 | "-expect-certificate-types", |
| 1415 | base64.StdEncoding.EncodeToString([]byte{ |
| 1416 | CertTypeDSSSign, |
| 1417 | CertTypeRSASign, |
| 1418 | CertTypeECDSASign, |
| 1419 | }), |
| 1420 | }, |
| 1421 | }, |
| 1422 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1423 | name: "UnauthenticatedECDH", |
| 1424 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1425 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1426 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1427 | Bugs: ProtocolBugs{ |
| 1428 | UnauthenticatedECDH: true, |
| 1429 | }, |
| 1430 | }, |
| 1431 | shouldFail: true, |
| 1432 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1433 | }, |
| 1434 | { |
| 1435 | name: "SkipCertificateStatus", |
| 1436 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1437 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1438 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1439 | Bugs: ProtocolBugs{ |
| 1440 | SkipCertificateStatus: true, |
| 1441 | }, |
| 1442 | }, |
| 1443 | flags: []string{ |
| 1444 | "-enable-ocsp-stapling", |
| 1445 | }, |
| 1446 | }, |
| 1447 | { |
| 1448 | name: "SkipServerKeyExchange", |
| 1449 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1450 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1451 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1452 | Bugs: ProtocolBugs{ |
| 1453 | SkipServerKeyExchange: true, |
| 1454 | }, |
| 1455 | }, |
| 1456 | shouldFail: true, |
| 1457 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1458 | }, |
| 1459 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1460 | testType: serverTest, |
| 1461 | name: "Alert", |
| 1462 | config: Config{ |
| 1463 | Bugs: ProtocolBugs{ |
| 1464 | SendSpuriousAlert: alertRecordOverflow, |
| 1465 | }, |
| 1466 | }, |
| 1467 | shouldFail: true, |
| 1468 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1469 | }, |
| 1470 | { |
| 1471 | protocol: dtls, |
| 1472 | testType: serverTest, |
| 1473 | name: "Alert-DTLS", |
| 1474 | config: Config{ |
| 1475 | Bugs: ProtocolBugs{ |
| 1476 | SendSpuriousAlert: alertRecordOverflow, |
| 1477 | }, |
| 1478 | }, |
| 1479 | shouldFail: true, |
| 1480 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1481 | }, |
| 1482 | { |
| 1483 | testType: serverTest, |
| 1484 | name: "FragmentAlert", |
| 1485 | config: Config{ |
| 1486 | Bugs: ProtocolBugs{ |
| 1487 | FragmentAlert: true, |
| 1488 | SendSpuriousAlert: alertRecordOverflow, |
| 1489 | }, |
| 1490 | }, |
| 1491 | shouldFail: true, |
| 1492 | expectedError: ":BAD_ALERT:", |
| 1493 | }, |
| 1494 | { |
| 1495 | protocol: dtls, |
| 1496 | testType: serverTest, |
| 1497 | name: "FragmentAlert-DTLS", |
| 1498 | config: Config{ |
| 1499 | Bugs: ProtocolBugs{ |
| 1500 | FragmentAlert: true, |
| 1501 | SendSpuriousAlert: alertRecordOverflow, |
| 1502 | }, |
| 1503 | }, |
| 1504 | shouldFail: true, |
| 1505 | expectedError: ":BAD_ALERT:", |
| 1506 | }, |
| 1507 | { |
| 1508 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1509 | name: "DoubleAlert", |
| 1510 | config: Config{ |
| 1511 | Bugs: ProtocolBugs{ |
| 1512 | DoubleAlert: true, |
| 1513 | SendSpuriousAlert: alertRecordOverflow, |
| 1514 | }, |
| 1515 | }, |
| 1516 | shouldFail: true, |
| 1517 | expectedError: ":BAD_ALERT:", |
| 1518 | }, |
| 1519 | { |
| 1520 | protocol: dtls, |
| 1521 | testType: serverTest, |
| 1522 | name: "DoubleAlert-DTLS", |
| 1523 | config: Config{ |
| 1524 | Bugs: ProtocolBugs{ |
| 1525 | DoubleAlert: true, |
| 1526 | SendSpuriousAlert: alertRecordOverflow, |
| 1527 | }, |
| 1528 | }, |
| 1529 | shouldFail: true, |
| 1530 | expectedError: ":BAD_ALERT:", |
| 1531 | }, |
| 1532 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1533 | name: "SkipNewSessionTicket", |
| 1534 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1535 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1536 | Bugs: ProtocolBugs{ |
| 1537 | SkipNewSessionTicket: true, |
| 1538 | }, |
| 1539 | }, |
| 1540 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1541 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1542 | }, |
| 1543 | { |
| 1544 | testType: serverTest, |
| 1545 | name: "FallbackSCSV", |
| 1546 | config: Config{ |
| 1547 | MaxVersion: VersionTLS11, |
| 1548 | Bugs: ProtocolBugs{ |
| 1549 | SendFallbackSCSV: true, |
| 1550 | }, |
| 1551 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1552 | shouldFail: true, |
| 1553 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1554 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1555 | }, |
| 1556 | { |
| 1557 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1558 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1559 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1560 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1561 | Bugs: ProtocolBugs{ |
| 1562 | SendFallbackSCSV: true, |
| 1563 | }, |
| 1564 | }, |
| 1565 | }, |
| 1566 | { |
| 1567 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1568 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1569 | config: Config{ |
| 1570 | MaxVersion: VersionTLS12, |
| 1571 | Bugs: ProtocolBugs{ |
| 1572 | SendFallbackSCSV: true, |
| 1573 | }, |
| 1574 | }, |
| 1575 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1576 | }, |
| 1577 | { |
| 1578 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1579 | name: "FragmentedClientVersion", |
| 1580 | config: Config{ |
| 1581 | Bugs: ProtocolBugs{ |
| 1582 | MaxHandshakeRecordLength: 1, |
| 1583 | FragmentClientVersion: true, |
| 1584 | }, |
| 1585 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1586 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1587 | }, |
| 1588 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1589 | testType: serverTest, |
| 1590 | name: "HttpGET", |
| 1591 | sendPrefix: "GET / HTTP/1.0\n", |
| 1592 | shouldFail: true, |
| 1593 | expectedError: ":HTTP_REQUEST:", |
| 1594 | }, |
| 1595 | { |
| 1596 | testType: serverTest, |
| 1597 | name: "HttpPOST", |
| 1598 | sendPrefix: "POST / HTTP/1.0\n", |
| 1599 | shouldFail: true, |
| 1600 | expectedError: ":HTTP_REQUEST:", |
| 1601 | }, |
| 1602 | { |
| 1603 | testType: serverTest, |
| 1604 | name: "HttpHEAD", |
| 1605 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1606 | shouldFail: true, |
| 1607 | expectedError: ":HTTP_REQUEST:", |
| 1608 | }, |
| 1609 | { |
| 1610 | testType: serverTest, |
| 1611 | name: "HttpPUT", |
| 1612 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1613 | shouldFail: true, |
| 1614 | expectedError: ":HTTP_REQUEST:", |
| 1615 | }, |
| 1616 | { |
| 1617 | testType: serverTest, |
| 1618 | name: "HttpCONNECT", |
| 1619 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1620 | shouldFail: true, |
| 1621 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1622 | }, |
| 1623 | { |
| 1624 | testType: serverTest, |
| 1625 | name: "Garbage", |
| 1626 | sendPrefix: "blah", |
| 1627 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1628 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1629 | }, |
| 1630 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1631 | name: "RSAEphemeralKey", |
| 1632 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1633 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1634 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1635 | Bugs: ProtocolBugs{ |
| 1636 | RSAEphemeralKey: true, |
| 1637 | }, |
| 1638 | }, |
| 1639 | shouldFail: true, |
| 1640 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1641 | }, |
| 1642 | { |
| 1643 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1644 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1645 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1646 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1647 | }, |
| 1648 | { |
| 1649 | protocol: dtls, |
| 1650 | name: "DisableEverything-DTLS", |
| 1651 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1652 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1653 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1654 | }, |
| 1655 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1656 | protocol: dtls, |
| 1657 | testType: serverTest, |
| 1658 | name: "MTU", |
| 1659 | config: Config{ |
| 1660 | Bugs: ProtocolBugs{ |
| 1661 | MaxPacketLength: 256, |
| 1662 | }, |
| 1663 | }, |
| 1664 | flags: []string{"-mtu", "256"}, |
| 1665 | }, |
| 1666 | { |
| 1667 | protocol: dtls, |
| 1668 | testType: serverTest, |
| 1669 | name: "MTUExceeded", |
| 1670 | config: Config{ |
| 1671 | Bugs: ProtocolBugs{ |
| 1672 | MaxPacketLength: 255, |
| 1673 | }, |
| 1674 | }, |
| 1675 | flags: []string{"-mtu", "256"}, |
| 1676 | shouldFail: true, |
| 1677 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1678 | }, |
| 1679 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1680 | name: "EmptyCertificateList", |
| 1681 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1682 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1683 | Bugs: ProtocolBugs{ |
| 1684 | EmptyCertificateList: true, |
| 1685 | }, |
| 1686 | }, |
| 1687 | shouldFail: true, |
| 1688 | expectedError: ":DECODE_ERROR:", |
| 1689 | }, |
| 1690 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1691 | name: "EmptyCertificateList-TLS13", |
| 1692 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1693 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1694 | Bugs: ProtocolBugs{ |
| 1695 | EmptyCertificateList: true, |
| 1696 | }, |
| 1697 | }, |
| 1698 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1699 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1700 | }, |
| 1701 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1702 | name: "TLSFatalBadPackets", |
| 1703 | damageFirstWrite: true, |
| 1704 | shouldFail: true, |
| 1705 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1706 | }, |
| 1707 | { |
| 1708 | protocol: dtls, |
| 1709 | name: "DTLSIgnoreBadPackets", |
| 1710 | damageFirstWrite: true, |
| 1711 | }, |
| 1712 | { |
| 1713 | protocol: dtls, |
| 1714 | name: "DTLSIgnoreBadPackets-Async", |
| 1715 | damageFirstWrite: true, |
| 1716 | flags: []string{"-async"}, |
| 1717 | }, |
| 1718 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1719 | name: "AppDataBeforeHandshake", |
| 1720 | config: Config{ |
| 1721 | Bugs: ProtocolBugs{ |
| 1722 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1723 | }, |
| 1724 | }, |
| 1725 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1726 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1727 | }, |
| 1728 | { |
| 1729 | name: "AppDataBeforeHandshake-Empty", |
| 1730 | config: Config{ |
| 1731 | Bugs: ProtocolBugs{ |
| 1732 | AppDataBeforeHandshake: []byte{}, |
| 1733 | }, |
| 1734 | }, |
| 1735 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1736 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1737 | }, |
| 1738 | { |
| 1739 | protocol: dtls, |
| 1740 | name: "AppDataBeforeHandshake-DTLS", |
| 1741 | config: Config{ |
| 1742 | Bugs: ProtocolBugs{ |
| 1743 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1744 | }, |
| 1745 | }, |
| 1746 | shouldFail: true, |
| 1747 | expectedError: ":UNEXPECTED_RECORD:", |
| 1748 | }, |
| 1749 | { |
| 1750 | protocol: dtls, |
| 1751 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1752 | config: Config{ |
| 1753 | Bugs: ProtocolBugs{ |
| 1754 | AppDataBeforeHandshake: []byte{}, |
| 1755 | }, |
| 1756 | }, |
| 1757 | shouldFail: true, |
| 1758 | expectedError: ":UNEXPECTED_RECORD:", |
| 1759 | }, |
| 1760 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1761 | name: "AppDataAfterChangeCipherSpec", |
| 1762 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1763 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1764 | Bugs: ProtocolBugs{ |
| 1765 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1766 | }, |
| 1767 | }, |
| 1768 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1769 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1770 | }, |
| 1771 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1772 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1773 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1774 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1775 | Bugs: ProtocolBugs{ |
| 1776 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1777 | }, |
| 1778 | }, |
| 1779 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1780 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1781 | }, |
| 1782 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1783 | protocol: dtls, |
| 1784 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1785 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1786 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1787 | Bugs: ProtocolBugs{ |
| 1788 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1789 | }, |
| 1790 | }, |
| 1791 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1792 | // application data. |
| 1793 | }, |
| 1794 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1795 | protocol: dtls, |
| 1796 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1797 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1798 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1799 | Bugs: ProtocolBugs{ |
| 1800 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1801 | }, |
| 1802 | }, |
| 1803 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1804 | // application data. |
| 1805 | }, |
| 1806 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1807 | name: "AlertAfterChangeCipherSpec", |
| 1808 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1809 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1810 | Bugs: ProtocolBugs{ |
| 1811 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1812 | }, |
| 1813 | }, |
| 1814 | shouldFail: true, |
| 1815 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1816 | }, |
| 1817 | { |
| 1818 | protocol: dtls, |
| 1819 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1820 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1821 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1822 | Bugs: ProtocolBugs{ |
| 1823 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1824 | }, |
| 1825 | }, |
| 1826 | shouldFail: true, |
| 1827 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1828 | }, |
| 1829 | { |
| 1830 | protocol: dtls, |
| 1831 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1832 | config: Config{ |
| 1833 | Bugs: ProtocolBugs{ |
| 1834 | ReorderHandshakeFragments: true, |
| 1835 | // Small enough that every handshake message is |
| 1836 | // fragmented. |
| 1837 | MaxHandshakeRecordLength: 2, |
| 1838 | }, |
| 1839 | }, |
| 1840 | }, |
| 1841 | { |
| 1842 | protocol: dtls, |
| 1843 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1844 | config: Config{ |
| 1845 | Bugs: ProtocolBugs{ |
| 1846 | ReorderHandshakeFragments: true, |
| 1847 | // Large enough that no handshake message is |
| 1848 | // fragmented. |
| 1849 | MaxHandshakeRecordLength: 2048, |
| 1850 | }, |
| 1851 | }, |
| 1852 | }, |
| 1853 | { |
| 1854 | protocol: dtls, |
| 1855 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1856 | config: Config{ |
| 1857 | Bugs: ProtocolBugs{ |
| 1858 | ReorderHandshakeFragments: true, |
| 1859 | MixCompleteMessageWithFragments: true, |
| 1860 | MaxHandshakeRecordLength: 2, |
| 1861 | }, |
| 1862 | }, |
| 1863 | }, |
| 1864 | { |
| 1865 | name: "SendInvalidRecordType", |
| 1866 | config: Config{ |
| 1867 | Bugs: ProtocolBugs{ |
| 1868 | SendInvalidRecordType: true, |
| 1869 | }, |
| 1870 | }, |
| 1871 | shouldFail: true, |
| 1872 | expectedError: ":UNEXPECTED_RECORD:", |
| 1873 | }, |
| 1874 | { |
| 1875 | protocol: dtls, |
| 1876 | name: "SendInvalidRecordType-DTLS", |
| 1877 | config: Config{ |
| 1878 | Bugs: ProtocolBugs{ |
| 1879 | SendInvalidRecordType: true, |
| 1880 | }, |
| 1881 | }, |
| 1882 | shouldFail: true, |
| 1883 | expectedError: ":UNEXPECTED_RECORD:", |
| 1884 | }, |
| 1885 | { |
| 1886 | name: "FalseStart-SkipServerSecondLeg", |
| 1887 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1888 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1889 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1890 | NextProtos: []string{"foo"}, |
| 1891 | Bugs: ProtocolBugs{ |
| 1892 | SkipNewSessionTicket: true, |
| 1893 | SkipChangeCipherSpec: true, |
| 1894 | SkipFinished: true, |
| 1895 | ExpectFalseStart: true, |
| 1896 | }, |
| 1897 | }, |
| 1898 | flags: []string{ |
| 1899 | "-false-start", |
| 1900 | "-handshake-never-done", |
| 1901 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1902 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1903 | }, |
| 1904 | shimWritesFirst: true, |
| 1905 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1906 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1907 | }, |
| 1908 | { |
| 1909 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1910 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1911 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1912 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1913 | NextProtos: []string{"foo"}, |
| 1914 | Bugs: ProtocolBugs{ |
| 1915 | SkipNewSessionTicket: true, |
| 1916 | SkipChangeCipherSpec: true, |
| 1917 | SkipFinished: true, |
| 1918 | }, |
| 1919 | }, |
| 1920 | flags: []string{ |
| 1921 | "-implicit-handshake", |
| 1922 | "-false-start", |
| 1923 | "-handshake-never-done", |
| 1924 | "-advertise-alpn", "\x03foo", |
| 1925 | }, |
| 1926 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1927 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1928 | }, |
| 1929 | { |
| 1930 | testType: serverTest, |
| 1931 | name: "FailEarlyCallback", |
| 1932 | flags: []string{"-fail-early-callback"}, |
| 1933 | shouldFail: true, |
| 1934 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1935 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1936 | }, |
| 1937 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1938 | name: "FailCertCallback-Client-TLS12", |
| 1939 | config: Config{ |
| 1940 | MaxVersion: VersionTLS12, |
| 1941 | ClientAuth: RequestClientCert, |
| 1942 | }, |
| 1943 | flags: []string{"-fail-cert-callback"}, |
| 1944 | shouldFail: true, |
| 1945 | expectedError: ":CERT_CB_ERROR:", |
| 1946 | expectedLocalError: "remote error: internal error", |
| 1947 | }, |
| 1948 | { |
| 1949 | testType: serverTest, |
| 1950 | name: "FailCertCallback-Server-TLS12", |
| 1951 | config: Config{ |
| 1952 | MaxVersion: VersionTLS12, |
| 1953 | }, |
| 1954 | flags: []string{"-fail-cert-callback"}, |
| 1955 | shouldFail: true, |
| 1956 | expectedError: ":CERT_CB_ERROR:", |
| 1957 | expectedLocalError: "remote error: internal error", |
| 1958 | }, |
| 1959 | { |
| 1960 | name: "FailCertCallback-Client-TLS13", |
| 1961 | config: Config{ |
| 1962 | MaxVersion: VersionTLS13, |
| 1963 | ClientAuth: RequestClientCert, |
| 1964 | }, |
| 1965 | flags: []string{"-fail-cert-callback"}, |
| 1966 | shouldFail: true, |
| 1967 | expectedError: ":CERT_CB_ERROR:", |
| 1968 | expectedLocalError: "remote error: internal error", |
| 1969 | }, |
| 1970 | { |
| 1971 | testType: serverTest, |
| 1972 | name: "FailCertCallback-Server-TLS13", |
| 1973 | config: Config{ |
| 1974 | MaxVersion: VersionTLS13, |
| 1975 | }, |
| 1976 | flags: []string{"-fail-cert-callback"}, |
| 1977 | shouldFail: true, |
| 1978 | expectedError: ":CERT_CB_ERROR:", |
| 1979 | expectedLocalError: "remote error: internal error", |
| 1980 | }, |
| 1981 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1982 | protocol: dtls, |
| 1983 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1984 | config: Config{ |
| 1985 | Bugs: ProtocolBugs{ |
| 1986 | MaxHandshakeRecordLength: 2, |
| 1987 | FragmentMessageTypeMismatch: true, |
| 1988 | }, |
| 1989 | }, |
| 1990 | shouldFail: true, |
| 1991 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1992 | }, |
| 1993 | { |
| 1994 | protocol: dtls, |
| 1995 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1996 | config: Config{ |
| 1997 | Bugs: ProtocolBugs{ |
| 1998 | MaxHandshakeRecordLength: 2, |
| 1999 | FragmentMessageLengthMismatch: true, |
| 2000 | }, |
| 2001 | }, |
| 2002 | shouldFail: true, |
| 2003 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2004 | }, |
| 2005 | { |
| 2006 | protocol: dtls, |
| 2007 | name: "SplitFragments-Header-DTLS", |
| 2008 | config: Config{ |
| 2009 | Bugs: ProtocolBugs{ |
| 2010 | SplitFragments: 2, |
| 2011 | }, |
| 2012 | }, |
| 2013 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2014 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2015 | }, |
| 2016 | { |
| 2017 | protocol: dtls, |
| 2018 | name: "SplitFragments-Boundary-DTLS", |
| 2019 | config: Config{ |
| 2020 | Bugs: ProtocolBugs{ |
| 2021 | SplitFragments: dtlsRecordHeaderLen, |
| 2022 | }, |
| 2023 | }, |
| 2024 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2025 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2026 | }, |
| 2027 | { |
| 2028 | protocol: dtls, |
| 2029 | name: "SplitFragments-Body-DTLS", |
| 2030 | config: Config{ |
| 2031 | Bugs: ProtocolBugs{ |
| 2032 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 2033 | }, |
| 2034 | }, |
| 2035 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2036 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2037 | }, |
| 2038 | { |
| 2039 | protocol: dtls, |
| 2040 | name: "SendEmptyFragments-DTLS", |
| 2041 | config: Config{ |
| 2042 | Bugs: ProtocolBugs{ |
| 2043 | SendEmptyFragments: true, |
| 2044 | }, |
| 2045 | }, |
| 2046 | }, |
| 2047 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2048 | name: "BadFinished-Client", |
| 2049 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2050 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2051 | Bugs: ProtocolBugs{ |
| 2052 | BadFinished: true, |
| 2053 | }, |
| 2054 | }, |
| 2055 | shouldFail: true, |
| 2056 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2057 | }, |
| 2058 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2059 | name: "BadFinished-Client-TLS13", |
| 2060 | config: Config{ |
| 2061 | MaxVersion: VersionTLS13, |
| 2062 | Bugs: ProtocolBugs{ |
| 2063 | BadFinished: true, |
| 2064 | }, |
| 2065 | }, |
| 2066 | shouldFail: true, |
| 2067 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2068 | }, |
| 2069 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2070 | testType: serverTest, |
| 2071 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2072 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2073 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2074 | Bugs: ProtocolBugs{ |
| 2075 | BadFinished: true, |
| 2076 | }, |
| 2077 | }, |
| 2078 | shouldFail: true, |
| 2079 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2080 | }, |
| 2081 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2082 | testType: serverTest, |
| 2083 | name: "BadFinished-Server-TLS13", |
| 2084 | config: Config{ |
| 2085 | MaxVersion: VersionTLS13, |
| 2086 | Bugs: ProtocolBugs{ |
| 2087 | BadFinished: true, |
| 2088 | }, |
| 2089 | }, |
| 2090 | shouldFail: true, |
| 2091 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2092 | }, |
| 2093 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2094 | name: "FalseStart-BadFinished", |
| 2095 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2096 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2097 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2098 | NextProtos: []string{"foo"}, |
| 2099 | Bugs: ProtocolBugs{ |
| 2100 | BadFinished: true, |
| 2101 | ExpectFalseStart: true, |
| 2102 | }, |
| 2103 | }, |
| 2104 | flags: []string{ |
| 2105 | "-false-start", |
| 2106 | "-handshake-never-done", |
| 2107 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 2108 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2109 | }, |
| 2110 | shimWritesFirst: true, |
| 2111 | shouldFail: true, |
| 2112 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2113 | }, |
| 2114 | { |
| 2115 | name: "NoFalseStart-NoALPN", |
| 2116 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2117 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2118 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2119 | Bugs: ProtocolBugs{ |
| 2120 | ExpectFalseStart: true, |
| 2121 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2122 | }, |
| 2123 | }, |
| 2124 | flags: []string{ |
| 2125 | "-false-start", |
| 2126 | }, |
| 2127 | shimWritesFirst: true, |
| 2128 | shouldFail: true, |
| 2129 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2130 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2131 | }, |
| 2132 | { |
| 2133 | name: "NoFalseStart-NoAEAD", |
| 2134 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2135 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2136 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2137 | NextProtos: []string{"foo"}, |
| 2138 | Bugs: ProtocolBugs{ |
| 2139 | ExpectFalseStart: true, |
| 2140 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2141 | }, |
| 2142 | }, |
| 2143 | flags: []string{ |
| 2144 | "-false-start", |
| 2145 | "-advertise-alpn", "\x03foo", |
| 2146 | }, |
| 2147 | shimWritesFirst: true, |
| 2148 | shouldFail: true, |
| 2149 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2150 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2151 | }, |
| 2152 | { |
| 2153 | name: "NoFalseStart-RSA", |
| 2154 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2155 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2156 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2157 | NextProtos: []string{"foo"}, |
| 2158 | Bugs: ProtocolBugs{ |
| 2159 | ExpectFalseStart: true, |
| 2160 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2161 | }, |
| 2162 | }, |
| 2163 | flags: []string{ |
| 2164 | "-false-start", |
| 2165 | "-advertise-alpn", "\x03foo", |
| 2166 | }, |
| 2167 | shimWritesFirst: true, |
| 2168 | shouldFail: true, |
| 2169 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2170 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2171 | }, |
| 2172 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2173 | protocol: dtls, |
| 2174 | name: "SendSplitAlert-Sync", |
| 2175 | config: Config{ |
| 2176 | Bugs: ProtocolBugs{ |
| 2177 | SendSplitAlert: true, |
| 2178 | }, |
| 2179 | }, |
| 2180 | }, |
| 2181 | { |
| 2182 | protocol: dtls, |
| 2183 | name: "SendSplitAlert-Async", |
| 2184 | config: Config{ |
| 2185 | Bugs: ProtocolBugs{ |
| 2186 | SendSplitAlert: true, |
| 2187 | }, |
| 2188 | }, |
| 2189 | flags: []string{"-async"}, |
| 2190 | }, |
| 2191 | { |
| 2192 | protocol: dtls, |
| 2193 | name: "PackDTLSHandshake", |
| 2194 | config: Config{ |
| 2195 | Bugs: ProtocolBugs{ |
| 2196 | MaxHandshakeRecordLength: 2, |
| 2197 | PackHandshakeFragments: 20, |
| 2198 | PackHandshakeRecords: 200, |
| 2199 | }, |
| 2200 | }, |
| 2201 | }, |
| 2202 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2203 | name: "SendEmptyRecords-Pass", |
| 2204 | sendEmptyRecords: 32, |
| 2205 | }, |
| 2206 | { |
| 2207 | name: "SendEmptyRecords", |
| 2208 | sendEmptyRecords: 33, |
| 2209 | shouldFail: true, |
| 2210 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2211 | }, |
| 2212 | { |
| 2213 | name: "SendEmptyRecords-Async", |
| 2214 | sendEmptyRecords: 33, |
| 2215 | flags: []string{"-async"}, |
| 2216 | shouldFail: true, |
| 2217 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2218 | }, |
| 2219 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2220 | name: "SendWarningAlerts-Pass", |
| 2221 | config: Config{ |
| 2222 | MaxVersion: VersionTLS12, |
| 2223 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2224 | sendWarningAlerts: 4, |
| 2225 | }, |
| 2226 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2227 | protocol: dtls, |
| 2228 | name: "SendWarningAlerts-DTLS-Pass", |
| 2229 | config: Config{ |
| 2230 | MaxVersion: VersionTLS12, |
| 2231 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2232 | sendWarningAlerts: 4, |
| 2233 | }, |
| 2234 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2235 | name: "SendWarningAlerts-TLS13", |
| 2236 | config: Config{ |
| 2237 | MaxVersion: VersionTLS13, |
| 2238 | }, |
| 2239 | sendWarningAlerts: 4, |
| 2240 | shouldFail: true, |
| 2241 | expectedError: ":BAD_ALERT:", |
| 2242 | expectedLocalError: "remote error: error decoding message", |
| 2243 | }, |
| 2244 | { |
| 2245 | name: "SendWarningAlerts", |
| 2246 | config: Config{ |
| 2247 | MaxVersion: VersionTLS12, |
| 2248 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2249 | sendWarningAlerts: 5, |
| 2250 | shouldFail: true, |
| 2251 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2252 | }, |
| 2253 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2254 | name: "SendWarningAlerts-Async", |
| 2255 | config: Config{ |
| 2256 | MaxVersion: VersionTLS12, |
| 2257 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2258 | sendWarningAlerts: 5, |
| 2259 | flags: []string{"-async"}, |
| 2260 | shouldFail: true, |
| 2261 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2262 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2263 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2264 | name: "SendBogusAlertType", |
| 2265 | sendBogusAlertType: true, |
| 2266 | shouldFail: true, |
| 2267 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2268 | expectedLocalError: "remote error: illegal parameter", |
| 2269 | }, |
| 2270 | { |
| 2271 | protocol: dtls, |
| 2272 | name: "SendBogusAlertType-DTLS", |
| 2273 | sendBogusAlertType: true, |
| 2274 | shouldFail: true, |
| 2275 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2276 | expectedLocalError: "remote error: illegal parameter", |
| 2277 | }, |
| 2278 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2279 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2280 | config: Config{ |
| 2281 | MaxVersion: VersionTLS13, |
| 2282 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2283 | sendKeyUpdates: 33, |
| 2284 | keyUpdateRequest: keyUpdateNotRequested, |
| 2285 | shouldFail: true, |
| 2286 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2287 | }, |
| 2288 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2289 | name: "EmptySessionID", |
| 2290 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2291 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2292 | SessionTicketsDisabled: true, |
| 2293 | }, |
| 2294 | noSessionCache: true, |
| 2295 | flags: []string{"-expect-no-session"}, |
| 2296 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2297 | { |
| 2298 | name: "Unclean-Shutdown", |
| 2299 | config: Config{ |
| 2300 | Bugs: ProtocolBugs{ |
| 2301 | NoCloseNotify: true, |
| 2302 | ExpectCloseNotify: true, |
| 2303 | }, |
| 2304 | }, |
| 2305 | shimShutsDown: true, |
| 2306 | flags: []string{"-check-close-notify"}, |
| 2307 | shouldFail: true, |
| 2308 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2309 | }, |
| 2310 | { |
| 2311 | name: "Unclean-Shutdown-Ignored", |
| 2312 | config: Config{ |
| 2313 | Bugs: ProtocolBugs{ |
| 2314 | NoCloseNotify: true, |
| 2315 | }, |
| 2316 | }, |
| 2317 | shimShutsDown: true, |
| 2318 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2319 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2320 | name: "Unclean-Shutdown-Alert", |
| 2321 | config: Config{ |
| 2322 | Bugs: ProtocolBugs{ |
| 2323 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2324 | ExpectCloseNotify: true, |
| 2325 | }, |
| 2326 | }, |
| 2327 | shimShutsDown: true, |
| 2328 | flags: []string{"-check-close-notify"}, |
| 2329 | shouldFail: true, |
| 2330 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2331 | }, |
| 2332 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2333 | name: "LargePlaintext", |
| 2334 | config: Config{ |
| 2335 | Bugs: ProtocolBugs{ |
| 2336 | SendLargeRecords: true, |
| 2337 | }, |
| 2338 | }, |
| 2339 | messageLen: maxPlaintext + 1, |
| 2340 | shouldFail: true, |
| 2341 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2342 | }, |
| 2343 | { |
| 2344 | protocol: dtls, |
| 2345 | name: "LargePlaintext-DTLS", |
| 2346 | config: Config{ |
| 2347 | Bugs: ProtocolBugs{ |
| 2348 | SendLargeRecords: true, |
| 2349 | }, |
| 2350 | }, |
| 2351 | messageLen: maxPlaintext + 1, |
| 2352 | shouldFail: true, |
| 2353 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2354 | }, |
| 2355 | { |
| 2356 | name: "LargeCiphertext", |
| 2357 | config: Config{ |
| 2358 | Bugs: ProtocolBugs{ |
| 2359 | SendLargeRecords: true, |
| 2360 | }, |
| 2361 | }, |
| 2362 | messageLen: maxPlaintext * 2, |
| 2363 | shouldFail: true, |
| 2364 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2365 | }, |
| 2366 | { |
| 2367 | protocol: dtls, |
| 2368 | name: "LargeCiphertext-DTLS", |
| 2369 | config: Config{ |
| 2370 | Bugs: ProtocolBugs{ |
| 2371 | SendLargeRecords: true, |
| 2372 | }, |
| 2373 | }, |
| 2374 | messageLen: maxPlaintext * 2, |
| 2375 | // Unlike the other four cases, DTLS drops records which |
| 2376 | // are invalid before authentication, so the connection |
| 2377 | // does not fail. |
| 2378 | expectMessageDropped: true, |
| 2379 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2380 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2381 | name: "BadHelloRequest-1", |
| 2382 | renegotiate: 1, |
| 2383 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2384 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2385 | Bugs: ProtocolBugs{ |
| 2386 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2387 | }, |
| 2388 | }, |
| 2389 | flags: []string{ |
| 2390 | "-renegotiate-freely", |
| 2391 | "-expect-total-renegotiations", "1", |
| 2392 | }, |
| 2393 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2394 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2395 | }, |
| 2396 | { |
| 2397 | name: "BadHelloRequest-2", |
| 2398 | renegotiate: 1, |
| 2399 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2400 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2401 | Bugs: ProtocolBugs{ |
| 2402 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2403 | }, |
| 2404 | }, |
| 2405 | flags: []string{ |
| 2406 | "-renegotiate-freely", |
| 2407 | "-expect-total-renegotiations", "1", |
| 2408 | }, |
| 2409 | shouldFail: true, |
| 2410 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2411 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2412 | { |
| 2413 | testType: serverTest, |
| 2414 | name: "SupportTicketsWithSessionID", |
| 2415 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2416 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2417 | SessionTicketsDisabled: true, |
| 2418 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2419 | resumeConfig: &Config{ |
| 2420 | MaxVersion: VersionTLS12, |
| 2421 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2422 | resumeSession: true, |
| 2423 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2424 | { |
| 2425 | protocol: dtls, |
| 2426 | name: "DTLS-SendExtraFinished", |
| 2427 | config: Config{ |
| 2428 | Bugs: ProtocolBugs{ |
| 2429 | SendExtraFinished: true, |
| 2430 | }, |
| 2431 | }, |
| 2432 | shouldFail: true, |
| 2433 | expectedError: ":UNEXPECTED_RECORD:", |
| 2434 | }, |
| 2435 | { |
| 2436 | protocol: dtls, |
| 2437 | name: "DTLS-SendExtraFinished-Reordered", |
| 2438 | config: Config{ |
| 2439 | Bugs: ProtocolBugs{ |
| 2440 | MaxHandshakeRecordLength: 2, |
| 2441 | ReorderHandshakeFragments: true, |
| 2442 | SendExtraFinished: true, |
| 2443 | }, |
| 2444 | }, |
| 2445 | shouldFail: true, |
| 2446 | expectedError: ":UNEXPECTED_RECORD:", |
| 2447 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2448 | { |
| 2449 | testType: serverTest, |
| 2450 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2451 | config: Config{ |
| 2452 | // Choose a cipher suite that does not involve |
| 2453 | // elliptic curves, so no extensions are |
| 2454 | // involved. |
| 2455 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2456 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2457 | Bugs: ProtocolBugs{ |
| 2458 | SendV2ClientHello: true, |
| 2459 | }, |
| 2460 | }, |
| 2461 | sendPrefix: string([]byte{ |
| 2462 | byte(recordTypeHandshake), |
| 2463 | 3, 1, // version |
| 2464 | 0, 0, // length |
| 2465 | }), |
| 2466 | // A no-op empty record may not be sent before V2ClientHello. |
| 2467 | shouldFail: true, |
| 2468 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2469 | }, |
| 2470 | { |
| 2471 | testType: serverTest, |
| 2472 | name: "V2ClientHello-WarningAlertPrefix", |
| 2473 | config: Config{ |
| 2474 | // Choose a cipher suite that does not involve |
| 2475 | // elliptic curves, so no extensions are |
| 2476 | // involved. |
| 2477 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2478 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2479 | Bugs: ProtocolBugs{ |
| 2480 | SendV2ClientHello: true, |
| 2481 | }, |
| 2482 | }, |
| 2483 | sendPrefix: string([]byte{ |
| 2484 | byte(recordTypeAlert), |
| 2485 | 3, 1, // version |
| 2486 | 0, 2, // length |
| 2487 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2488 | }), |
| 2489 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2490 | shouldFail: true, |
| 2491 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2492 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2493 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2494 | name: "KeyUpdate-Client", |
| 2495 | config: Config{ |
| 2496 | MaxVersion: VersionTLS13, |
| 2497 | }, |
| 2498 | sendKeyUpdates: 1, |
| 2499 | keyUpdateRequest: keyUpdateNotRequested, |
| 2500 | }, |
| 2501 | { |
| 2502 | testType: serverTest, |
| 2503 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2504 | config: Config{ |
| 2505 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2506 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2507 | sendKeyUpdates: 1, |
| 2508 | keyUpdateRequest: keyUpdateNotRequested, |
| 2509 | }, |
| 2510 | { |
| 2511 | name: "KeyUpdate-InvalidRequestMode", |
| 2512 | config: Config{ |
| 2513 | MaxVersion: VersionTLS13, |
| 2514 | }, |
| 2515 | sendKeyUpdates: 1, |
| 2516 | keyUpdateRequest: 42, |
| 2517 | shouldFail: true, |
| 2518 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2519 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2520 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2521 | // Test that KeyUpdates are acknowledged properly. |
| 2522 | name: "KeyUpdate-RequestACK", |
| 2523 | config: Config{ |
| 2524 | MaxVersion: VersionTLS13, |
| 2525 | Bugs: ProtocolBugs{ |
| 2526 | RejectUnsolicitedKeyUpdate: true, |
| 2527 | }, |
| 2528 | }, |
| 2529 | // Test the shim receiving many KeyUpdates in a row. |
| 2530 | sendKeyUpdates: 5, |
| 2531 | messageCount: 5, |
| 2532 | keyUpdateRequest: keyUpdateRequested, |
| 2533 | }, |
| 2534 | { |
| 2535 | // Test that KeyUpdates are acknowledged properly if the |
| 2536 | // peer's KeyUpdate is discovered while a write is |
| 2537 | // pending. |
| 2538 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2539 | config: Config{ |
| 2540 | MaxVersion: VersionTLS13, |
| 2541 | Bugs: ProtocolBugs{ |
| 2542 | RejectUnsolicitedKeyUpdate: true, |
| 2543 | }, |
| 2544 | }, |
| 2545 | // Test the shim receiving many KeyUpdates in a row. |
| 2546 | sendKeyUpdates: 5, |
| 2547 | messageCount: 5, |
| 2548 | keyUpdateRequest: keyUpdateRequested, |
| 2549 | readWithUnfinishedWrite: true, |
| 2550 | flags: []string{"-async"}, |
| 2551 | }, |
| 2552 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2553 | name: "SendSNIWarningAlert", |
| 2554 | config: Config{ |
| 2555 | MaxVersion: VersionTLS12, |
| 2556 | Bugs: ProtocolBugs{ |
| 2557 | SendSNIWarningAlert: true, |
| 2558 | }, |
| 2559 | }, |
| 2560 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2561 | { |
| 2562 | testType: serverTest, |
| 2563 | name: "ExtraCompressionMethods-TLS12", |
| 2564 | config: Config{ |
| 2565 | MaxVersion: VersionTLS12, |
| 2566 | Bugs: ProtocolBugs{ |
| 2567 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2568 | }, |
| 2569 | }, |
| 2570 | }, |
| 2571 | { |
| 2572 | testType: serverTest, |
| 2573 | name: "ExtraCompressionMethods-TLS13", |
| 2574 | config: Config{ |
| 2575 | MaxVersion: VersionTLS13, |
| 2576 | Bugs: ProtocolBugs{ |
| 2577 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2578 | }, |
| 2579 | }, |
| 2580 | shouldFail: true, |
| 2581 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2582 | expectedLocalError: "remote error: illegal parameter", |
| 2583 | }, |
| 2584 | { |
| 2585 | testType: serverTest, |
| 2586 | name: "NoNullCompression-TLS12", |
| 2587 | config: Config{ |
| 2588 | MaxVersion: VersionTLS12, |
| 2589 | Bugs: ProtocolBugs{ |
| 2590 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2591 | }, |
| 2592 | }, |
| 2593 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2594 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2595 | expectedLocalError: "remote error: illegal parameter", |
| 2596 | }, |
| 2597 | { |
| 2598 | testType: serverTest, |
| 2599 | name: "NoNullCompression-TLS13", |
| 2600 | config: Config{ |
| 2601 | MaxVersion: VersionTLS13, |
| 2602 | Bugs: ProtocolBugs{ |
| 2603 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2604 | }, |
| 2605 | }, |
| 2606 | shouldFail: true, |
| 2607 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2608 | expectedLocalError: "remote error: illegal parameter", |
| 2609 | }, |
David Benjamin | 413e79e | 2017-07-01 10:11:53 -0400 | [diff] [blame] | 2610 | // Test that the client rejects invalid compression methods |
| 2611 | // from the server. |
| 2612 | { |
| 2613 | testType: clientTest, |
| 2614 | name: "InvalidCompressionMethod", |
| 2615 | config: Config{ |
| 2616 | MaxVersion: VersionTLS12, |
| 2617 | Bugs: ProtocolBugs{ |
| 2618 | SendCompressionMethod: 1, |
| 2619 | }, |
| 2620 | }, |
| 2621 | shouldFail: true, |
| 2622 | expectedError: ":UNSUPPORTED_COMPRESSION_ALGORITHM:", |
| 2623 | expectedLocalError: "remote error: illegal parameter", |
| 2624 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2625 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2626 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2627 | config: Config{ |
| 2628 | MaxVersion: VersionTLS12, |
| 2629 | Bugs: ProtocolBugs{ |
| 2630 | ExpectGREASE: true, |
| 2631 | }, |
| 2632 | }, |
| 2633 | flags: []string{"-enable-grease"}, |
| 2634 | }, |
| 2635 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2636 | name: "GREASE-Client-TLS13", |
| 2637 | config: Config{ |
| 2638 | MaxVersion: VersionTLS13, |
| 2639 | Bugs: ProtocolBugs{ |
| 2640 | ExpectGREASE: true, |
| 2641 | }, |
| 2642 | }, |
| 2643 | flags: []string{"-enable-grease"}, |
| 2644 | }, |
| 2645 | { |
| 2646 | testType: serverTest, |
| 2647 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2648 | config: Config{ |
| 2649 | MaxVersion: VersionTLS13, |
| 2650 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2651 | // TLS 1.3 servers are expected to |
| 2652 | // always enable GREASE. TLS 1.3 is new, |
| 2653 | // so there is no existing ecosystem to |
| 2654 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2655 | ExpectGREASE: true, |
| 2656 | }, |
| 2657 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2658 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2659 | { |
| 2660 | // Test the server so there is a large certificate as |
| 2661 | // well as application data. |
| 2662 | testType: serverTest, |
| 2663 | name: "MaxSendFragment", |
| 2664 | config: Config{ |
| 2665 | Bugs: ProtocolBugs{ |
| 2666 | MaxReceivePlaintext: 512, |
| 2667 | }, |
| 2668 | }, |
| 2669 | messageLen: 1024, |
| 2670 | flags: []string{ |
| 2671 | "-max-send-fragment", "512", |
| 2672 | "-read-size", "1024", |
| 2673 | }, |
| 2674 | }, |
| 2675 | { |
| 2676 | // Test the server so there is a large certificate as |
| 2677 | // well as application data. |
| 2678 | testType: serverTest, |
| 2679 | name: "MaxSendFragment-TooLarge", |
| 2680 | config: Config{ |
| 2681 | Bugs: ProtocolBugs{ |
| 2682 | // Ensure that some of the records are |
| 2683 | // 512. |
| 2684 | MaxReceivePlaintext: 511, |
| 2685 | }, |
| 2686 | }, |
| 2687 | messageLen: 1024, |
| 2688 | flags: []string{ |
| 2689 | "-max-send-fragment", "512", |
| 2690 | "-read-size", "1024", |
| 2691 | }, |
| 2692 | shouldFail: true, |
| 2693 | expectedLocalError: "local error: record overflow", |
| 2694 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2695 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2696 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2697 | |
| 2698 | // Test that very large messages can be received. |
| 2699 | cert := rsaCertificate |
| 2700 | for i := 0; i < 50; i++ { |
| 2701 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2702 | } |
| 2703 | testCases = append(testCases, testCase{ |
| 2704 | name: "LargeMessage", |
| 2705 | config: Config{ |
| 2706 | Certificates: []Certificate{cert}, |
| 2707 | }, |
| 2708 | }) |
| 2709 | testCases = append(testCases, testCase{ |
| 2710 | protocol: dtls, |
| 2711 | name: "LargeMessage-DTLS", |
| 2712 | config: Config{ |
| 2713 | Certificates: []Certificate{cert}, |
| 2714 | }, |
| 2715 | }) |
| 2716 | |
| 2717 | // They are rejected if the maximum certificate chain length is capped. |
| 2718 | testCases = append(testCases, testCase{ |
| 2719 | name: "LargeMessage-Reject", |
| 2720 | config: Config{ |
| 2721 | Certificates: []Certificate{cert}, |
| 2722 | }, |
| 2723 | flags: []string{"-max-cert-list", "16384"}, |
| 2724 | shouldFail: true, |
| 2725 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2726 | }) |
| 2727 | testCases = append(testCases, testCase{ |
| 2728 | protocol: dtls, |
| 2729 | name: "LargeMessage-Reject-DTLS", |
| 2730 | config: Config{ |
| 2731 | Certificates: []Certificate{cert}, |
| 2732 | }, |
| 2733 | flags: []string{"-max-cert-list", "16384"}, |
| 2734 | shouldFail: true, |
| 2735 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2736 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2737 | } |
| 2738 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2739 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2740 | const psk = "12345" |
| 2741 | const pskIdentity = "luggage combo" |
| 2742 | |
| 2743 | var prefix string |
| 2744 | if protocol == dtls { |
| 2745 | if !ver.hasDTLS { |
| 2746 | return |
| 2747 | } |
| 2748 | prefix = "D" |
| 2749 | } |
| 2750 | |
| 2751 | var cert Certificate |
| 2752 | var certFile string |
| 2753 | var keyFile string |
| 2754 | if hasComponent(suite.name, "ECDSA") { |
| 2755 | cert = ecdsaP256Certificate |
| 2756 | certFile = ecdsaP256CertificateFile |
| 2757 | keyFile = ecdsaP256KeyFile |
| 2758 | } else { |
| 2759 | cert = rsaCertificate |
| 2760 | certFile = rsaCertificateFile |
| 2761 | keyFile = rsaKeyFile |
| 2762 | } |
| 2763 | |
| 2764 | var flags []string |
| 2765 | if hasComponent(suite.name, "PSK") { |
| 2766 | flags = append(flags, |
| 2767 | "-psk", psk, |
| 2768 | "-psk-identity", pskIdentity) |
| 2769 | } |
| 2770 | if hasComponent(suite.name, "NULL") { |
| 2771 | // NULL ciphers must be explicitly enabled. |
| 2772 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2773 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2774 | |
| 2775 | var shouldServerFail, shouldClientFail bool |
| 2776 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2777 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2778 | // a BoringSSL server will never select it |
| 2779 | // because the extension is missing. |
| 2780 | shouldServerFail = true |
| 2781 | } |
| 2782 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2783 | shouldClientFail = true |
| 2784 | shouldServerFail = true |
| 2785 | } |
| 2786 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2787 | shouldClientFail = true |
| 2788 | shouldServerFail = true |
| 2789 | } |
| 2790 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2791 | shouldClientFail = true |
| 2792 | shouldServerFail = true |
| 2793 | } |
| 2794 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2795 | shouldClientFail = true |
| 2796 | shouldServerFail = true |
| 2797 | } |
| 2798 | |
| 2799 | var sendCipherSuite uint16 |
| 2800 | var expectedServerError, expectedClientError string |
| 2801 | serverCipherSuites := []uint16{suite.id} |
| 2802 | if shouldServerFail { |
| 2803 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2804 | } |
| 2805 | if shouldClientFail { |
| 2806 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2807 | // Configure the server to select ciphers as normal but |
| 2808 | // select an incompatible cipher in ServerHello. |
| 2809 | serverCipherSuites = nil |
| 2810 | sendCipherSuite = suite.id |
| 2811 | } |
| 2812 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2813 | // For cipher suites and versions where exporters are defined, verify |
| 2814 | // that they interoperate. |
| 2815 | var exportKeyingMaterial int |
| 2816 | if ver.version > VersionSSL30 { |
| 2817 | exportKeyingMaterial = 1024 |
| 2818 | } |
| 2819 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2820 | testCases = append(testCases, testCase{ |
| 2821 | testType: serverTest, |
| 2822 | protocol: protocol, |
| 2823 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2824 | config: Config{ |
| 2825 | MinVersion: ver.version, |
| 2826 | MaxVersion: ver.version, |
| 2827 | CipherSuites: []uint16{suite.id}, |
| 2828 | Certificates: []Certificate{cert}, |
| 2829 | PreSharedKey: []byte(psk), |
| 2830 | PreSharedKeyIdentity: pskIdentity, |
| 2831 | Bugs: ProtocolBugs{ |
| 2832 | AdvertiseAllConfiguredCiphers: true, |
| 2833 | }, |
| 2834 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2835 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2836 | certFile: certFile, |
| 2837 | keyFile: keyFile, |
| 2838 | flags: flags, |
| 2839 | resumeSession: true, |
| 2840 | shouldFail: shouldServerFail, |
| 2841 | expectedError: expectedServerError, |
| 2842 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2843 | }) |
| 2844 | |
| 2845 | testCases = append(testCases, testCase{ |
| 2846 | testType: clientTest, |
| 2847 | protocol: protocol, |
| 2848 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2849 | config: Config{ |
| 2850 | MinVersion: ver.version, |
| 2851 | MaxVersion: ver.version, |
| 2852 | CipherSuites: serverCipherSuites, |
| 2853 | Certificates: []Certificate{cert}, |
| 2854 | PreSharedKey: []byte(psk), |
| 2855 | PreSharedKeyIdentity: pskIdentity, |
| 2856 | Bugs: ProtocolBugs{ |
| 2857 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2858 | SendCipherSuite: sendCipherSuite, |
| 2859 | }, |
| 2860 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2861 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2862 | flags: flags, |
| 2863 | resumeSession: true, |
| 2864 | shouldFail: shouldClientFail, |
| 2865 | expectedError: expectedClientError, |
| 2866 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2867 | }) |
| 2868 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2869 | if shouldClientFail { |
| 2870 | return |
| 2871 | } |
| 2872 | |
| 2873 | // Ensure the maximum record size is accepted. |
| 2874 | testCases = append(testCases, testCase{ |
| 2875 | protocol: protocol, |
| 2876 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2877 | config: Config{ |
| 2878 | MinVersion: ver.version, |
| 2879 | MaxVersion: ver.version, |
| 2880 | CipherSuites: []uint16{suite.id}, |
| 2881 | Certificates: []Certificate{cert}, |
| 2882 | PreSharedKey: []byte(psk), |
| 2883 | PreSharedKeyIdentity: pskIdentity, |
| 2884 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2885 | tls13Variant: ver.tls13Variant, |
| 2886 | flags: flags, |
| 2887 | messageLen: maxPlaintext, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2888 | }) |
| 2889 | |
| 2890 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2891 | // and ignored in DTLS. |
| 2892 | var shouldFail bool |
| 2893 | var expectedError string |
| 2894 | if protocol == tls { |
| 2895 | shouldFail = true |
| 2896 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2897 | } |
| 2898 | |
| 2899 | testCases = append(testCases, testCase{ |
| 2900 | protocol: protocol, |
| 2901 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2902 | config: Config{ |
| 2903 | MinVersion: ver.version, |
| 2904 | MaxVersion: ver.version, |
| 2905 | CipherSuites: []uint16{suite.id}, |
| 2906 | Certificates: []Certificate{cert}, |
| 2907 | PreSharedKey: []byte(psk), |
| 2908 | PreSharedKeyIdentity: pskIdentity, |
| 2909 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2910 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2911 | flags: flags, |
| 2912 | damageFirstWrite: true, |
| 2913 | messageLen: maxPlaintext, |
| 2914 | shouldFail: shouldFail, |
| 2915 | expectedError: expectedError, |
| 2916 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2917 | } |
| 2918 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2919 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2920 | const bogusCipher = 0xfe00 |
| 2921 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2922 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2923 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2924 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2925 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2926 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2927 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2928 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2929 | |
| 2930 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2931 | name: "NoSharedCipher", |
| 2932 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2933 | MaxVersion: VersionTLS12, |
| 2934 | CipherSuites: []uint16{}, |
| 2935 | }, |
| 2936 | shouldFail: true, |
| 2937 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2938 | }) |
| 2939 | |
| 2940 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2941 | name: "NoSharedCipher-TLS13", |
| 2942 | config: Config{ |
| 2943 | MaxVersion: VersionTLS13, |
| 2944 | CipherSuites: []uint16{}, |
| 2945 | }, |
| 2946 | shouldFail: true, |
| 2947 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2948 | }) |
| 2949 | |
| 2950 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2951 | name: "UnsupportedCipherSuite", |
| 2952 | config: Config{ |
| 2953 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2954 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2955 | Bugs: ProtocolBugs{ |
| 2956 | IgnorePeerCipherPreferences: true, |
| 2957 | }, |
| 2958 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2959 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2960 | shouldFail: true, |
| 2961 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2962 | }) |
| 2963 | |
| 2964 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2965 | name: "ServerHelloBogusCipher", |
| 2966 | config: Config{ |
| 2967 | MaxVersion: VersionTLS12, |
| 2968 | Bugs: ProtocolBugs{ |
| 2969 | SendCipherSuite: bogusCipher, |
| 2970 | }, |
| 2971 | }, |
| 2972 | shouldFail: true, |
| 2973 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2974 | }) |
| 2975 | testCases = append(testCases, testCase{ |
| 2976 | name: "ServerHelloBogusCipher-TLS13", |
| 2977 | config: Config{ |
| 2978 | MaxVersion: VersionTLS13, |
| 2979 | Bugs: ProtocolBugs{ |
| 2980 | SendCipherSuite: bogusCipher, |
| 2981 | }, |
| 2982 | }, |
| 2983 | shouldFail: true, |
| 2984 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2985 | }) |
| 2986 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2987 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2988 | testCases = append(testCases, testCase{ |
| 2989 | testType: serverTest, |
| 2990 | name: "UnknownCipher", |
| 2991 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2992 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2993 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2994 | Bugs: ProtocolBugs{ |
| 2995 | AdvertiseAllConfiguredCiphers: true, |
| 2996 | }, |
| 2997 | }, |
| 2998 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2999 | |
| 3000 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3001 | testCases = append(testCases, testCase{ |
| 3002 | testType: serverTest, |
| 3003 | name: "UnknownCipher-TLS13", |
| 3004 | config: Config{ |
| 3005 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3006 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3007 | Bugs: ProtocolBugs{ |
| 3008 | AdvertiseAllConfiguredCiphers: true, |
| 3009 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3010 | }, |
| 3011 | }) |
| 3012 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 3013 | // Test empty ECDHE_PSK identity hints work as expected. |
| 3014 | testCases = append(testCases, testCase{ |
| 3015 | name: "EmptyECDHEPSKHint", |
| 3016 | config: Config{ |
| 3017 | MaxVersion: VersionTLS12, |
| 3018 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3019 | PreSharedKey: []byte("secret"), |
| 3020 | }, |
| 3021 | flags: []string{"-psk", "secret"}, |
| 3022 | }) |
| 3023 | |
| 3024 | // Test empty PSK identity hints work as expected, even if an explicit |
| 3025 | // ServerKeyExchange is sent. |
| 3026 | testCases = append(testCases, testCase{ |
| 3027 | name: "ExplicitEmptyPSKHint", |
| 3028 | config: Config{ |
| 3029 | MaxVersion: VersionTLS12, |
| 3030 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3031 | PreSharedKey: []byte("secret"), |
| 3032 | Bugs: ProtocolBugs{ |
| 3033 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 3034 | }, |
| 3035 | }, |
| 3036 | flags: []string{"-psk", "secret"}, |
| 3037 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 3038 | |
| 3039 | // Test that clients enforce that the server-sent certificate and cipher |
| 3040 | // suite match in TLS 1.2. |
| 3041 | testCases = append(testCases, testCase{ |
| 3042 | name: "CertificateCipherMismatch-RSA", |
| 3043 | config: Config{ |
| 3044 | MaxVersion: VersionTLS12, |
| 3045 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3046 | Certificates: []Certificate{rsaCertificate}, |
| 3047 | Bugs: ProtocolBugs{ |
| 3048 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 3049 | }, |
| 3050 | }, |
| 3051 | shouldFail: true, |
| 3052 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3053 | }) |
| 3054 | testCases = append(testCases, testCase{ |
| 3055 | name: "CertificateCipherMismatch-ECDSA", |
| 3056 | config: Config{ |
| 3057 | MaxVersion: VersionTLS12, |
| 3058 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3059 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3060 | Bugs: ProtocolBugs{ |
| 3061 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3062 | }, |
| 3063 | }, |
| 3064 | shouldFail: true, |
| 3065 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3066 | }) |
| 3067 | testCases = append(testCases, testCase{ |
| 3068 | name: "CertificateCipherMismatch-Ed25519", |
| 3069 | config: Config{ |
| 3070 | MaxVersion: VersionTLS12, |
| 3071 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3072 | Certificates: []Certificate{ed25519Certificate}, |
| 3073 | Bugs: ProtocolBugs{ |
| 3074 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3075 | }, |
| 3076 | }, |
| 3077 | shouldFail: true, |
| 3078 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3079 | }) |
| 3080 | |
| 3081 | // Test that servers decline to select a cipher suite which is |
| 3082 | // inconsistent with their configured certificate. |
| 3083 | testCases = append(testCases, testCase{ |
| 3084 | testType: serverTest, |
| 3085 | name: "ServerCipherFilter-RSA", |
| 3086 | config: Config{ |
| 3087 | MaxVersion: VersionTLS12, |
| 3088 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3089 | }, |
| 3090 | flags: []string{ |
| 3091 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3092 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3093 | }, |
| 3094 | shouldFail: true, |
| 3095 | expectedError: ":NO_SHARED_CIPHER:", |
| 3096 | }) |
| 3097 | testCases = append(testCases, testCase{ |
| 3098 | testType: serverTest, |
| 3099 | name: "ServerCipherFilter-ECDSA", |
| 3100 | config: Config{ |
| 3101 | MaxVersion: VersionTLS12, |
| 3102 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3103 | }, |
| 3104 | flags: []string{ |
| 3105 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3106 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3107 | }, |
| 3108 | shouldFail: true, |
| 3109 | expectedError: ":NO_SHARED_CIPHER:", |
| 3110 | }) |
| 3111 | testCases = append(testCases, testCase{ |
| 3112 | testType: serverTest, |
| 3113 | name: "ServerCipherFilter-Ed25519", |
| 3114 | config: Config{ |
| 3115 | MaxVersion: VersionTLS12, |
| 3116 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3117 | }, |
| 3118 | flags: []string{ |
| 3119 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 3120 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 3121 | }, |
| 3122 | shouldFail: true, |
| 3123 | expectedError: ":NO_SHARED_CIPHER:", |
| 3124 | }) |
David Benjamin | 364af78 | 2017-07-01 10:35:27 -0400 | [diff] [blame] | 3125 | |
| 3126 | // Test cipher suite negotiation works as expected. Configure a |
| 3127 | // complicated cipher suite configuration. |
| 3128 | const negotiationTestCiphers = "" + |
| 3129 | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3130 | "[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]:" + |
| 3131 | "TLS_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3132 | "TLS_RSA_WITH_AES_128_CBC_SHA:" + |
| 3133 | "[TLS_RSA_WITH_AES_256_GCM_SHA384|TLS_RSA_WITH_AES_256_CBC_SHA]" |
| 3134 | negotiationTests := []struct { |
| 3135 | ciphers []uint16 |
| 3136 | expected uint16 |
| 3137 | }{ |
| 3138 | // Server preferences are honored, including when |
| 3139 | // equipreference groups are involved. |
| 3140 | { |
| 3141 | []uint16{ |
| 3142 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3143 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3144 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3145 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3146 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3147 | }, |
| 3148 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3149 | }, |
| 3150 | { |
| 3151 | []uint16{ |
| 3152 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3153 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3154 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3155 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3156 | }, |
| 3157 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3158 | }, |
| 3159 | { |
| 3160 | []uint16{ |
| 3161 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3162 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3163 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3164 | }, |
| 3165 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3166 | }, |
| 3167 | { |
| 3168 | []uint16{ |
| 3169 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3170 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3171 | }, |
| 3172 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3173 | }, |
| 3174 | // Equipreference groups use the client preference. |
| 3175 | { |
| 3176 | []uint16{ |
| 3177 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3178 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3179 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3180 | }, |
| 3181 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3182 | }, |
| 3183 | { |
| 3184 | []uint16{ |
| 3185 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3186 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3187 | }, |
| 3188 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3189 | }, |
| 3190 | { |
| 3191 | []uint16{ |
| 3192 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3193 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3194 | }, |
| 3195 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3196 | }, |
| 3197 | { |
| 3198 | []uint16{ |
| 3199 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3200 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3201 | }, |
| 3202 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3203 | }, |
| 3204 | { |
| 3205 | []uint16{ |
| 3206 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3207 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3208 | }, |
| 3209 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3210 | }, |
| 3211 | // If there are two equipreference groups, the preferred one |
| 3212 | // takes precedence. |
| 3213 | { |
| 3214 | []uint16{ |
| 3215 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3216 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3217 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3218 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3219 | }, |
| 3220 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3221 | }, |
| 3222 | } |
| 3223 | for i, t := range negotiationTests { |
| 3224 | testCases = append(testCases, testCase{ |
| 3225 | testType: serverTest, |
| 3226 | name: "CipherNegotiation-" + strconv.Itoa(i), |
| 3227 | config: Config{ |
| 3228 | MaxVersion: VersionTLS12, |
| 3229 | CipherSuites: t.ciphers, |
| 3230 | }, |
| 3231 | flags: []string{"-cipher", negotiationTestCiphers}, |
| 3232 | expectedCipher: t.expected, |
| 3233 | }) |
| 3234 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3235 | } |
| 3236 | |
| 3237 | func addBadECDSASignatureTests() { |
| 3238 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 3239 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3240 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3241 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 3242 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3243 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3244 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3245 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3246 | Bugs: ProtocolBugs{ |
| 3247 | BadECDSAR: badR, |
| 3248 | BadECDSAS: badS, |
| 3249 | }, |
| 3250 | }, |
| 3251 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3252 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3253 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3254 | testCases = append(testCases, testCase{ |
| 3255 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 3256 | config: Config{ |
| 3257 | MaxVersion: VersionTLS13, |
| 3258 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3259 | Bugs: ProtocolBugs{ |
| 3260 | BadECDSAR: badR, |
| 3261 | BadECDSAS: badS, |
| 3262 | }, |
| 3263 | }, |
| 3264 | shouldFail: true, |
| 3265 | expectedError: ":BAD_SIGNATURE:", |
| 3266 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3267 | } |
| 3268 | } |
| 3269 | } |
| 3270 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3271 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3272 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3273 | name: "MaxCBCPadding", |
| 3274 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3275 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3276 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3277 | Bugs: ProtocolBugs{ |
| 3278 | MaxPadding: true, |
| 3279 | }, |
| 3280 | }, |
| 3281 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3282 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3283 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3284 | name: "BadCBCPadding", |
| 3285 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3286 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3287 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3288 | Bugs: ProtocolBugs{ |
| 3289 | PaddingFirstByteBad: true, |
| 3290 | }, |
| 3291 | }, |
| 3292 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3293 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3294 | }) |
| 3295 | // OpenSSL previously had an issue where the first byte of padding in |
| 3296 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3297 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3298 | name: "BadCBCPadding255", |
| 3299 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3300 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3301 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3302 | Bugs: ProtocolBugs{ |
| 3303 | MaxPadding: true, |
| 3304 | PaddingFirstByteBadIf255: true, |
| 3305 | }, |
| 3306 | }, |
| 3307 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3308 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3309 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3310 | }) |
| 3311 | } |
| 3312 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3313 | func addCBCSplittingTests() { |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3314 | var cbcCiphers = []struct { |
| 3315 | name string |
| 3316 | cipher uint16 |
| 3317 | }{ |
| 3318 | {"3DES", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
| 3319 | {"AES128", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3320 | {"AES256", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
| 3321 | } |
| 3322 | for _, t := range cbcCiphers { |
| 3323 | testCases = append(testCases, testCase{ |
| 3324 | name: "CBCRecordSplitting-" + t.name, |
| 3325 | config: Config{ |
| 3326 | MaxVersion: VersionTLS10, |
| 3327 | MinVersion: VersionTLS10, |
| 3328 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3329 | Bugs: ProtocolBugs{ |
| 3330 | ExpectRecordSplitting: true, |
| 3331 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3332 | }, |
| 3333 | messageLen: -1, // read until EOF |
| 3334 | resumeSession: true, |
| 3335 | flags: []string{ |
| 3336 | "-async", |
| 3337 | "-write-different-record-sizes", |
| 3338 | "-cbc-record-splitting", |
| 3339 | }, |
| 3340 | }) |
| 3341 | testCases = append(testCases, testCase{ |
| 3342 | name: "CBCRecordSplittingPartialWrite-" + t.name, |
| 3343 | config: Config{ |
| 3344 | MaxVersion: VersionTLS10, |
| 3345 | MinVersion: VersionTLS10, |
| 3346 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3347 | Bugs: ProtocolBugs{ |
| 3348 | ExpectRecordSplitting: true, |
| 3349 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3350 | }, |
| 3351 | messageLen: -1, // read until EOF |
| 3352 | flags: []string{ |
| 3353 | "-async", |
| 3354 | "-write-different-record-sizes", |
| 3355 | "-cbc-record-splitting", |
| 3356 | "-partial-write", |
| 3357 | }, |
| 3358 | }) |
| 3359 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3360 | } |
| 3361 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3362 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3363 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3364 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3365 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3366 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3367 | if err != nil { |
| 3368 | panic(err) |
| 3369 | } |
| 3370 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3371 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3372 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3373 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3374 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3375 | testCases = append(testCases, testCase{ |
| 3376 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3377 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3378 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3379 | MinVersion: ver.version, |
| 3380 | MaxVersion: ver.version, |
| 3381 | ClientAuth: RequireAnyClientCert, |
| 3382 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3383 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3384 | tls13Variant: ver.tls13Variant, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3385 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3386 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3387 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3388 | }, |
| 3389 | }) |
| 3390 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3391 | testType: serverTest, |
| 3392 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3393 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3394 | MinVersion: ver.version, |
| 3395 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3396 | Certificates: []Certificate{rsaCertificate}, |
| 3397 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3398 | tls13Variant: ver.tls13Variant, |
| 3399 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3400 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3401 | if ver.version != VersionSSL30 { |
| 3402 | testCases = append(testCases, testCase{ |
| 3403 | testType: serverTest, |
| 3404 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3405 | config: Config{ |
| 3406 | MinVersion: ver.version, |
| 3407 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3408 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3409 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3410 | tls13Variant: ver.tls13Variant, |
| 3411 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3412 | }) |
| 3413 | testCases = append(testCases, testCase{ |
| 3414 | testType: clientTest, |
| 3415 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3416 | config: Config{ |
| 3417 | MinVersion: ver.version, |
| 3418 | MaxVersion: ver.version, |
| 3419 | ClientAuth: RequireAnyClientCert, |
| 3420 | ClientCAs: certPool, |
| 3421 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3422 | tls13Variant: ver.tls13Variant, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3423 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3424 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3425 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3426 | }, |
| 3427 | }) |
| 3428 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3429 | |
| 3430 | testCases = append(testCases, testCase{ |
| 3431 | name: "NoClientCertificate-" + ver.name, |
| 3432 | config: Config{ |
| 3433 | MinVersion: ver.version, |
| 3434 | MaxVersion: ver.version, |
| 3435 | ClientAuth: RequireAnyClientCert, |
| 3436 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3437 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3438 | shouldFail: true, |
| 3439 | expectedLocalError: "client didn't provide a certificate", |
| 3440 | }) |
| 3441 | |
| 3442 | testCases = append(testCases, testCase{ |
| 3443 | // Even if not configured to expect a certificate, OpenSSL will |
| 3444 | // return X509_V_OK as the verify_result. |
| 3445 | testType: serverTest, |
| 3446 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3447 | config: Config{ |
| 3448 | MinVersion: ver.version, |
| 3449 | MaxVersion: ver.version, |
| 3450 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3451 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3452 | flags: []string{ |
| 3453 | "-expect-verify-result", |
| 3454 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3455 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3456 | }) |
| 3457 | |
| 3458 | testCases = append(testCases, testCase{ |
| 3459 | // If a client certificate is not provided, OpenSSL will still |
| 3460 | // return X509_V_OK as the verify_result. |
| 3461 | testType: serverTest, |
| 3462 | name: "NoClientCertificate-Server-" + ver.name, |
| 3463 | config: Config{ |
| 3464 | MinVersion: ver.version, |
| 3465 | MaxVersion: ver.version, |
| 3466 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3467 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3468 | flags: []string{ |
| 3469 | "-expect-verify-result", |
| 3470 | "-verify-peer", |
| 3471 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3472 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3473 | }) |
| 3474 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3475 | certificateRequired := "remote error: certificate required" |
| 3476 | if ver.version < VersionTLS13 { |
| 3477 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3478 | // was used. |
| 3479 | certificateRequired = "remote error: handshake failure" |
| 3480 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3481 | testCases = append(testCases, testCase{ |
| 3482 | testType: serverTest, |
| 3483 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3484 | config: Config{ |
| 3485 | MinVersion: ver.version, |
| 3486 | MaxVersion: ver.version, |
| 3487 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3488 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3489 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3490 | shouldFail: true, |
| 3491 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3492 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3493 | }) |
| 3494 | |
| 3495 | if ver.version != VersionSSL30 { |
| 3496 | testCases = append(testCases, testCase{ |
| 3497 | testType: serverTest, |
| 3498 | name: "SkipClientCertificate-" + ver.name, |
| 3499 | config: Config{ |
| 3500 | MinVersion: ver.version, |
| 3501 | MaxVersion: ver.version, |
| 3502 | Bugs: ProtocolBugs{ |
| 3503 | SkipClientCertificate: true, |
| 3504 | }, |
| 3505 | }, |
| 3506 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3507 | flags: []string{"-verify-peer"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3508 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3509 | shouldFail: true, |
| 3510 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3511 | }) |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3512 | |
| 3513 | testCases = append(testCases, testCase{ |
| 3514 | testType: serverTest, |
| 3515 | name: "VerifyPeerIfNoOBC-NoChannelID-" + ver.name, |
| 3516 | config: Config{ |
| 3517 | MinVersion: ver.version, |
| 3518 | MaxVersion: ver.version, |
| 3519 | }, |
| 3520 | flags: []string{ |
| 3521 | "-enable-channel-id", |
| 3522 | "-verify-peer-if-no-obc", |
| 3523 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3524 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3525 | shouldFail: true, |
| 3526 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3527 | expectedLocalError: certificateRequired, |
| 3528 | }) |
| 3529 | |
| 3530 | testCases = append(testCases, testCase{ |
| 3531 | testType: serverTest, |
| 3532 | name: "VerifyPeerIfNoOBC-ChannelID-" + ver.name, |
| 3533 | config: Config{ |
| 3534 | MinVersion: ver.version, |
| 3535 | MaxVersion: ver.version, |
| 3536 | ChannelID: channelIDKey, |
| 3537 | }, |
| 3538 | expectChannelID: true, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3539 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3540 | flags: []string{ |
| 3541 | "-enable-channel-id", |
| 3542 | "-verify-peer-if-no-obc", |
| 3543 | }, |
| 3544 | }) |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3545 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3546 | |
| 3547 | testCases = append(testCases, testCase{ |
| 3548 | testType: serverTest, |
| 3549 | name: ver.name + "-Server-CertReq-CA-List", |
| 3550 | config: Config{ |
| 3551 | MinVersion: ver.version, |
| 3552 | MaxVersion: ver.version, |
| 3553 | Certificates: []Certificate{rsaCertificate}, |
| 3554 | Bugs: ProtocolBugs{ |
| 3555 | ExpectCertificateReqNames: caNames, |
| 3556 | }, |
| 3557 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3558 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3559 | flags: []string{ |
| 3560 | "-require-any-client-certificate", |
| 3561 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3562 | }, |
| 3563 | }) |
| 3564 | |
| 3565 | testCases = append(testCases, testCase{ |
| 3566 | testType: clientTest, |
| 3567 | name: ver.name + "-Client-CertReq-CA-List", |
| 3568 | config: Config{ |
| 3569 | MinVersion: ver.version, |
| 3570 | MaxVersion: ver.version, |
| 3571 | Certificates: []Certificate{rsaCertificate}, |
| 3572 | ClientAuth: RequireAnyClientCert, |
| 3573 | ClientCAs: certPool, |
| 3574 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3575 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3576 | flags: []string{ |
| 3577 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3578 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3579 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3580 | }, |
| 3581 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3582 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3583 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3584 | // Client auth is only legal in certificate-based ciphers. |
| 3585 | testCases = append(testCases, testCase{ |
| 3586 | testType: clientTest, |
| 3587 | name: "ClientAuth-PSK", |
| 3588 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3589 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3590 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3591 | PreSharedKey: []byte("secret"), |
| 3592 | ClientAuth: RequireAnyClientCert, |
| 3593 | }, |
| 3594 | flags: []string{ |
| 3595 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3596 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3597 | "-psk", "secret", |
| 3598 | }, |
| 3599 | shouldFail: true, |
| 3600 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3601 | }) |
| 3602 | testCases = append(testCases, testCase{ |
| 3603 | testType: clientTest, |
| 3604 | name: "ClientAuth-ECDHE_PSK", |
| 3605 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3606 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3607 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3608 | PreSharedKey: []byte("secret"), |
| 3609 | ClientAuth: RequireAnyClientCert, |
| 3610 | }, |
| 3611 | flags: []string{ |
| 3612 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3613 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3614 | "-psk", "secret", |
| 3615 | }, |
| 3616 | shouldFail: true, |
| 3617 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3618 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3619 | |
| 3620 | // Regression test for a bug where the client CA list, if explicitly |
| 3621 | // set to NULL, was mis-encoded. |
| 3622 | testCases = append(testCases, testCase{ |
| 3623 | testType: serverTest, |
| 3624 | name: "Null-Client-CA-List", |
| 3625 | config: Config{ |
| 3626 | MaxVersion: VersionTLS12, |
| 3627 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3628 | Bugs: ProtocolBugs{ |
| 3629 | ExpectCertificateReqNames: [][]byte{}, |
| 3630 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3631 | }, |
| 3632 | flags: []string{ |
| 3633 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3634 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3635 | }, |
| 3636 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3637 | } |
| 3638 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3639 | func addExtendedMasterSecretTests() { |
| 3640 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3641 | |
| 3642 | for _, with := range []bool{false, true} { |
| 3643 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3644 | if with { |
| 3645 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3646 | } |
| 3647 | |
| 3648 | for _, isClient := range []bool{false, true} { |
| 3649 | suffix := "-Server" |
| 3650 | testType := serverTest |
| 3651 | if isClient { |
| 3652 | suffix = "-Client" |
| 3653 | testType = clientTest |
| 3654 | } |
| 3655 | |
| 3656 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3657 | // In TLS 1.3, the extension is irrelevant and |
| 3658 | // always reports as enabled. |
| 3659 | var flags []string |
| 3660 | if with || ver.version >= VersionTLS13 { |
| 3661 | flags = []string{expectEMSFlag} |
| 3662 | } |
| 3663 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3664 | test := testCase{ |
| 3665 | testType: testType, |
| 3666 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3667 | config: Config{ |
| 3668 | MinVersion: ver.version, |
| 3669 | MaxVersion: ver.version, |
| 3670 | Bugs: ProtocolBugs{ |
| 3671 | NoExtendedMasterSecret: !with, |
| 3672 | RequireExtendedMasterSecret: with, |
| 3673 | }, |
| 3674 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3675 | tls13Variant: ver.tls13Variant, |
| 3676 | flags: flags, |
| 3677 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3678 | } |
| 3679 | if test.shouldFail { |
| 3680 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3681 | } |
| 3682 | testCases = append(testCases, test) |
| 3683 | } |
| 3684 | } |
| 3685 | } |
| 3686 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3687 | for _, isClient := range []bool{false, true} { |
| 3688 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3689 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3690 | boolToWord := func(b bool) string { |
| 3691 | if b { |
| 3692 | return "Yes" |
| 3693 | } |
| 3694 | return "No" |
| 3695 | } |
| 3696 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3697 | if isClient { |
| 3698 | suffix += "Client" |
| 3699 | } else { |
| 3700 | suffix += "Server" |
| 3701 | } |
| 3702 | |
| 3703 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3704 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3705 | Bugs: ProtocolBugs{ |
| 3706 | RequireExtendedMasterSecret: true, |
| 3707 | }, |
| 3708 | } |
| 3709 | |
| 3710 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3711 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3712 | Bugs: ProtocolBugs{ |
| 3713 | NoExtendedMasterSecret: true, |
| 3714 | }, |
| 3715 | } |
| 3716 | |
| 3717 | test := testCase{ |
| 3718 | name: "ExtendedMasterSecret-" + suffix, |
| 3719 | resumeSession: true, |
| 3720 | } |
| 3721 | |
| 3722 | if !isClient { |
| 3723 | test.testType = serverTest |
| 3724 | } |
| 3725 | |
| 3726 | if supportedInFirstConnection { |
| 3727 | test.config = supportedConfig |
| 3728 | } else { |
| 3729 | test.config = noSupportConfig |
| 3730 | } |
| 3731 | |
| 3732 | if supportedInResumeConnection { |
| 3733 | test.resumeConfig = &supportedConfig |
| 3734 | } else { |
| 3735 | test.resumeConfig = &noSupportConfig |
| 3736 | } |
| 3737 | |
| 3738 | switch suffix { |
| 3739 | case "YesToYes-Client", "YesToYes-Server": |
| 3740 | // When a session is resumed, it should |
| 3741 | // still be aware that its master |
| 3742 | // secret was generated via EMS and |
| 3743 | // thus it's safe to use tls-unique. |
| 3744 | test.flags = []string{expectEMSFlag} |
| 3745 | case "NoToYes-Server": |
| 3746 | // If an original connection did not |
| 3747 | // contain EMS, but a resumption |
| 3748 | // handshake does, then a server should |
| 3749 | // not resume the session. |
| 3750 | test.expectResumeRejected = true |
| 3751 | case "YesToNo-Server": |
| 3752 | // Resuming an EMS session without the |
| 3753 | // EMS extension should cause the |
| 3754 | // server to abort the connection. |
| 3755 | test.shouldFail = true |
| 3756 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3757 | case "NoToYes-Client": |
| 3758 | // A client should abort a connection |
| 3759 | // where the server resumed a non-EMS |
| 3760 | // session but echoed the EMS |
| 3761 | // extension. |
| 3762 | test.shouldFail = true |
| 3763 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3764 | case "YesToNo-Client": |
| 3765 | // A client should abort a connection |
| 3766 | // where the server didn't echo EMS |
| 3767 | // when the session used it. |
| 3768 | test.shouldFail = true |
| 3769 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3770 | } |
| 3771 | |
| 3772 | testCases = append(testCases, test) |
| 3773 | } |
| 3774 | } |
| 3775 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3776 | |
| 3777 | // Switching EMS on renegotiation is forbidden. |
| 3778 | testCases = append(testCases, testCase{ |
| 3779 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3780 | config: Config{ |
| 3781 | MaxVersion: VersionTLS12, |
| 3782 | Bugs: ProtocolBugs{ |
| 3783 | NoExtendedMasterSecret: true, |
| 3784 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3785 | }, |
| 3786 | }, |
| 3787 | renegotiate: 1, |
| 3788 | flags: []string{ |
| 3789 | "-renegotiate-freely", |
| 3790 | "-expect-total-renegotiations", "1", |
| 3791 | }, |
| 3792 | }) |
| 3793 | |
| 3794 | testCases = append(testCases, testCase{ |
| 3795 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3796 | config: Config{ |
| 3797 | MaxVersion: VersionTLS12, |
| 3798 | Bugs: ProtocolBugs{ |
| 3799 | NoExtendedMasterSecret: true, |
| 3800 | }, |
| 3801 | }, |
| 3802 | renegotiate: 1, |
| 3803 | flags: []string{ |
| 3804 | "-renegotiate-freely", |
| 3805 | "-expect-total-renegotiations", "1", |
| 3806 | }, |
| 3807 | shouldFail: true, |
| 3808 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3809 | }) |
| 3810 | |
| 3811 | testCases = append(testCases, testCase{ |
| 3812 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3813 | config: Config{ |
| 3814 | MaxVersion: VersionTLS12, |
| 3815 | Bugs: ProtocolBugs{ |
| 3816 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3817 | }, |
| 3818 | }, |
| 3819 | renegotiate: 1, |
| 3820 | flags: []string{ |
| 3821 | "-renegotiate-freely", |
| 3822 | "-expect-total-renegotiations", "1", |
| 3823 | }, |
| 3824 | shouldFail: true, |
| 3825 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3826 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3827 | } |
| 3828 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3829 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3830 | protocol protocol |
| 3831 | async bool |
| 3832 | splitHandshake bool |
| 3833 | packHandshakeFlight bool |
| 3834 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3835 | } |
| 3836 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3837 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3838 | // various conditions. Some of these are redundant with other tests, but they |
| 3839 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3840 | func addAllStateMachineCoverageTests() { |
| 3841 | for _, async := range []bool{false, true} { |
| 3842 | for _, protocol := range []protocol{tls, dtls} { |
| 3843 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3844 | protocol: protocol, |
| 3845 | async: async, |
| 3846 | }) |
| 3847 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3848 | protocol: protocol, |
| 3849 | async: async, |
| 3850 | implicitHandshake: true, |
| 3851 | }) |
| 3852 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3853 | protocol: protocol, |
| 3854 | async: async, |
| 3855 | splitHandshake: true, |
| 3856 | }) |
| 3857 | if protocol == tls { |
| 3858 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3859 | protocol: protocol, |
| 3860 | async: async, |
| 3861 | packHandshakeFlight: true, |
| 3862 | }) |
| 3863 | } |
| 3864 | } |
| 3865 | } |
| 3866 | } |
| 3867 | |
| 3868 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3869 | var tests []testCase |
| 3870 | |
| 3871 | // Basic handshake, with resumption. Client and server, |
| 3872 | // session ID and session ticket. |
| 3873 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3874 | name: "Basic-Client", |
| 3875 | config: Config{ |
| 3876 | MaxVersion: VersionTLS12, |
| 3877 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3878 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3879 | // Ensure session tickets are used, not session IDs. |
| 3880 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3881 | }) |
| 3882 | tests = append(tests, testCase{ |
| 3883 | name: "Basic-Client-RenewTicket", |
| 3884 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3885 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3886 | Bugs: ProtocolBugs{ |
| 3887 | RenewTicketOnResume: true, |
| 3888 | }, |
| 3889 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3890 | flags: []string{"-expect-ticket-renewal"}, |
| 3891 | resumeSession: true, |
| 3892 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3893 | }) |
| 3894 | tests = append(tests, testCase{ |
| 3895 | name: "Basic-Client-NoTicket", |
| 3896 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3897 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3898 | SessionTicketsDisabled: true, |
| 3899 | }, |
| 3900 | resumeSession: true, |
| 3901 | }) |
| 3902 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3903 | testType: serverTest, |
| 3904 | name: "Basic-Server", |
| 3905 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3906 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3907 | Bugs: ProtocolBugs{ |
| 3908 | RequireSessionTickets: true, |
| 3909 | }, |
| 3910 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3911 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3912 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3913 | }) |
| 3914 | tests = append(tests, testCase{ |
| 3915 | testType: serverTest, |
| 3916 | name: "Basic-Server-NoTickets", |
| 3917 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3918 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3919 | SessionTicketsDisabled: true, |
| 3920 | }, |
| 3921 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3922 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3923 | }) |
| 3924 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3925 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3926 | name: "Basic-Server-EarlyCallback", |
| 3927 | config: Config{ |
| 3928 | MaxVersion: VersionTLS12, |
| 3929 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3930 | flags: []string{"-use-early-callback"}, |
| 3931 | resumeSession: true, |
| 3932 | }) |
| 3933 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3934 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3935 | if config.protocol == tls { |
| 3936 | tests = append(tests, testCase{ |
| 3937 | name: "TLS13-1RTT-Client", |
| 3938 | config: Config{ |
| 3939 | MaxVersion: VersionTLS13, |
| 3940 | MinVersion: VersionTLS13, |
| 3941 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3942 | resumeSession: true, |
| 3943 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3944 | }) |
| 3945 | |
| 3946 | tests = append(tests, testCase{ |
| 3947 | testType: serverTest, |
| 3948 | name: "TLS13-1RTT-Server", |
| 3949 | config: Config{ |
| 3950 | MaxVersion: VersionTLS13, |
| 3951 | MinVersion: VersionTLS13, |
| 3952 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3953 | resumeSession: true, |
| 3954 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3955 | // TLS 1.3 uses tickets, so the session should not be |
| 3956 | // cached statefully. |
| 3957 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3958 | }) |
| 3959 | |
| 3960 | tests = append(tests, testCase{ |
| 3961 | name: "TLS13-HelloRetryRequest-Client", |
| 3962 | config: Config{ |
| 3963 | MaxVersion: VersionTLS13, |
| 3964 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3965 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3966 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3967 | CurvePreferences: []CurveID{CurveP384}, |
| 3968 | Bugs: ProtocolBugs{ |
| 3969 | ExpectMissingKeyShare: true, |
| 3970 | }, |
| 3971 | }, |
| 3972 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3973 | resumeSession: true, |
| 3974 | }) |
| 3975 | |
| 3976 | tests = append(tests, testCase{ |
| 3977 | testType: serverTest, |
| 3978 | name: "TLS13-HelloRetryRequest-Server", |
| 3979 | config: Config{ |
| 3980 | MaxVersion: VersionTLS13, |
| 3981 | MinVersion: VersionTLS13, |
| 3982 | // Require a HelloRetryRequest for every curve. |
| 3983 | DefaultCurves: []CurveID{}, |
| 3984 | }, |
| 3985 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3986 | resumeSession: true, |
| 3987 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3988 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3989 | tests = append(tests, testCase{ |
| 3990 | testType: clientTest, |
| 3991 | name: "TLS13-EarlyData-Client", |
| 3992 | config: Config{ |
| 3993 | MaxVersion: VersionTLS13, |
| 3994 | MinVersion: VersionTLS13, |
| 3995 | MaxEarlyDataSize: 16384, |
| 3996 | }, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3997 | resumeConfig: &Config{ |
| 3998 | MaxVersion: VersionTLS13, |
| 3999 | MinVersion: VersionTLS13, |
| 4000 | MaxEarlyDataSize: 16384, |
| 4001 | Bugs: ProtocolBugs{ |
| 4002 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4003 | }, |
| 4004 | }, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4005 | resumeSession: true, |
| 4006 | flags: []string{ |
| 4007 | "-enable-early-data", |
| 4008 | "-expect-early-data-info", |
| 4009 | "-expect-accept-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4010 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4011 | }, |
| 4012 | }) |
| 4013 | |
| 4014 | tests = append(tests, testCase{ |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4015 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4016 | name: "TLS13Experiment-EarlyData-Client", |
| 4017 | config: Config{ |
| 4018 | MaxVersion: VersionTLS13, |
| 4019 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4020 | MaxEarlyDataSize: 16384, |
| 4021 | }, |
| 4022 | resumeConfig: &Config{ |
| 4023 | MaxVersion: VersionTLS13, |
| 4024 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4025 | MaxEarlyDataSize: 16384, |
| 4026 | Bugs: ProtocolBugs{ |
| 4027 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4028 | }, |
| 4029 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4030 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4031 | resumeSession: true, |
| 4032 | flags: []string{ |
| 4033 | "-enable-early-data", |
| 4034 | "-expect-early-data-info", |
| 4035 | "-expect-accept-early-data", |
| 4036 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4037 | }, |
| 4038 | }) |
| 4039 | |
| 4040 | tests = append(tests, testCase{ |
| 4041 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4042 | name: "TLS13RecordTypeExperiment-EarlyData-Client", |
| 4043 | config: Config{ |
| 4044 | MaxVersion: VersionTLS13, |
| 4045 | MinVersion: VersionTLS13, |
| 4046 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4047 | MaxEarlyDataSize: 16384, |
| 4048 | }, |
| 4049 | resumeConfig: &Config{ |
| 4050 | MaxVersion: VersionTLS13, |
| 4051 | MinVersion: VersionTLS13, |
| 4052 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4053 | MaxEarlyDataSize: 16384, |
| 4054 | Bugs: ProtocolBugs{ |
| 4055 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4056 | }, |
| 4057 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4058 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4059 | resumeSession: true, |
| 4060 | flags: []string{ |
| 4061 | "-enable-early-data", |
| 4062 | "-expect-early-data-info", |
| 4063 | "-expect-accept-early-data", |
| 4064 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4065 | }, |
| 4066 | }) |
| 4067 | |
| 4068 | tests = append(tests, testCase{ |
| 4069 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4070 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 4071 | config: Config{ |
| 4072 | MaxVersion: VersionTLS13, |
| 4073 | MinVersion: VersionTLS13, |
| 4074 | MaxEarlyDataSize: 2, |
| 4075 | }, |
| 4076 | resumeConfig: &Config{ |
| 4077 | MaxVersion: VersionTLS13, |
| 4078 | MinVersion: VersionTLS13, |
| 4079 | MaxEarlyDataSize: 2, |
| 4080 | Bugs: ProtocolBugs{ |
| 4081 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 4082 | }, |
| 4083 | }, |
| 4084 | resumeShimPrefix: "llo", |
| 4085 | resumeSession: true, |
| 4086 | flags: []string{ |
| 4087 | "-enable-early-data", |
| 4088 | "-expect-early-data-info", |
| 4089 | "-expect-accept-early-data", |
| 4090 | "-on-resume-shim-writes-first", |
| 4091 | }, |
| 4092 | }) |
| 4093 | |
| 4094 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 4095 | // can't be tested as part of an ImplicitHandshake in this case since |
| 4096 | // otherwise the early data will be sent as normal data. |
| 4097 | if config.async && !config.implicitHandshake { |
| 4098 | tests = append(tests, testCase{ |
| 4099 | testType: clientTest, |
| 4100 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 4101 | config: Config{ |
| 4102 | MaxVersion: VersionTLS13, |
| 4103 | MinVersion: VersionTLS13, |
| 4104 | MaxEarlyDataSize: 16384, |
| 4105 | }, |
| 4106 | resumeConfig: &Config{ |
| 4107 | MaxVersion: VersionTLS13, |
| 4108 | MinVersion: VersionTLS13, |
| 4109 | MaxEarlyDataSize: 16384, |
| 4110 | Bugs: ProtocolBugs{ |
| 4111 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4112 | }, |
| 4113 | }, |
| 4114 | resumeSession: true, |
| 4115 | flags: []string{ |
| 4116 | "-enable-early-data", |
| 4117 | "-expect-early-data-info", |
| 4118 | "-expect-accept-early-data", |
| 4119 | "-on-resume-read-with-unfinished-write", |
| 4120 | "-on-resume-shim-writes-first", |
| 4121 | }, |
| 4122 | }) |
| 4123 | |
| 4124 | // Rejected unfinished writes are discarded (from the |
| 4125 | // perspective of the calling application) on 0-RTT |
| 4126 | // reject. |
| 4127 | tests = append(tests, testCase{ |
| 4128 | testType: clientTest, |
| 4129 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 4130 | config: Config{ |
| 4131 | MaxVersion: VersionTLS13, |
| 4132 | MinVersion: VersionTLS13, |
| 4133 | MaxEarlyDataSize: 16384, |
| 4134 | }, |
| 4135 | resumeConfig: &Config{ |
| 4136 | MaxVersion: VersionTLS13, |
| 4137 | MinVersion: VersionTLS13, |
| 4138 | MaxEarlyDataSize: 16384, |
| 4139 | Bugs: ProtocolBugs{ |
| 4140 | AlwaysRejectEarlyData: true, |
| 4141 | }, |
| 4142 | }, |
| 4143 | resumeSession: true, |
| 4144 | flags: []string{ |
| 4145 | "-enable-early-data", |
| 4146 | "-expect-early-data-info", |
| 4147 | "-expect-reject-early-data", |
| 4148 | "-on-resume-read-with-unfinished-write", |
| 4149 | "-on-resume-shim-writes-first", |
| 4150 | }, |
| 4151 | }) |
| 4152 | } |
| 4153 | |
| 4154 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4155 | testType: serverTest, |
| 4156 | name: "TLS13-EarlyData-Server", |
| 4157 | config: Config{ |
| 4158 | MaxVersion: VersionTLS13, |
| 4159 | MinVersion: VersionTLS13, |
| 4160 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4161 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4162 | ExpectEarlyDataAccepted: true, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4163 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4164 | }, |
| 4165 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4166 | messageCount: 2, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4167 | resumeSession: true, |
| 4168 | flags: []string{ |
| 4169 | "-enable-early-data", |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4170 | "-expect-accept-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4171 | }, |
| 4172 | }) |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4173 | |
| 4174 | tests = append(tests, testCase{ |
| 4175 | testType: serverTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4176 | name: "TLS13Experiment-EarlyData-Server", |
| 4177 | config: Config{ |
| 4178 | MaxVersion: VersionTLS13, |
| 4179 | MinVersion: VersionTLS13, |
| 4180 | TLS13Variant: TLS13Experiment, |
| 4181 | Bugs: ProtocolBugs{ |
| 4182 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4183 | ExpectEarlyDataAccepted: true, |
| 4184 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4185 | }, |
| 4186 | }, |
| 4187 | messageCount: 2, |
| 4188 | resumeSession: true, |
| 4189 | flags: []string{ |
| 4190 | "-enable-early-data", |
| 4191 | "-expect-accept-early-data", |
| 4192 | "-tls13-variant", "1", |
| 4193 | }, |
| 4194 | }) |
| 4195 | |
| 4196 | tests = append(tests, testCase{ |
| 4197 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4198 | name: "TLS13RecordTypeExperiment-EarlyData-Server", |
| 4199 | config: Config{ |
| 4200 | MaxVersion: VersionTLS13, |
| 4201 | MinVersion: VersionTLS13, |
| 4202 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4203 | Bugs: ProtocolBugs{ |
| 4204 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4205 | ExpectEarlyDataAccepted: true, |
| 4206 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4207 | }, |
| 4208 | }, |
| 4209 | messageCount: 2, |
| 4210 | resumeSession: true, |
| 4211 | flags: []string{ |
| 4212 | "-enable-early-data", |
| 4213 | "-expect-accept-early-data", |
| 4214 | "-tls13-variant", "2", |
| 4215 | }, |
| 4216 | }) |
| 4217 | |
| 4218 | tests = append(tests, testCase{ |
| 4219 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4220 | name: "TLS13-MaxEarlyData-Server", |
| 4221 | config: Config{ |
| 4222 | MaxVersion: VersionTLS13, |
| 4223 | MinVersion: VersionTLS13, |
| 4224 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4225 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4226 | ExpectEarlyDataAccepted: true, |
| 4227 | }, |
| 4228 | }, |
| 4229 | messageCount: 2, |
| 4230 | resumeSession: true, |
| 4231 | flags: []string{ |
| 4232 | "-enable-early-data", |
| 4233 | "-expect-accept-early-data", |
| 4234 | }, |
| 4235 | shouldFail: true, |
| 4236 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4237 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4238 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4239 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4240 | // TLS client auth. |
| 4241 | tests = append(tests, testCase{ |
| 4242 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4243 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4244 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4245 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4246 | ClientAuth: RequestClientCert, |
| 4247 | }, |
| 4248 | }) |
| 4249 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4250 | testType: serverTest, |
| 4251 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4252 | config: Config{ |
| 4253 | MaxVersion: VersionTLS12, |
| 4254 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4255 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4256 | flags: []string{"-verify-peer"}, |
| 4257 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4258 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4259 | tests = append(tests, testCase{ |
| 4260 | testType: clientTest, |
| 4261 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4262 | config: Config{ |
| 4263 | MaxVersion: VersionSSL30, |
| 4264 | ClientAuth: RequestClientCert, |
| 4265 | }, |
| 4266 | }) |
| 4267 | tests = append(tests, testCase{ |
| 4268 | testType: serverTest, |
| 4269 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4270 | config: Config{ |
| 4271 | MaxVersion: VersionSSL30, |
| 4272 | }, |
| 4273 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4274 | flags: []string{"-verify-peer"}, |
| 4275 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4276 | tests = append(tests, testCase{ |
| 4277 | testType: clientTest, |
| 4278 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4279 | config: Config{ |
| 4280 | MaxVersion: VersionTLS13, |
| 4281 | ClientAuth: RequestClientCert, |
| 4282 | }, |
| 4283 | }) |
| 4284 | tests = append(tests, testCase{ |
| 4285 | testType: serverTest, |
| 4286 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4287 | config: Config{ |
| 4288 | MaxVersion: VersionTLS13, |
| 4289 | }, |
| 4290 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4291 | flags: []string{"-verify-peer"}, |
| 4292 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4293 | } |
| 4294 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4295 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4296 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4297 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4298 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4299 | ClientAuth: RequireAnyClientCert, |
| 4300 | }, |
| 4301 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4302 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4303 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4304 | }, |
| 4305 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4306 | tests = append(tests, testCase{ |
| 4307 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4308 | name: "ClientAuth-RSA-Client-TLS13", |
| 4309 | config: Config{ |
| 4310 | MaxVersion: VersionTLS13, |
| 4311 | ClientAuth: RequireAnyClientCert, |
| 4312 | }, |
| 4313 | flags: []string{ |
| 4314 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4315 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4316 | }, |
| 4317 | }) |
| 4318 | tests = append(tests, testCase{ |
| 4319 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4320 | name: "ClientAuth-ECDSA-Client", |
| 4321 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4322 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4323 | ClientAuth: RequireAnyClientCert, |
| 4324 | }, |
| 4325 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4326 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4327 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4328 | }, |
| 4329 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4330 | tests = append(tests, testCase{ |
| 4331 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4332 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4333 | config: Config{ |
| 4334 | MaxVersion: VersionTLS13, |
| 4335 | ClientAuth: RequireAnyClientCert, |
| 4336 | }, |
| 4337 | flags: []string{ |
| 4338 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4339 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4340 | }, |
| 4341 | }) |
| 4342 | tests = append(tests, testCase{ |
| 4343 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4344 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4345 | config: Config{ |
| 4346 | MaxVersion: VersionTLS12, |
| 4347 | ClientAuth: RequestClientCert, |
| 4348 | }, |
| 4349 | flags: []string{"-use-old-client-cert-callback"}, |
| 4350 | }) |
| 4351 | tests = append(tests, testCase{ |
| 4352 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4353 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4354 | config: Config{ |
| 4355 | MaxVersion: VersionTLS13, |
| 4356 | ClientAuth: RequestClientCert, |
| 4357 | }, |
| 4358 | flags: []string{"-use-old-client-cert-callback"}, |
| 4359 | }) |
| 4360 | tests = append(tests, testCase{ |
| 4361 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4362 | name: "ClientAuth-OldCallback", |
| 4363 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4364 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4365 | ClientAuth: RequireAnyClientCert, |
| 4366 | }, |
| 4367 | flags: []string{ |
| 4368 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4369 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4370 | "-use-old-client-cert-callback", |
| 4371 | }, |
| 4372 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4373 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4374 | testType: clientTest, |
| 4375 | name: "ClientAuth-OldCallback-TLS13", |
| 4376 | config: Config{ |
| 4377 | MaxVersion: VersionTLS13, |
| 4378 | ClientAuth: RequireAnyClientCert, |
| 4379 | }, |
| 4380 | flags: []string{ |
| 4381 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4382 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4383 | "-use-old-client-cert-callback", |
| 4384 | }, |
| 4385 | }) |
| 4386 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4387 | testType: serverTest, |
| 4388 | name: "ClientAuth-Server", |
| 4389 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4390 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4391 | Certificates: []Certificate{rsaCertificate}, |
| 4392 | }, |
| 4393 | flags: []string{"-require-any-client-certificate"}, |
| 4394 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4395 | tests = append(tests, testCase{ |
| 4396 | testType: serverTest, |
| 4397 | name: "ClientAuth-Server-TLS13", |
| 4398 | config: Config{ |
| 4399 | MaxVersion: VersionTLS13, |
| 4400 | Certificates: []Certificate{rsaCertificate}, |
| 4401 | }, |
| 4402 | flags: []string{"-require-any-client-certificate"}, |
| 4403 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4404 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4405 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4406 | tests = append(tests, testCase{ |
| 4407 | testType: serverTest, |
| 4408 | name: "Basic-Server-RSA", |
| 4409 | config: Config{ |
| 4410 | MaxVersion: VersionTLS12, |
| 4411 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4412 | }, |
| 4413 | flags: []string{ |
| 4414 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4415 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4416 | }, |
| 4417 | }) |
| 4418 | tests = append(tests, testCase{ |
| 4419 | testType: serverTest, |
| 4420 | name: "Basic-Server-ECDHE-RSA", |
| 4421 | config: Config{ |
| 4422 | MaxVersion: VersionTLS12, |
| 4423 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4424 | }, |
| 4425 | flags: []string{ |
| 4426 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4427 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4428 | }, |
| 4429 | }) |
| 4430 | tests = append(tests, testCase{ |
| 4431 | testType: serverTest, |
| 4432 | name: "Basic-Server-ECDHE-ECDSA", |
| 4433 | config: Config{ |
| 4434 | MaxVersion: VersionTLS12, |
| 4435 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4436 | }, |
| 4437 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4438 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4439 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4440 | }, |
| 4441 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4442 | tests = append(tests, testCase{ |
| 4443 | testType: serverTest, |
| 4444 | name: "Basic-Server-Ed25519", |
| 4445 | config: Config{ |
| 4446 | MaxVersion: VersionTLS12, |
| 4447 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4448 | }, |
| 4449 | flags: []string{ |
| 4450 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4451 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4452 | "-enable-ed25519", |
| 4453 | }, |
| 4454 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4455 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4456 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4457 | tests = append(tests, testCase{ |
| 4458 | name: "SessionTicketsDisabled-Client", |
| 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 | SessionTicketsDisabled: true, |
| 4462 | }, |
| 4463 | }) |
| 4464 | tests = append(tests, testCase{ |
| 4465 | testType: serverTest, |
| 4466 | name: "SessionTicketsDisabled-Server", |
| 4467 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4468 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4469 | SessionTicketsDisabled: true, |
| 4470 | }, |
| 4471 | }) |
| 4472 | |
| 4473 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4474 | // identity hint. |
| 4475 | tests = append(tests, testCase{ |
| 4476 | name: "EmptyPSKHint-Client", |
| 4477 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4478 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4479 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4480 | PreSharedKey: []byte("secret"), |
| 4481 | }, |
| 4482 | flags: []string{"-psk", "secret"}, |
| 4483 | }) |
| 4484 | tests = append(tests, testCase{ |
| 4485 | testType: serverTest, |
| 4486 | name: "EmptyPSKHint-Server", |
| 4487 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4488 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4489 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4490 | PreSharedKey: []byte("secret"), |
| 4491 | }, |
| 4492 | flags: []string{"-psk", "secret"}, |
| 4493 | }) |
| 4494 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4495 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4496 | tests = append(tests, testCase{ |
| 4497 | testType: clientTest, |
| 4498 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4499 | config: Config{ |
| 4500 | MaxVersion: VersionTLS12, |
| 4501 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4502 | flags: []string{ |
| 4503 | "-enable-ocsp-stapling", |
| 4504 | "-expect-ocsp-response", |
| 4505 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4506 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4507 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4508 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4509 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4510 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4511 | testType: serverTest, |
| 4512 | name: "OCSPStapling-Server", |
| 4513 | config: Config{ |
| 4514 | MaxVersion: VersionTLS12, |
| 4515 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4516 | expectedOCSPResponse: testOCSPResponse, |
| 4517 | flags: []string{ |
| 4518 | "-ocsp-response", |
| 4519 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4520 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4521 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4522 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4523 | tests = append(tests, testCase{ |
| 4524 | testType: clientTest, |
| 4525 | name: "OCSPStapling-Client-TLS13", |
| 4526 | config: Config{ |
| 4527 | MaxVersion: VersionTLS13, |
| 4528 | }, |
| 4529 | flags: []string{ |
| 4530 | "-enable-ocsp-stapling", |
| 4531 | "-expect-ocsp-response", |
| 4532 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4533 | "-verify-peer", |
| 4534 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4535 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4536 | }) |
| 4537 | tests = append(tests, testCase{ |
| 4538 | testType: serverTest, |
| 4539 | name: "OCSPStapling-Server-TLS13", |
| 4540 | config: Config{ |
| 4541 | MaxVersion: VersionTLS13, |
| 4542 | }, |
| 4543 | expectedOCSPResponse: testOCSPResponse, |
| 4544 | flags: []string{ |
| 4545 | "-ocsp-response", |
| 4546 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4547 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4548 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4549 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4550 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4551 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4552 | for _, vers := range tlsVersions { |
| 4553 | if config.protocol == dtls && !vers.hasDTLS { |
| 4554 | continue |
| 4555 | } |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4556 | for _, useCustomCallback := range []bool{false, true} { |
| 4557 | for _, testType := range []testType{clientTest, serverTest} { |
| 4558 | suffix := "-Client" |
| 4559 | if testType == serverTest { |
| 4560 | suffix = "-Server" |
| 4561 | } |
| 4562 | suffix += "-" + vers.name |
| 4563 | if useCustomCallback { |
| 4564 | suffix += "-CustomCallback" |
| 4565 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4566 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4567 | flags := []string{"-verify-peer"} |
| 4568 | if testType == serverTest { |
| 4569 | flags = append(flags, "-require-any-client-certificate") |
| 4570 | } |
| 4571 | if useCustomCallback { |
| 4572 | flags = append(flags, "-use-custom-verify-callback") |
| 4573 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4574 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4575 | tests = append(tests, testCase{ |
| 4576 | testType: testType, |
| 4577 | name: "CertificateVerificationSucceed" + suffix, |
| 4578 | config: Config{ |
| 4579 | MaxVersion: vers.version, |
| 4580 | Certificates: []Certificate{rsaCertificate}, |
| 4581 | }, |
| 4582 | tls13Variant: vers.tls13Variant, |
| 4583 | flags: append([]string{"-expect-verify-result"}, flags...), |
| 4584 | resumeSession: true, |
| 4585 | }) |
| 4586 | tests = append(tests, testCase{ |
| 4587 | testType: testType, |
| 4588 | name: "CertificateVerificationFail" + suffix, |
| 4589 | config: Config{ |
| 4590 | MaxVersion: vers.version, |
| 4591 | Certificates: []Certificate{rsaCertificate}, |
| 4592 | }, |
| 4593 | tls13Variant: vers.tls13Variant, |
| 4594 | flags: append([]string{"-verify-fail"}, flags...), |
| 4595 | shouldFail: true, |
| 4596 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4597 | }) |
| 4598 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4599 | } |
| 4600 | |
| 4601 | // By default, the client is in a soft fail mode where the peer |
| 4602 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4603 | tests = append(tests, testCase{ |
| 4604 | testType: clientTest, |
| 4605 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4606 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4607 | MaxVersion: vers.version, |
| 4608 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4609 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4610 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4611 | flags: []string{ |
| 4612 | "-verify-fail", |
| 4613 | "-expect-verify-result", |
| 4614 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4615 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4616 | }) |
| 4617 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4618 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4619 | tests = append(tests, testCase{ |
| 4620 | name: "ShimSendAlert", |
| 4621 | flags: []string{"-send-alert"}, |
| 4622 | shimWritesFirst: true, |
| 4623 | shouldFail: true, |
| 4624 | expectedLocalError: "remote error: decompression failure", |
| 4625 | }) |
| 4626 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4627 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4628 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4629 | name: "Renegotiate-Client", |
| 4630 | config: Config{ |
| 4631 | MaxVersion: VersionTLS12, |
| 4632 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4633 | renegotiate: 1, |
| 4634 | flags: []string{ |
| 4635 | "-renegotiate-freely", |
| 4636 | "-expect-total-renegotiations", "1", |
| 4637 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4638 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4639 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4640 | tests = append(tests, testCase{ |
| 4641 | name: "SendHalfHelloRequest", |
| 4642 | config: Config{ |
| 4643 | MaxVersion: VersionTLS12, |
| 4644 | Bugs: ProtocolBugs{ |
| 4645 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4646 | }, |
| 4647 | }, |
| 4648 | sendHalfHelloRequest: true, |
| 4649 | flags: []string{"-renegotiate-ignore"}, |
| 4650 | shouldFail: true, |
| 4651 | expectedError: ":UNEXPECTED_RECORD:", |
| 4652 | }) |
| 4653 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4654 | // NPN on client and server; results in post-handshake message. |
| 4655 | tests = append(tests, testCase{ |
| 4656 | name: "NPN-Client", |
| 4657 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4658 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4659 | NextProtos: []string{"foo"}, |
| 4660 | }, |
| 4661 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4662 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4663 | expectedNextProto: "foo", |
| 4664 | expectedNextProtoType: npn, |
| 4665 | }) |
| 4666 | tests = append(tests, testCase{ |
| 4667 | testType: serverTest, |
| 4668 | name: "NPN-Server", |
| 4669 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4670 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4671 | NextProtos: []string{"bar"}, |
| 4672 | }, |
| 4673 | flags: []string{ |
| 4674 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4675 | "-expect-next-proto", "bar", |
| 4676 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4677 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4678 | expectedNextProto: "bar", |
| 4679 | expectedNextProtoType: npn, |
| 4680 | }) |
| 4681 | |
| 4682 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4683 | |
| 4684 | // Client does False Start and negotiates NPN. |
| 4685 | tests = append(tests, testCase{ |
| 4686 | name: "FalseStart", |
| 4687 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4688 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4689 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4690 | NextProtos: []string{"foo"}, |
| 4691 | Bugs: ProtocolBugs{ |
| 4692 | ExpectFalseStart: true, |
| 4693 | }, |
| 4694 | }, |
| 4695 | flags: []string{ |
| 4696 | "-false-start", |
| 4697 | "-select-next-proto", "foo", |
| 4698 | }, |
| 4699 | shimWritesFirst: true, |
| 4700 | resumeSession: true, |
| 4701 | }) |
| 4702 | |
| 4703 | // Client does False Start and negotiates ALPN. |
| 4704 | tests = append(tests, testCase{ |
| 4705 | name: "FalseStart-ALPN", |
| 4706 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4707 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4708 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4709 | NextProtos: []string{"foo"}, |
| 4710 | Bugs: ProtocolBugs{ |
| 4711 | ExpectFalseStart: true, |
| 4712 | }, |
| 4713 | }, |
| 4714 | flags: []string{ |
| 4715 | "-false-start", |
| 4716 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4717 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4718 | }, |
| 4719 | shimWritesFirst: true, |
| 4720 | resumeSession: true, |
| 4721 | }) |
| 4722 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4723 | // False Start without session tickets. |
| 4724 | tests = append(tests, testCase{ |
| 4725 | name: "FalseStart-SessionTicketsDisabled", |
| 4726 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4727 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4728 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4729 | NextProtos: []string{"foo"}, |
| 4730 | SessionTicketsDisabled: true, |
| 4731 | Bugs: ProtocolBugs{ |
| 4732 | ExpectFalseStart: true, |
| 4733 | }, |
| 4734 | }, |
| 4735 | flags: []string{ |
| 4736 | "-false-start", |
| 4737 | "-select-next-proto", "foo", |
| 4738 | }, |
| 4739 | shimWritesFirst: true, |
| 4740 | }) |
| 4741 | |
| 4742 | // Server parses a V2ClientHello. |
| 4743 | tests = append(tests, testCase{ |
| 4744 | testType: serverTest, |
| 4745 | name: "SendV2ClientHello", |
| 4746 | config: Config{ |
| 4747 | // Choose a cipher suite that does not involve |
| 4748 | // elliptic curves, so no extensions are |
| 4749 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4750 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4751 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4752 | Bugs: ProtocolBugs{ |
| 4753 | SendV2ClientHello: true, |
| 4754 | }, |
| 4755 | }, |
| 4756 | }) |
| 4757 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4758 | // Test Channel ID |
| 4759 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4760 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4761 | continue |
| 4762 | } |
| 4763 | // Client sends a Channel ID. |
| 4764 | tests = append(tests, testCase{ |
| 4765 | name: "ChannelID-Client-" + ver.name, |
| 4766 | config: Config{ |
| 4767 | MaxVersion: ver.version, |
| 4768 | RequestChannelID: true, |
| 4769 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4770 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4771 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4772 | resumeSession: true, |
| 4773 | expectChannelID: true, |
| 4774 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4775 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4776 | // Server accepts a Channel ID. |
| 4777 | tests = append(tests, testCase{ |
| 4778 | testType: serverTest, |
| 4779 | name: "ChannelID-Server-" + ver.name, |
| 4780 | config: Config{ |
| 4781 | MaxVersion: ver.version, |
| 4782 | ChannelID: channelIDKey, |
| 4783 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4784 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4785 | flags: []string{ |
| 4786 | "-expect-channel-id", |
| 4787 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4788 | }, |
| 4789 | resumeSession: true, |
| 4790 | expectChannelID: true, |
| 4791 | }) |
| 4792 | |
| 4793 | tests = append(tests, testCase{ |
| 4794 | testType: serverTest, |
| 4795 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4796 | config: Config{ |
| 4797 | MaxVersion: ver.version, |
| 4798 | ChannelID: channelIDKey, |
| 4799 | Bugs: ProtocolBugs{ |
| 4800 | InvalidChannelIDSignature: true, |
| 4801 | }, |
| 4802 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4803 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4804 | flags: []string{"-enable-channel-id"}, |
| 4805 | shouldFail: true, |
| 4806 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4807 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4808 | |
| 4809 | if ver.version < VersionTLS13 { |
| 4810 | // Channel ID requires ECDHE ciphers. |
| 4811 | tests = append(tests, testCase{ |
| 4812 | testType: serverTest, |
| 4813 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4814 | config: Config{ |
| 4815 | MaxVersion: ver.version, |
| 4816 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4817 | ChannelID: channelIDKey, |
| 4818 | }, |
| 4819 | expectChannelID: false, |
| 4820 | flags: []string{"-enable-channel-id"}, |
| 4821 | }) |
| 4822 | |
| 4823 | // Sanity-check setting expectChannelID false works. |
| 4824 | tests = append(tests, testCase{ |
| 4825 | testType: serverTest, |
| 4826 | name: "ChannelID-ECDHE-" + ver.name, |
| 4827 | config: Config{ |
| 4828 | MaxVersion: ver.version, |
| 4829 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4830 | ChannelID: channelIDKey, |
| 4831 | }, |
| 4832 | expectChannelID: false, |
| 4833 | flags: []string{"-enable-channel-id"}, |
| 4834 | shouldFail: true, |
| 4835 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4836 | }) |
| 4837 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4838 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4839 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4840 | // Channel ID and NPN at the same time, to ensure their relative |
| 4841 | // ordering is correct. |
| 4842 | tests = append(tests, testCase{ |
| 4843 | name: "ChannelID-NPN-Client", |
| 4844 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4845 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4846 | RequestChannelID: true, |
| 4847 | NextProtos: []string{"foo"}, |
| 4848 | }, |
| 4849 | flags: []string{ |
| 4850 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4851 | "-select-next-proto", "foo", |
| 4852 | }, |
| 4853 | resumeSession: true, |
| 4854 | expectChannelID: true, |
| 4855 | expectedNextProto: "foo", |
| 4856 | expectedNextProtoType: npn, |
| 4857 | }) |
| 4858 | tests = append(tests, testCase{ |
| 4859 | testType: serverTest, |
| 4860 | name: "ChannelID-NPN-Server", |
| 4861 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4862 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4863 | ChannelID: channelIDKey, |
| 4864 | NextProtos: []string{"bar"}, |
| 4865 | }, |
| 4866 | flags: []string{ |
| 4867 | "-expect-channel-id", |
| 4868 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4869 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4870 | "-expect-next-proto", "bar", |
| 4871 | }, |
| 4872 | resumeSession: true, |
| 4873 | expectChannelID: true, |
| 4874 | expectedNextProto: "bar", |
| 4875 | expectedNextProtoType: npn, |
| 4876 | }) |
| 4877 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4878 | // Bidirectional shutdown with the runner initiating. |
| 4879 | tests = append(tests, testCase{ |
| 4880 | name: "Shutdown-Runner", |
| 4881 | config: Config{ |
| 4882 | Bugs: ProtocolBugs{ |
| 4883 | ExpectCloseNotify: true, |
| 4884 | }, |
| 4885 | }, |
| 4886 | flags: []string{"-check-close-notify"}, |
| 4887 | }) |
| 4888 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4889 | if !config.implicitHandshake { |
| 4890 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4891 | // in the meantime, sends garbage before the close_notify which |
| 4892 | // the shim must ignore. This test is disabled under implicit |
| 4893 | // handshake tests because the shim never reads or writes. |
| 4894 | tests = append(tests, testCase{ |
| 4895 | name: "Shutdown-Shim", |
| 4896 | config: Config{ |
| 4897 | MaxVersion: VersionTLS12, |
| 4898 | Bugs: ProtocolBugs{ |
| 4899 | ExpectCloseNotify: true, |
| 4900 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4901 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4902 | shimShutsDown: true, |
| 4903 | sendEmptyRecords: 1, |
| 4904 | sendWarningAlerts: 1, |
| 4905 | flags: []string{"-check-close-notify"}, |
| 4906 | }) |
| 4907 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4908 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4909 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4910 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4911 | tests = append(tests, testCase{ |
| 4912 | name: "SkipHelloVerifyRequest", |
| 4913 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4914 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4915 | Bugs: ProtocolBugs{ |
| 4916 | SkipHelloVerifyRequest: true, |
| 4917 | }, |
| 4918 | }, |
| 4919 | }) |
| 4920 | } |
| 4921 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4922 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4923 | test.protocol = config.protocol |
| 4924 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4925 | test.name += "-DTLS" |
| 4926 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4927 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4928 | test.name += "-Async" |
| 4929 | test.flags = append(test.flags, "-async") |
| 4930 | } else { |
| 4931 | test.name += "-Sync" |
| 4932 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4933 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4934 | test.name += "-SplitHandshakeRecords" |
| 4935 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4936 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4937 | test.config.Bugs.MaxPacketLength = 256 |
| 4938 | test.flags = append(test.flags, "-mtu", "256") |
| 4939 | } |
| 4940 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4941 | if config.packHandshakeFlight { |
| 4942 | test.name += "-PackHandshakeFlight" |
| 4943 | test.config.Bugs.PackHandshakeFlight = true |
| 4944 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4945 | if config.implicitHandshake { |
| 4946 | test.name += "-ImplicitHandshake" |
| 4947 | test.flags = append(test.flags, "-implicit-handshake") |
| 4948 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4949 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4950 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4951 | } |
| 4952 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4953 | func addDDoSCallbackTests() { |
| 4954 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4955 | for _, resume := range []bool{false, true} { |
| 4956 | suffix := "Resume" |
| 4957 | if resume { |
| 4958 | suffix = "No" + suffix |
| 4959 | } |
| 4960 | |
| 4961 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4962 | testType: serverTest, |
| 4963 | name: "Server-DDoS-OK-" + suffix, |
| 4964 | config: Config{ |
| 4965 | MaxVersion: VersionTLS12, |
| 4966 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4967 | flags: []string{"-install-ddos-callback"}, |
| 4968 | resumeSession: resume, |
| 4969 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4970 | testCases = append(testCases, testCase{ |
| 4971 | testType: serverTest, |
| 4972 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4973 | config: Config{ |
| 4974 | MaxVersion: VersionTLS13, |
| 4975 | }, |
| 4976 | flags: []string{"-install-ddos-callback"}, |
| 4977 | resumeSession: resume, |
| 4978 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4979 | |
| 4980 | failFlag := "-fail-ddos-callback" |
| 4981 | if resume { |
| 4982 | failFlag = "-fail-second-ddos-callback" |
| 4983 | } |
| 4984 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4985 | testType: serverTest, |
| 4986 | name: "Server-DDoS-Reject-" + suffix, |
| 4987 | config: Config{ |
| 4988 | MaxVersion: VersionTLS12, |
| 4989 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4990 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4991 | resumeSession: resume, |
| 4992 | shouldFail: true, |
| 4993 | expectedError: ":CONNECTION_REJECTED:", |
| 4994 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4995 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4996 | testCases = append(testCases, testCase{ |
| 4997 | testType: serverTest, |
| 4998 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4999 | config: Config{ |
| 5000 | MaxVersion: VersionTLS13, |
| 5001 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5002 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5003 | resumeSession: resume, |
| 5004 | shouldFail: true, |
| 5005 | expectedError: ":CONNECTION_REJECTED:", |
| 5006 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5007 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5008 | } |
| 5009 | } |
| 5010 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5011 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5012 | for _, protocol := range []protocol{tls, dtls} { |
| 5013 | for _, shimVers := range allVersions(protocol) { |
| 5014 | // Assemble flags to disable all newer versions on the shim. |
| 5015 | var flags []string |
| 5016 | for _, vers := range allVersions(protocol) { |
| 5017 | if vers.version > shimVers.version { |
| 5018 | flags = append(flags, vers.excludeFlag) |
| 5019 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5020 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5021 | |
| 5022 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 5023 | |
| 5024 | if shimVers.tls13Variant != 0 { |
| 5025 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5026 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5027 | } |
| 5028 | |
| 5029 | // Test configuring the runner's maximum version. |
| 5030 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5031 | expectedVersion := shimVers.version |
| 5032 | if runnerVers.version < shimVers.version { |
| 5033 | expectedVersion = runnerVers.version |
| 5034 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5035 | // When running and shim have different TLS 1.3 variants enabled, |
| 5036 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5037 | // servers support both variants when enabled when the experiment is |
| 5038 | // enabled. |
| 5039 | expectedServerVersion := expectedVersion |
| 5040 | expectedClientVersion := expectedVersion |
| 5041 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5042 | expectedClientVersion = VersionTLS12 |
| 5043 | expectedServerVersion = VersionTLS12 |
| 5044 | if shimVers.tls13Variant != TLS13Default { |
| 5045 | expectedServerVersion = VersionTLS13 |
| 5046 | } |
| 5047 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5048 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5049 | suffix := shimVers.name + "-" + runnerVers.name |
| 5050 | if protocol == dtls { |
| 5051 | suffix += "-DTLS" |
| 5052 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5053 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5054 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5055 | clientVers := shimVers.version |
| 5056 | if clientVers > VersionTLS10 { |
| 5057 | clientVers = VersionTLS10 |
| 5058 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5059 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5060 | serverVers := expectedServerVersion |
| 5061 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5062 | serverVers = VersionTLS10 |
| 5063 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5064 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5065 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5066 | testCases = append(testCases, testCase{ |
| 5067 | protocol: protocol, |
| 5068 | testType: clientTest, |
| 5069 | name: "VersionNegotiation-Client-" + suffix, |
| 5070 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5071 | MaxVersion: runnerVers.version, |
| 5072 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5073 | Bugs: ProtocolBugs{ |
| 5074 | ExpectInitialRecordVersion: clientVers, |
| 5075 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5076 | }, |
| 5077 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5078 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5079 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5080 | testCases = append(testCases, testCase{ |
| 5081 | protocol: protocol, |
| 5082 | testType: clientTest, |
| 5083 | name: "VersionNegotiation-Client2-" + suffix, |
| 5084 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5085 | MaxVersion: runnerVers.version, |
| 5086 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5087 | Bugs: ProtocolBugs{ |
| 5088 | ExpectInitialRecordVersion: clientVers, |
| 5089 | }, |
| 5090 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5091 | flags: flags2, |
| 5092 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5093 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5094 | |
| 5095 | testCases = append(testCases, testCase{ |
| 5096 | protocol: protocol, |
| 5097 | testType: serverTest, |
| 5098 | name: "VersionNegotiation-Server-" + suffix, |
| 5099 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5100 | MaxVersion: runnerVers.version, |
| 5101 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5102 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5103 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5104 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5105 | }, |
| 5106 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5107 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5108 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5109 | testCases = append(testCases, testCase{ |
| 5110 | protocol: protocol, |
| 5111 | testType: serverTest, |
| 5112 | name: "VersionNegotiation-Server2-" + suffix, |
| 5113 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5114 | MaxVersion: runnerVers.version, |
| 5115 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5116 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5117 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5118 | }, |
| 5119 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5120 | flags: flags2, |
| 5121 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5122 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5123 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5124 | } |
| 5125 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5126 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5127 | // Test the version extension at all versions. |
| 5128 | for _, vers := range tlsVersions { |
| 5129 | protocols := []protocol{tls} |
| 5130 | if vers.hasDTLS { |
| 5131 | protocols = append(protocols, dtls) |
| 5132 | } |
| 5133 | for _, protocol := range protocols { |
| 5134 | suffix := vers.name |
| 5135 | if protocol == dtls { |
| 5136 | suffix += "-DTLS" |
| 5137 | } |
| 5138 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5139 | testCases = append(testCases, testCase{ |
| 5140 | protocol: protocol, |
| 5141 | testType: serverTest, |
| 5142 | name: "VersionNegotiationExtension-" + suffix, |
| 5143 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5144 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5145 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5146 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5147 | }, |
| 5148 | }, |
| 5149 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5150 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5151 | }) |
| 5152 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5153 | } |
| 5154 | |
| 5155 | // If all versions are unknown, negotiation fails. |
| 5156 | testCases = append(testCases, testCase{ |
| 5157 | testType: serverTest, |
| 5158 | name: "NoSupportedVersions", |
| 5159 | config: Config{ |
| 5160 | Bugs: ProtocolBugs{ |
| 5161 | SendSupportedVersions: []uint16{0x1111}, |
| 5162 | }, |
| 5163 | }, |
| 5164 | shouldFail: true, |
| 5165 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5166 | }) |
| 5167 | testCases = append(testCases, testCase{ |
| 5168 | protocol: dtls, |
| 5169 | testType: serverTest, |
| 5170 | name: "NoSupportedVersions-DTLS", |
| 5171 | config: Config{ |
| 5172 | Bugs: ProtocolBugs{ |
| 5173 | SendSupportedVersions: []uint16{0x1111}, |
| 5174 | }, |
| 5175 | }, |
| 5176 | shouldFail: true, |
| 5177 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5178 | }) |
| 5179 | |
| 5180 | testCases = append(testCases, testCase{ |
| 5181 | testType: serverTest, |
| 5182 | name: "ClientHelloVersionTooHigh", |
| 5183 | config: Config{ |
| 5184 | MaxVersion: VersionTLS13, |
| 5185 | Bugs: ProtocolBugs{ |
| 5186 | SendClientVersion: 0x0304, |
| 5187 | OmitSupportedVersions: true, |
| 5188 | }, |
| 5189 | }, |
| 5190 | expectedVersion: VersionTLS12, |
| 5191 | }) |
| 5192 | |
| 5193 | testCases = append(testCases, testCase{ |
| 5194 | testType: serverTest, |
| 5195 | name: "ConflictingVersionNegotiation", |
| 5196 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5197 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5198 | SendClientVersion: VersionTLS12, |
| 5199 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5200 | }, |
| 5201 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5202 | // The extension takes precedence over the ClientHello version. |
| 5203 | expectedVersion: VersionTLS11, |
| 5204 | }) |
| 5205 | |
| 5206 | testCases = append(testCases, testCase{ |
| 5207 | testType: serverTest, |
| 5208 | name: "ConflictingVersionNegotiation-2", |
| 5209 | config: Config{ |
| 5210 | Bugs: ProtocolBugs{ |
| 5211 | SendClientVersion: VersionTLS11, |
| 5212 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5213 | }, |
| 5214 | }, |
| 5215 | // The extension takes precedence over the ClientHello version. |
| 5216 | expectedVersion: VersionTLS12, |
| 5217 | }) |
| 5218 | |
| 5219 | testCases = append(testCases, testCase{ |
| 5220 | testType: serverTest, |
| 5221 | name: "RejectFinalTLS13", |
| 5222 | config: Config{ |
| 5223 | Bugs: ProtocolBugs{ |
| 5224 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5225 | }, |
| 5226 | }, |
| 5227 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5228 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5229 | expectedVersion: VersionTLS12, |
| 5230 | }) |
| 5231 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5232 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5233 | // the ServerHello. |
| 5234 | testCases = append(testCases, testCase{ |
| 5235 | testType: clientTest, |
| 5236 | name: "SupportedVersionSelection-TLS12", |
| 5237 | config: Config{ |
| 5238 | MaxVersion: VersionTLS12, |
| 5239 | Bugs: ProtocolBugs{ |
| 5240 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5241 | }, |
| 5242 | }, |
| 5243 | shouldFail: true, |
| 5244 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5245 | }) |
| 5246 | |
| 5247 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5248 | // supported_versions extension in the ServerHello. |
| 5249 | testCases = append(testCases, testCase{ |
| 5250 | testType: clientTest, |
| 5251 | name: "SupportedVersionSelection-TLS13", |
| 5252 | config: Config{ |
| 5253 | MaxVersion: VersionTLS13, |
| 5254 | Bugs: ProtocolBugs{ |
| 5255 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5256 | }, |
| 5257 | }, |
| 5258 | shouldFail: true, |
| 5259 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5260 | }) |
| 5261 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5262 | // Test that the maximum version is selected regardless of the |
| 5263 | // client-sent order. |
| 5264 | testCases = append(testCases, testCase{ |
| 5265 | testType: serverTest, |
| 5266 | name: "IgnoreClientVersionOrder", |
| 5267 | config: Config{ |
| 5268 | Bugs: ProtocolBugs{ |
| 5269 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5270 | }, |
| 5271 | }, |
| 5272 | expectedVersion: VersionTLS13, |
| 5273 | }) |
| 5274 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5275 | // Test for version tolerance. |
| 5276 | testCases = append(testCases, testCase{ |
| 5277 | testType: serverTest, |
| 5278 | name: "MinorVersionTolerance", |
| 5279 | config: Config{ |
| 5280 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5281 | SendClientVersion: 0x03ff, |
| 5282 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5283 | }, |
| 5284 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5285 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5286 | }) |
| 5287 | testCases = append(testCases, testCase{ |
| 5288 | testType: serverTest, |
| 5289 | name: "MajorVersionTolerance", |
| 5290 | config: Config{ |
| 5291 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5292 | SendClientVersion: 0x0400, |
| 5293 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5294 | }, |
| 5295 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5296 | // TLS 1.3 must be negotiated with the supported_versions |
| 5297 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5298 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5299 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5300 | testCases = append(testCases, testCase{ |
| 5301 | testType: serverTest, |
| 5302 | name: "VersionTolerance-TLS13", |
| 5303 | config: Config{ |
| 5304 | Bugs: ProtocolBugs{ |
| 5305 | // Although TLS 1.3 does not use |
| 5306 | // ClientHello.version, it still tolerates high |
| 5307 | // values there. |
| 5308 | SendClientVersion: 0x0400, |
| 5309 | }, |
| 5310 | }, |
| 5311 | expectedVersion: VersionTLS13, |
| 5312 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5313 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5314 | testCases = append(testCases, testCase{ |
| 5315 | protocol: dtls, |
| 5316 | testType: serverTest, |
| 5317 | name: "MinorVersionTolerance-DTLS", |
| 5318 | config: Config{ |
| 5319 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5320 | SendClientVersion: 0xfe00, |
| 5321 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5322 | }, |
| 5323 | }, |
| 5324 | expectedVersion: VersionTLS12, |
| 5325 | }) |
| 5326 | testCases = append(testCases, testCase{ |
| 5327 | protocol: dtls, |
| 5328 | testType: serverTest, |
| 5329 | name: "MajorVersionTolerance-DTLS", |
| 5330 | config: Config{ |
| 5331 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5332 | SendClientVersion: 0xfdff, |
| 5333 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5334 | }, |
| 5335 | }, |
| 5336 | expectedVersion: VersionTLS12, |
| 5337 | }) |
| 5338 | |
| 5339 | // Test that versions below 3.0 are rejected. |
| 5340 | testCases = append(testCases, testCase{ |
| 5341 | testType: serverTest, |
| 5342 | name: "VersionTooLow", |
| 5343 | config: Config{ |
| 5344 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5345 | SendClientVersion: 0x0200, |
| 5346 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5347 | }, |
| 5348 | }, |
| 5349 | shouldFail: true, |
| 5350 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5351 | }) |
| 5352 | testCases = append(testCases, testCase{ |
| 5353 | protocol: dtls, |
| 5354 | testType: serverTest, |
| 5355 | name: "VersionTooLow-DTLS", |
| 5356 | config: Config{ |
| 5357 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5358 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5359 | }, |
| 5360 | }, |
| 5361 | shouldFail: true, |
| 5362 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5363 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5364 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5365 | testCases = append(testCases, testCase{ |
| 5366 | name: "ServerBogusVersion", |
| 5367 | config: Config{ |
| 5368 | Bugs: ProtocolBugs{ |
| 5369 | SendServerHelloVersion: 0x1234, |
| 5370 | }, |
| 5371 | }, |
| 5372 | shouldFail: true, |
| 5373 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5374 | }) |
| 5375 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5376 | // Test TLS 1.3's downgrade signal. |
| 5377 | testCases = append(testCases, testCase{ |
| 5378 | name: "Downgrade-TLS12-Client", |
| 5379 | config: Config{ |
| 5380 | Bugs: ProtocolBugs{ |
| 5381 | NegotiateVersion: VersionTLS12, |
| 5382 | }, |
| 5383 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5384 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5385 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5386 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5387 | }) |
| 5388 | testCases = append(testCases, testCase{ |
| 5389 | testType: serverTest, |
| 5390 | name: "Downgrade-TLS12-Server", |
| 5391 | config: Config{ |
| 5392 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5393 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5394 | }, |
| 5395 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5396 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5397 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5398 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5399 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5400 | } |
| 5401 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5402 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5403 | for _, protocol := range []protocol{tls, dtls} { |
| 5404 | for _, shimVers := range allVersions(protocol) { |
| 5405 | // Assemble flags to disable all older versions on the shim. |
| 5406 | var flags []string |
| 5407 | for _, vers := range allVersions(protocol) { |
| 5408 | if vers.version < shimVers.version { |
| 5409 | flags = append(flags, vers.excludeFlag) |
| 5410 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5411 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5412 | |
| 5413 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5414 | |
| 5415 | if shimVers.tls13Variant != 0 { |
| 5416 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5417 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5418 | } |
| 5419 | |
| 5420 | for _, runnerVers := range allVersions(protocol) { |
| 5421 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5422 | // produce consistent minimum versions. |
| 5423 | // |
| 5424 | // TODO(davidben): Fold these tests (the main value is in the |
| 5425 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5426 | // on intended shim behavior, not the shim + runner combination. |
| 5427 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5428 | continue |
| 5429 | } |
| 5430 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5431 | suffix := shimVers.name + "-" + runnerVers.name |
| 5432 | if protocol == dtls { |
| 5433 | suffix += "-DTLS" |
| 5434 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5435 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5436 | var expectedVersion uint16 |
| 5437 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5438 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5439 | if runnerVers.version >= shimVers.version { |
| 5440 | expectedVersion = runnerVers.version |
| 5441 | } else { |
| 5442 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5443 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5444 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5445 | } |
| 5446 | |
| 5447 | testCases = append(testCases, testCase{ |
| 5448 | protocol: protocol, |
| 5449 | testType: clientTest, |
| 5450 | name: "MinimumVersion-Client-" + suffix, |
| 5451 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5452 | MaxVersion: runnerVers.version, |
| 5453 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5454 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5455 | // Ensure the server does not decline to |
| 5456 | // select a version (versions extension) or |
| 5457 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5458 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5459 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5460 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5461 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5462 | flags: flags, |
| 5463 | expectedVersion: expectedVersion, |
| 5464 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5465 | expectedError: expectedError, |
| 5466 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5467 | }) |
| 5468 | testCases = append(testCases, testCase{ |
| 5469 | protocol: protocol, |
| 5470 | testType: clientTest, |
| 5471 | name: "MinimumVersion-Client2-" + suffix, |
| 5472 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5473 | MaxVersion: runnerVers.version, |
| 5474 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5475 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5476 | // Ensure the server does not decline to |
| 5477 | // select a version (versions extension) or |
| 5478 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5479 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5480 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5481 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5482 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5483 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5484 | expectedVersion: expectedVersion, |
| 5485 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5486 | expectedError: expectedError, |
| 5487 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5488 | }) |
| 5489 | |
| 5490 | testCases = append(testCases, testCase{ |
| 5491 | protocol: protocol, |
| 5492 | testType: serverTest, |
| 5493 | name: "MinimumVersion-Server-" + suffix, |
| 5494 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5495 | MaxVersion: runnerVers.version, |
| 5496 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5497 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5498 | flags: flags, |
| 5499 | expectedVersion: expectedVersion, |
| 5500 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5501 | expectedError: expectedError, |
| 5502 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5503 | }) |
| 5504 | testCases = append(testCases, testCase{ |
| 5505 | protocol: protocol, |
| 5506 | testType: serverTest, |
| 5507 | name: "MinimumVersion-Server2-" + suffix, |
| 5508 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5509 | MaxVersion: runnerVers.version, |
| 5510 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5511 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5512 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5513 | expectedVersion: expectedVersion, |
| 5514 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5515 | expectedError: expectedError, |
| 5516 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5517 | }) |
| 5518 | } |
| 5519 | } |
| 5520 | } |
| 5521 | } |
| 5522 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5523 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5524 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5525 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5526 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5527 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5528 | // Repeat extensions tests all versions except SSL 3.0. |
| 5529 | for _, ver := range tlsVersions { |
| 5530 | if ver.version == VersionSSL30 { |
| 5531 | continue |
| 5532 | } |
| 5533 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5534 | // Test that duplicate extensions are rejected. |
| 5535 | testCases = append(testCases, testCase{ |
| 5536 | testType: clientTest, |
| 5537 | name: "DuplicateExtensionClient-" + ver.name, |
| 5538 | config: Config{ |
| 5539 | MaxVersion: ver.version, |
| 5540 | Bugs: ProtocolBugs{ |
| 5541 | DuplicateExtension: true, |
| 5542 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5543 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5544 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5545 | shouldFail: true, |
| 5546 | expectedLocalError: "remote error: error decoding message", |
| 5547 | }) |
| 5548 | testCases = append(testCases, testCase{ |
| 5549 | testType: serverTest, |
| 5550 | name: "DuplicateExtensionServer-" + ver.name, |
| 5551 | config: Config{ |
| 5552 | MaxVersion: ver.version, |
| 5553 | Bugs: ProtocolBugs{ |
| 5554 | DuplicateExtension: true, |
| 5555 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5556 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5557 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5558 | shouldFail: true, |
| 5559 | expectedLocalError: "remote error: error decoding message", |
| 5560 | }) |
| 5561 | |
| 5562 | // Test SNI. |
| 5563 | testCases = append(testCases, testCase{ |
| 5564 | testType: clientTest, |
| 5565 | name: "ServerNameExtensionClient-" + ver.name, |
| 5566 | config: Config{ |
| 5567 | MaxVersion: ver.version, |
| 5568 | Bugs: ProtocolBugs{ |
| 5569 | ExpectServerName: "example.com", |
| 5570 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5571 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5572 | tls13Variant: ver.tls13Variant, |
| 5573 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5574 | }) |
| 5575 | testCases = append(testCases, testCase{ |
| 5576 | testType: clientTest, |
| 5577 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5578 | config: Config{ |
| 5579 | MaxVersion: ver.version, |
| 5580 | Bugs: ProtocolBugs{ |
| 5581 | ExpectServerName: "mismatch.com", |
| 5582 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5583 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5584 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5585 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5586 | shouldFail: true, |
| 5587 | expectedLocalError: "tls: unexpected server name", |
| 5588 | }) |
| 5589 | testCases = append(testCases, testCase{ |
| 5590 | testType: clientTest, |
| 5591 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5592 | config: Config{ |
| 5593 | MaxVersion: ver.version, |
| 5594 | Bugs: ProtocolBugs{ |
| 5595 | ExpectServerName: "missing.com", |
| 5596 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5597 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5598 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5599 | shouldFail: true, |
| 5600 | expectedLocalError: "tls: unexpected server name", |
| 5601 | }) |
| 5602 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5603 | testType: clientTest, |
| 5604 | name: "TolerateServerNameAck-" + ver.name, |
| 5605 | config: Config{ |
| 5606 | MaxVersion: ver.version, |
| 5607 | Bugs: ProtocolBugs{ |
| 5608 | SendServerNameAck: true, |
| 5609 | }, |
| 5610 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5611 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5612 | flags: []string{"-host-name", "example.com"}, |
| 5613 | resumeSession: true, |
| 5614 | }) |
| 5615 | testCases = append(testCases, testCase{ |
| 5616 | testType: clientTest, |
| 5617 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5618 | config: Config{ |
| 5619 | MaxVersion: ver.version, |
| 5620 | Bugs: ProtocolBugs{ |
| 5621 | SendServerNameAck: true, |
| 5622 | }, |
| 5623 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5624 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5625 | shouldFail: true, |
| 5626 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5627 | expectedLocalError: "remote error: unsupported extension", |
| 5628 | }) |
| 5629 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5630 | testType: serverTest, |
| 5631 | name: "ServerNameExtensionServer-" + ver.name, |
| 5632 | config: Config{ |
| 5633 | MaxVersion: ver.version, |
| 5634 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5635 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5636 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5637 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5638 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5639 | }) |
| 5640 | |
| 5641 | // Test ALPN. |
| 5642 | testCases = append(testCases, testCase{ |
| 5643 | testType: clientTest, |
| 5644 | name: "ALPNClient-" + ver.name, |
| 5645 | config: Config{ |
| 5646 | MaxVersion: ver.version, |
| 5647 | NextProtos: []string{"foo"}, |
| 5648 | }, |
| 5649 | flags: []string{ |
| 5650 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5651 | "-expect-alpn", "foo", |
| 5652 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5653 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5654 | expectedNextProto: "foo", |
| 5655 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5656 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5657 | }) |
| 5658 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5659 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5660 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5661 | config: Config{ |
| 5662 | MaxVersion: ver.version, |
| 5663 | Bugs: ProtocolBugs{ |
| 5664 | SendALPN: "baz", |
| 5665 | }, |
| 5666 | }, |
| 5667 | flags: []string{ |
| 5668 | "-advertise-alpn", "\x03foo\x03bar", |
| 5669 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5670 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5671 | shouldFail: true, |
| 5672 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5673 | expectedLocalError: "remote error: illegal parameter", |
| 5674 | }) |
| 5675 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5676 | testType: clientTest, |
| 5677 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5678 | config: Config{ |
| 5679 | MaxVersion: ver.version, |
| 5680 | Bugs: ProtocolBugs{ |
| 5681 | SendALPN: "baz", |
| 5682 | }, |
| 5683 | }, |
| 5684 | flags: []string{ |
| 5685 | "-advertise-alpn", "\x03foo\x03bar", |
| 5686 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5687 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5688 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5689 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5690 | }) |
| 5691 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5692 | testType: serverTest, |
| 5693 | name: "ALPNServer-" + ver.name, |
| 5694 | config: Config{ |
| 5695 | MaxVersion: ver.version, |
| 5696 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5697 | }, |
| 5698 | flags: []string{ |
| 5699 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5700 | "-select-alpn", "foo", |
| 5701 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5702 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5703 | expectedNextProto: "foo", |
| 5704 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5705 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5706 | }) |
| 5707 | testCases = append(testCases, testCase{ |
| 5708 | testType: serverTest, |
| 5709 | name: "ALPNServer-Decline-" + ver.name, |
| 5710 | config: Config{ |
| 5711 | MaxVersion: ver.version, |
| 5712 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5713 | }, |
| 5714 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5715 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5716 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5717 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5718 | }) |
| 5719 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5720 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5721 | // called once. |
| 5722 | testCases = append(testCases, testCase{ |
| 5723 | testType: serverTest, |
| 5724 | name: "ALPNServer-Async-" + ver.name, |
| 5725 | config: Config{ |
| 5726 | MaxVersion: ver.version, |
| 5727 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5728 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5729 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5730 | }, |
| 5731 | flags: []string{ |
| 5732 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5733 | "-select-alpn", "foo", |
| 5734 | "-async", |
| 5735 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5736 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5737 | expectedNextProto: "foo", |
| 5738 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5739 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5740 | }) |
| 5741 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5742 | var emptyString string |
| 5743 | testCases = append(testCases, testCase{ |
| 5744 | testType: clientTest, |
| 5745 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5746 | config: Config{ |
| 5747 | MaxVersion: ver.version, |
| 5748 | NextProtos: []string{""}, |
| 5749 | Bugs: ProtocolBugs{ |
| 5750 | // A server returning an empty ALPN protocol |
| 5751 | // should be rejected. |
| 5752 | ALPNProtocol: &emptyString, |
| 5753 | }, |
| 5754 | }, |
| 5755 | flags: []string{ |
| 5756 | "-advertise-alpn", "\x03foo", |
| 5757 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5758 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5759 | shouldFail: true, |
| 5760 | expectedError: ":PARSE_TLSEXT:", |
| 5761 | }) |
| 5762 | testCases = append(testCases, testCase{ |
| 5763 | testType: serverTest, |
| 5764 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5765 | config: Config{ |
| 5766 | MaxVersion: ver.version, |
| 5767 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5768 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5769 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5770 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5771 | flags: []string{ |
| 5772 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5773 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5774 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5775 | shouldFail: true, |
| 5776 | expectedError: ":PARSE_TLSEXT:", |
| 5777 | }) |
| 5778 | |
| 5779 | // Test NPN and the interaction with ALPN. |
| 5780 | if ver.version < VersionTLS13 { |
| 5781 | // Test that the server prefers ALPN over NPN. |
| 5782 | testCases = append(testCases, testCase{ |
| 5783 | testType: serverTest, |
| 5784 | name: "ALPNServer-Preferred-" + ver.name, |
| 5785 | config: Config{ |
| 5786 | MaxVersion: ver.version, |
| 5787 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5788 | }, |
| 5789 | flags: []string{ |
| 5790 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5791 | "-select-alpn", "foo", |
| 5792 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5793 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5794 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5795 | expectedNextProto: "foo", |
| 5796 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5797 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5798 | }) |
| 5799 | testCases = append(testCases, testCase{ |
| 5800 | testType: serverTest, |
| 5801 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5802 | config: Config{ |
| 5803 | MaxVersion: ver.version, |
| 5804 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5805 | Bugs: ProtocolBugs{ |
| 5806 | SwapNPNAndALPN: true, |
| 5807 | }, |
| 5808 | }, |
| 5809 | flags: []string{ |
| 5810 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5811 | "-select-alpn", "foo", |
| 5812 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5813 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5814 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5815 | expectedNextProto: "foo", |
| 5816 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5817 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5818 | }) |
| 5819 | |
| 5820 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5821 | testCases = append(testCases, testCase{ |
| 5822 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5823 | config: Config{ |
| 5824 | MaxVersion: ver.version, |
| 5825 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5826 | Bugs: ProtocolBugs{ |
| 5827 | NegotiateALPNAndNPN: true, |
| 5828 | }, |
| 5829 | }, |
| 5830 | flags: []string{ |
| 5831 | "-advertise-alpn", "\x03foo", |
| 5832 | "-select-next-proto", "foo", |
| 5833 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5834 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5835 | shouldFail: true, |
| 5836 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5837 | }) |
| 5838 | testCases = append(testCases, testCase{ |
| 5839 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5840 | config: Config{ |
| 5841 | MaxVersion: ver.version, |
| 5842 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5843 | Bugs: ProtocolBugs{ |
| 5844 | NegotiateALPNAndNPN: true, |
| 5845 | SwapNPNAndALPN: true, |
| 5846 | }, |
| 5847 | }, |
| 5848 | flags: []string{ |
| 5849 | "-advertise-alpn", "\x03foo", |
| 5850 | "-select-next-proto", "foo", |
| 5851 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5852 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5853 | shouldFail: true, |
| 5854 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5855 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5856 | } |
| 5857 | |
| 5858 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5859 | |
| 5860 | // Resume with a corrupt ticket. |
| 5861 | testCases = append(testCases, testCase{ |
| 5862 | testType: serverTest, |
| 5863 | name: "CorruptTicket-" + ver.name, |
| 5864 | config: Config{ |
| 5865 | MaxVersion: ver.version, |
| 5866 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5867 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5868 | in[len(in)-1] ^= 1 |
| 5869 | return in, nil |
| 5870 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5871 | }, |
| 5872 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5873 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5874 | resumeSession: true, |
| 5875 | expectResumeRejected: true, |
| 5876 | }) |
| 5877 | // Test the ticket callback, with and without renewal. |
| 5878 | testCases = append(testCases, testCase{ |
| 5879 | testType: serverTest, |
| 5880 | name: "TicketCallback-" + ver.name, |
| 5881 | config: Config{ |
| 5882 | MaxVersion: ver.version, |
| 5883 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5884 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5885 | resumeSession: true, |
| 5886 | flags: []string{"-use-ticket-callback"}, |
| 5887 | }) |
| 5888 | testCases = append(testCases, testCase{ |
| 5889 | testType: serverTest, |
| 5890 | name: "TicketCallback-Renew-" + ver.name, |
| 5891 | config: Config{ |
| 5892 | MaxVersion: ver.version, |
| 5893 | Bugs: ProtocolBugs{ |
| 5894 | ExpectNewTicket: true, |
| 5895 | }, |
| 5896 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5897 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5898 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5899 | resumeSession: true, |
| 5900 | }) |
| 5901 | |
| 5902 | // Test that the ticket callback is only called once when everything before |
| 5903 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5904 | // certificate selection callbacks run. |
| 5905 | testCases = append(testCases, testCase{ |
| 5906 | testType: serverTest, |
| 5907 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5908 | config: Config{ |
| 5909 | MaxVersion: ver.version, |
| 5910 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5911 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5912 | in[len(in)-1] ^= 1 |
| 5913 | return in, nil |
| 5914 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5915 | }, |
| 5916 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5917 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5918 | resumeSession: true, |
| 5919 | expectResumeRejected: true, |
| 5920 | flags: []string{ |
| 5921 | "-use-ticket-callback", |
| 5922 | "-async", |
| 5923 | }, |
| 5924 | }) |
| 5925 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5926 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5927 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5928 | testCases = append(testCases, testCase{ |
| 5929 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5930 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5931 | config: Config{ |
| 5932 | MaxVersion: ver.version, |
| 5933 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5934 | EmptyTicketSessionID: true, |
| 5935 | }, |
| 5936 | }, |
| 5937 | resumeSession: true, |
| 5938 | }) |
| 5939 | testCases = append(testCases, testCase{ |
| 5940 | testType: serverTest, |
| 5941 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5942 | config: Config{ |
| 5943 | MaxVersion: ver.version, |
| 5944 | Bugs: ProtocolBugs{ |
| 5945 | TicketSessionIDLength: 16, |
| 5946 | }, |
| 5947 | }, |
| 5948 | resumeSession: true, |
| 5949 | }) |
| 5950 | testCases = append(testCases, testCase{ |
| 5951 | testType: serverTest, |
| 5952 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5953 | config: Config{ |
| 5954 | MaxVersion: ver.version, |
| 5955 | Bugs: ProtocolBugs{ |
| 5956 | TicketSessionIDLength: 32, |
| 5957 | }, |
| 5958 | }, |
| 5959 | resumeSession: true, |
| 5960 | }) |
| 5961 | testCases = append(testCases, testCase{ |
| 5962 | testType: serverTest, |
| 5963 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5964 | config: Config{ |
| 5965 | MaxVersion: ver.version, |
| 5966 | Bugs: ProtocolBugs{ |
| 5967 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5968 | }, |
| 5969 | }, |
| 5970 | resumeSession: true, |
| 5971 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5972 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5973 | expectedError: ":DECODE_ERROR:", |
| 5974 | }) |
| 5975 | } |
| 5976 | |
| 5977 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5978 | // are ignored. |
| 5979 | if ver.hasDTLS { |
| 5980 | testCases = append(testCases, testCase{ |
| 5981 | protocol: dtls, |
| 5982 | name: "SRTP-Client-" + ver.name, |
| 5983 | config: Config{ |
| 5984 | MaxVersion: ver.version, |
| 5985 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5986 | }, |
| 5987 | flags: []string{ |
| 5988 | "-srtp-profiles", |
| 5989 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5990 | }, |
| 5991 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5992 | }) |
| 5993 | testCases = append(testCases, testCase{ |
| 5994 | protocol: dtls, |
| 5995 | testType: serverTest, |
| 5996 | name: "SRTP-Server-" + ver.name, |
| 5997 | config: Config{ |
| 5998 | MaxVersion: ver.version, |
| 5999 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6000 | }, |
| 6001 | flags: []string{ |
| 6002 | "-srtp-profiles", |
| 6003 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6004 | }, |
| 6005 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6006 | }) |
| 6007 | // Test that the MKI is ignored. |
| 6008 | testCases = append(testCases, testCase{ |
| 6009 | protocol: dtls, |
| 6010 | testType: serverTest, |
| 6011 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 6012 | config: Config{ |
| 6013 | MaxVersion: ver.version, |
| 6014 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 6015 | Bugs: ProtocolBugs{ |
| 6016 | SRTPMasterKeyIdentifer: "bogus", |
| 6017 | }, |
| 6018 | }, |
| 6019 | flags: []string{ |
| 6020 | "-srtp-profiles", |
| 6021 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6022 | }, |
| 6023 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6024 | }) |
| 6025 | // Test that SRTP isn't negotiated on the server if there were |
| 6026 | // no matching profiles. |
| 6027 | testCases = append(testCases, testCase{ |
| 6028 | protocol: dtls, |
| 6029 | testType: serverTest, |
| 6030 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6031 | config: Config{ |
| 6032 | MaxVersion: ver.version, |
| 6033 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6034 | }, |
| 6035 | flags: []string{ |
| 6036 | "-srtp-profiles", |
| 6037 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6038 | }, |
| 6039 | expectedSRTPProtectionProfile: 0, |
| 6040 | }) |
| 6041 | // Test that the server returning an invalid SRTP profile is |
| 6042 | // flagged as an error by the client. |
| 6043 | testCases = append(testCases, testCase{ |
| 6044 | protocol: dtls, |
| 6045 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6046 | config: Config{ |
| 6047 | MaxVersion: ver.version, |
| 6048 | Bugs: ProtocolBugs{ |
| 6049 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6050 | }, |
| 6051 | }, |
| 6052 | flags: []string{ |
| 6053 | "-srtp-profiles", |
| 6054 | "SRTP_AES128_CM_SHA1_80", |
| 6055 | }, |
| 6056 | shouldFail: true, |
| 6057 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6058 | }) |
| 6059 | } |
| 6060 | |
| 6061 | // Test SCT list. |
| 6062 | testCases = append(testCases, testCase{ |
| 6063 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6064 | testType: clientTest, |
| 6065 | config: Config{ |
| 6066 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6067 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6068 | flags: []string{ |
| 6069 | "-enable-signed-cert-timestamps", |
| 6070 | "-expect-signed-cert-timestamps", |
| 6071 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6072 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6073 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6074 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6075 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6076 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6077 | var differentSCTList []byte |
| 6078 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6079 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6080 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6081 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6082 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6083 | testCases = append(testCases, testCase{ |
| 6084 | name: "SendSCTListOnResume-" + ver.name, |
| 6085 | config: Config{ |
| 6086 | MaxVersion: ver.version, |
| 6087 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6088 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6089 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6090 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6091 | flags: []string{ |
| 6092 | "-enable-signed-cert-timestamps", |
| 6093 | "-expect-signed-cert-timestamps", |
| 6094 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6095 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6096 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6097 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6098 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6099 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6100 | testCases = append(testCases, testCase{ |
| 6101 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6102 | testType: serverTest, |
| 6103 | config: Config{ |
| 6104 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6105 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6106 | flags: []string{ |
| 6107 | "-signed-cert-timestamps", |
| 6108 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6109 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6110 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6111 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6112 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6113 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6114 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6115 | emptySCTListCert := *testCerts[0].cert |
| 6116 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6117 | |
| 6118 | // Test empty SCT list. |
| 6119 | testCases = append(testCases, testCase{ |
| 6120 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6121 | testType: clientTest, |
| 6122 | config: Config{ |
| 6123 | MaxVersion: ver.version, |
| 6124 | Certificates: []Certificate{emptySCTListCert}, |
| 6125 | }, |
| 6126 | flags: []string{ |
| 6127 | "-enable-signed-cert-timestamps", |
| 6128 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6129 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6130 | shouldFail: true, |
| 6131 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6132 | }) |
| 6133 | |
| 6134 | emptySCTCert := *testCerts[0].cert |
| 6135 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6136 | |
| 6137 | // Test empty SCT in non-empty list. |
| 6138 | testCases = append(testCases, testCase{ |
| 6139 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6140 | testType: clientTest, |
| 6141 | config: Config{ |
| 6142 | MaxVersion: ver.version, |
| 6143 | Certificates: []Certificate{emptySCTCert}, |
| 6144 | }, |
| 6145 | flags: []string{ |
| 6146 | "-enable-signed-cert-timestamps", |
| 6147 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6148 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6149 | shouldFail: true, |
| 6150 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6151 | }) |
| 6152 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6153 | // Test that certificate-related extensions are not sent unsolicited. |
| 6154 | testCases = append(testCases, testCase{ |
| 6155 | testType: serverTest, |
| 6156 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6157 | config: Config{ |
| 6158 | MaxVersion: ver.version, |
| 6159 | Bugs: ProtocolBugs{ |
| 6160 | NoOCSPStapling: true, |
| 6161 | NoSignedCertificateTimestamps: true, |
| 6162 | }, |
| 6163 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6164 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6165 | flags: []string{ |
| 6166 | "-ocsp-response", |
| 6167 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6168 | "-signed-cert-timestamps", |
| 6169 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6170 | }, |
| 6171 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6172 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6173 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6174 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6175 | testType: clientTest, |
| 6176 | name: "ClientHelloPadding", |
| 6177 | config: Config{ |
| 6178 | Bugs: ProtocolBugs{ |
| 6179 | RequireClientHelloSize: 512, |
| 6180 | }, |
| 6181 | }, |
| 6182 | // This hostname just needs to be long enough to push the |
| 6183 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6184 | // long. |
| 6185 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6186 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6187 | |
| 6188 | // Extensions should not function in SSL 3.0. |
| 6189 | testCases = append(testCases, testCase{ |
| 6190 | testType: serverTest, |
| 6191 | name: "SSLv3Extensions-NoALPN", |
| 6192 | config: Config{ |
| 6193 | MaxVersion: VersionSSL30, |
| 6194 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6195 | }, |
| 6196 | flags: []string{ |
| 6197 | "-select-alpn", "foo", |
| 6198 | }, |
| 6199 | expectNoNextProto: true, |
| 6200 | }) |
| 6201 | |
| 6202 | // Test session tickets separately as they follow a different codepath. |
| 6203 | testCases = append(testCases, testCase{ |
| 6204 | testType: serverTest, |
| 6205 | name: "SSLv3Extensions-NoTickets", |
| 6206 | config: Config{ |
| 6207 | MaxVersion: VersionSSL30, |
| 6208 | Bugs: ProtocolBugs{ |
| 6209 | // Historically, session tickets in SSL 3.0 |
| 6210 | // failed in different ways depending on whether |
| 6211 | // the client supported renegotiation_info. |
| 6212 | NoRenegotiationInfo: true, |
| 6213 | }, |
| 6214 | }, |
| 6215 | resumeSession: true, |
| 6216 | }) |
| 6217 | testCases = append(testCases, testCase{ |
| 6218 | testType: serverTest, |
| 6219 | name: "SSLv3Extensions-NoTickets2", |
| 6220 | config: Config{ |
| 6221 | MaxVersion: VersionSSL30, |
| 6222 | }, |
| 6223 | resumeSession: true, |
| 6224 | }) |
| 6225 | |
| 6226 | // But SSL 3.0 does send and process renegotiation_info. |
| 6227 | testCases = append(testCases, testCase{ |
| 6228 | testType: serverTest, |
| 6229 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6230 | config: Config{ |
| 6231 | MaxVersion: VersionSSL30, |
| 6232 | Bugs: ProtocolBugs{ |
| 6233 | RequireRenegotiationInfo: true, |
| 6234 | }, |
| 6235 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6236 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6237 | }) |
| 6238 | testCases = append(testCases, testCase{ |
| 6239 | testType: serverTest, |
| 6240 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6241 | config: Config{ |
| 6242 | MaxVersion: VersionSSL30, |
| 6243 | Bugs: ProtocolBugs{ |
| 6244 | NoRenegotiationInfo: true, |
| 6245 | SendRenegotiationSCSV: true, |
| 6246 | RequireRenegotiationInfo: true, |
| 6247 | }, |
| 6248 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6249 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6250 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6251 | |
| 6252 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6253 | // in ServerHello. |
| 6254 | testCases = append(testCases, testCase{ |
| 6255 | name: "NPN-Forbidden-TLS13", |
| 6256 | config: Config{ |
| 6257 | MaxVersion: VersionTLS13, |
| 6258 | NextProtos: []string{"foo"}, |
| 6259 | Bugs: ProtocolBugs{ |
| 6260 | NegotiateNPNAtAllVersions: true, |
| 6261 | }, |
| 6262 | }, |
| 6263 | flags: []string{"-select-next-proto", "foo"}, |
| 6264 | shouldFail: true, |
| 6265 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6266 | }) |
| 6267 | testCases = append(testCases, testCase{ |
| 6268 | name: "EMS-Forbidden-TLS13", |
| 6269 | config: Config{ |
| 6270 | MaxVersion: VersionTLS13, |
| 6271 | Bugs: ProtocolBugs{ |
| 6272 | NegotiateEMSAtAllVersions: true, |
| 6273 | }, |
| 6274 | }, |
| 6275 | shouldFail: true, |
| 6276 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6277 | }) |
| 6278 | testCases = append(testCases, testCase{ |
| 6279 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6280 | config: Config{ |
| 6281 | MaxVersion: VersionTLS13, |
| 6282 | Bugs: ProtocolBugs{ |
| 6283 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6284 | }, |
| 6285 | }, |
| 6286 | shouldFail: true, |
| 6287 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6288 | }) |
| 6289 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6290 | name: "Ticket-Forbidden-TLS13", |
| 6291 | config: Config{ |
| 6292 | MaxVersion: VersionTLS12, |
| 6293 | }, |
| 6294 | resumeConfig: &Config{ |
| 6295 | MaxVersion: VersionTLS13, |
| 6296 | Bugs: ProtocolBugs{ |
| 6297 | AdvertiseTicketExtension: true, |
| 6298 | }, |
| 6299 | }, |
| 6300 | resumeSession: true, |
| 6301 | shouldFail: true, |
| 6302 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6303 | }) |
| 6304 | |
| 6305 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6306 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6307 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6308 | // implicit in every test.) |
| 6309 | testCases = append(testCases, testCase{ |
| 6310 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6311 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6312 | config: Config{ |
| 6313 | MaxVersion: VersionTLS13, |
| 6314 | NextProtos: []string{"bar"}, |
| 6315 | }, |
| 6316 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6317 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6318 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6319 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6320 | // tolerated. |
| 6321 | testCases = append(testCases, testCase{ |
| 6322 | name: "SendOCSPResponseOnResume-TLS12", |
| 6323 | config: Config{ |
| 6324 | MaxVersion: VersionTLS12, |
| 6325 | Bugs: ProtocolBugs{ |
| 6326 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6327 | }, |
| 6328 | }, |
| 6329 | flags: []string{ |
| 6330 | "-enable-ocsp-stapling", |
| 6331 | "-expect-ocsp-response", |
| 6332 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6333 | }, |
| 6334 | resumeSession: true, |
| 6335 | }) |
| 6336 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6337 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6338 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6339 | config: Config{ |
| 6340 | MaxVersion: VersionTLS13, |
| 6341 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6342 | SendExtensionOnCertificate: testOCSPExtension, |
| 6343 | }, |
| 6344 | }, |
| 6345 | shouldFail: true, |
| 6346 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6347 | }) |
| 6348 | |
| 6349 | testCases = append(testCases, testCase{ |
| 6350 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6351 | config: Config{ |
| 6352 | MaxVersion: VersionTLS13, |
| 6353 | Bugs: ProtocolBugs{ |
| 6354 | SendExtensionOnCertificate: testSCTExtension, |
| 6355 | }, |
| 6356 | }, |
| 6357 | shouldFail: true, |
| 6358 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6359 | }) |
| 6360 | |
| 6361 | // Test that extensions on client certificates are never accepted. |
| 6362 | testCases = append(testCases, testCase{ |
| 6363 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6364 | testType: serverTest, |
| 6365 | config: Config{ |
| 6366 | MaxVersion: VersionTLS13, |
| 6367 | Certificates: []Certificate{rsaCertificate}, |
| 6368 | Bugs: ProtocolBugs{ |
| 6369 | SendExtensionOnCertificate: testOCSPExtension, |
| 6370 | }, |
| 6371 | }, |
| 6372 | flags: []string{ |
| 6373 | "-enable-ocsp-stapling", |
| 6374 | "-require-any-client-certificate", |
| 6375 | }, |
| 6376 | shouldFail: true, |
| 6377 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6378 | }) |
| 6379 | |
| 6380 | testCases = append(testCases, testCase{ |
| 6381 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6382 | config: Config{ |
| 6383 | MaxVersion: VersionTLS13, |
| 6384 | Bugs: ProtocolBugs{ |
| 6385 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6386 | }, |
| 6387 | }, |
| 6388 | shouldFail: true, |
| 6389 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6390 | }) |
| 6391 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6392 | var differentSCTList []byte |
| 6393 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6394 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6395 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6396 | // Test that extensions on intermediates are allowed but ignored. |
| 6397 | testCases = append(testCases, testCase{ |
| 6398 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6399 | config: Config{ |
| 6400 | MaxVersion: VersionTLS13, |
| 6401 | Certificates: []Certificate{rsaChainCertificate}, |
| 6402 | Bugs: ProtocolBugs{ |
| 6403 | // Send different values on the intermediate. This tests |
| 6404 | // the intermediate's extensions do not override the |
| 6405 | // leaf's. |
| 6406 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6407 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6408 | }, |
| 6409 | }, |
| 6410 | flags: []string{ |
| 6411 | "-enable-ocsp-stapling", |
| 6412 | "-expect-ocsp-response", |
| 6413 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6414 | "-enable-signed-cert-timestamps", |
| 6415 | "-expect-signed-cert-timestamps", |
| 6416 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6417 | }, |
| 6418 | resumeSession: true, |
| 6419 | }) |
| 6420 | |
| 6421 | // Test that extensions are not sent on intermediates when configured |
| 6422 | // only for a leaf. |
| 6423 | testCases = append(testCases, testCase{ |
| 6424 | testType: serverTest, |
| 6425 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6426 | config: Config{ |
| 6427 | MaxVersion: VersionTLS13, |
| 6428 | Bugs: ProtocolBugs{ |
| 6429 | ExpectNoExtensionsOnIntermediate: true, |
| 6430 | }, |
| 6431 | }, |
| 6432 | flags: []string{ |
| 6433 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6434 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6435 | "-ocsp-response", |
| 6436 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6437 | "-signed-cert-timestamps", |
| 6438 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6439 | }, |
| 6440 | }) |
| 6441 | |
| 6442 | // Test that extensions are not sent on client certificates. |
| 6443 | testCases = append(testCases, testCase{ |
| 6444 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6445 | config: Config{ |
| 6446 | MaxVersion: VersionTLS13, |
| 6447 | ClientAuth: RequireAnyClientCert, |
| 6448 | }, |
| 6449 | flags: []string{ |
| 6450 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6451 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6452 | "-ocsp-response", |
| 6453 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6454 | "-signed-cert-timestamps", |
| 6455 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6456 | }, |
| 6457 | }) |
| 6458 | |
| 6459 | testCases = append(testCases, testCase{ |
| 6460 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6461 | config: Config{ |
| 6462 | MaxVersion: VersionTLS13, |
| 6463 | Bugs: ProtocolBugs{ |
| 6464 | SendDuplicateCertExtensions: true, |
| 6465 | }, |
| 6466 | }, |
| 6467 | flags: []string{ |
| 6468 | "-enable-ocsp-stapling", |
| 6469 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6470 | }, |
| 6471 | resumeSession: true, |
| 6472 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6473 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6474 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6475 | |
| 6476 | testCases = append(testCases, testCase{ |
| 6477 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6478 | testType: serverTest, |
| 6479 | flags: []string{ |
| 6480 | "-signed-cert-timestamps", |
| 6481 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6482 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6483 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6484 | expectedError: ":INVALID_SCT_LIST:", |
| 6485 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6486 | } |
| 6487 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6488 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6489 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6490 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6491 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6492 | // have session IDs, so skip their cross-resumption |
| 6493 | // tests. |
| 6494 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6495 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6496 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6497 | } |
| 6498 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6499 | protocols := []protocol{tls} |
| 6500 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6501 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6502 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6503 | for _, protocol := range protocols { |
| 6504 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6505 | if protocol == dtls { |
| 6506 | suffix += "-DTLS" |
| 6507 | } |
| 6508 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6509 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6510 | // session resumption. |
| 6511 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6512 | continue |
| 6513 | } |
| 6514 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6515 | if sessionVers.version == resumeVers.version { |
| 6516 | testCases = append(testCases, testCase{ |
| 6517 | protocol: protocol, |
| 6518 | name: "Resume-Client" + suffix, |
| 6519 | resumeSession: true, |
| 6520 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6521 | MaxVersion: sessionVers.version, |
| 6522 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6523 | Bugs: ProtocolBugs{ |
| 6524 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6525 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6526 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6527 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6528 | expectedVersion: sessionVers.version, |
| 6529 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6530 | flags: []string{ |
| 6531 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6532 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6533 | }) |
| 6534 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6535 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6536 | |
| 6537 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6538 | // there is no way to convince a non-lookahead client the |
| 6539 | // session was resumed. It will appear to the client that a |
| 6540 | // stray ChangeCipherSpec was sent. |
| 6541 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6542 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6543 | } |
| 6544 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6545 | testCases = append(testCases, testCase{ |
| 6546 | protocol: protocol, |
| 6547 | name: "Resume-Client-Mismatch" + suffix, |
| 6548 | resumeSession: true, |
| 6549 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6550 | MaxVersion: sessionVers.version, |
| 6551 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6552 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6553 | expectedVersion: sessionVers.version, |
| 6554 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6555 | MaxVersion: resumeVers.version, |
| 6556 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6557 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6558 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6559 | }, |
| 6560 | }, |
| 6561 | expectedResumeVersion: resumeVers.version, |
| 6562 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6563 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6564 | flags: []string{ |
| 6565 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6566 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6567 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6568 | }) |
| 6569 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6570 | |
| 6571 | testCases = append(testCases, testCase{ |
| 6572 | protocol: protocol, |
| 6573 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6574 | resumeSession: true, |
| 6575 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6576 | MaxVersion: sessionVers.version, |
| 6577 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6578 | }, |
| 6579 | expectedVersion: sessionVers.version, |
| 6580 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6581 | MaxVersion: resumeVers.version, |
| 6582 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6583 | }, |
| 6584 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6585 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6586 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6587 | flags: []string{ |
| 6588 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6589 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6590 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6591 | }) |
| 6592 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6593 | testCases = append(testCases, testCase{ |
| 6594 | protocol: protocol, |
| 6595 | testType: serverTest, |
| 6596 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6597 | resumeSession: true, |
| 6598 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6599 | MaxVersion: sessionVers.version, |
| 6600 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6601 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6602 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6603 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6604 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6605 | MaxVersion: resumeVers.version, |
| 6606 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6607 | Bugs: ProtocolBugs{ |
| 6608 | SendBothTickets: true, |
| 6609 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6610 | }, |
| 6611 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6612 | flags: []string{ |
| 6613 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6614 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6615 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6616 | }) |
| 6617 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6618 | } |
| 6619 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6620 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6621 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6622 | testCases = append(testCases, testCase{ |
| 6623 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6624 | name: "ShimTicketRewritable", |
| 6625 | resumeSession: true, |
| 6626 | config: Config{ |
| 6627 | MaxVersion: VersionTLS12, |
| 6628 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6629 | Bugs: ProtocolBugs{ |
| 6630 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6631 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6632 | if err != nil { |
| 6633 | return nil, err |
| 6634 | } |
| 6635 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6636 | }, |
| 6637 | }, |
| 6638 | }, |
| 6639 | flags: []string{ |
| 6640 | "-ticket-key", |
| 6641 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6642 | }, |
| 6643 | }) |
| 6644 | |
| 6645 | // Resumptions are declined if the version does not match. |
| 6646 | testCases = append(testCases, testCase{ |
| 6647 | testType: serverTest, |
| 6648 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6649 | resumeSession: true, |
| 6650 | config: Config{ |
| 6651 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6652 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6653 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6654 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6655 | return SetShimTicketVersion(in, VersionTLS13) |
| 6656 | }, |
| 6657 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6658 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6659 | flags: []string{ |
| 6660 | "-ticket-key", |
| 6661 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6662 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6663 | expectResumeRejected: true, |
| 6664 | }) |
| 6665 | |
| 6666 | testCases = append(testCases, testCase{ |
| 6667 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6668 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6669 | resumeSession: true, |
| 6670 | config: Config{ |
| 6671 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6672 | Bugs: ProtocolBugs{ |
| 6673 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6674 | return SetShimTicketVersion(in, VersionTLS12) |
| 6675 | }, |
| 6676 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6677 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6678 | flags: []string{ |
| 6679 | "-ticket-key", |
| 6680 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6681 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6682 | expectResumeRejected: true, |
| 6683 | }) |
| 6684 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6685 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6686 | testCases = append(testCases, testCase{ |
| 6687 | testType: serverTest, |
| 6688 | name: "Resume-Server-DeclineBadCipher", |
| 6689 | resumeSession: true, |
| 6690 | config: Config{ |
| 6691 | MaxVersion: VersionTLS12, |
| 6692 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6693 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6694 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6695 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6696 | }, |
| 6697 | }, |
| 6698 | }, |
| 6699 | flags: []string{ |
| 6700 | "-ticket-key", |
| 6701 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6702 | }, |
| 6703 | expectResumeRejected: true, |
| 6704 | }) |
| 6705 | |
| 6706 | testCases = append(testCases, testCase{ |
| 6707 | testType: serverTest, |
| 6708 | name: "Resume-Server-DeclineBadCipher-2", |
| 6709 | resumeSession: true, |
| 6710 | config: Config{ |
| 6711 | MaxVersion: VersionTLS12, |
| 6712 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6713 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6714 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6715 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6716 | }, |
| 6717 | }, |
| 6718 | }, |
| 6719 | flags: []string{ |
| 6720 | "-cipher", "AES128", |
| 6721 | "-ticket-key", |
| 6722 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6723 | }, |
| 6724 | expectResumeRejected: true, |
| 6725 | }) |
| 6726 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6727 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6728 | testCases = append(testCases, testCase{ |
| 6729 | testType: serverTest, |
| 6730 | name: "Resume-Server-CipherNotPreferred", |
| 6731 | resumeSession: true, |
| 6732 | config: Config{ |
| 6733 | MaxVersion: VersionTLS12, |
| 6734 | Bugs: ProtocolBugs{ |
| 6735 | ExpectNewTicket: true, |
| 6736 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6737 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6738 | }, |
| 6739 | }, |
| 6740 | }, |
| 6741 | flags: []string{ |
| 6742 | "-ticket-key", |
| 6743 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6744 | }, |
| 6745 | shouldFail: false, |
| 6746 | expectResumeRejected: true, |
| 6747 | }) |
| 6748 | |
| 6749 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6750 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6751 | testCases = append(testCases, testCase{ |
| 6752 | testType: serverTest, |
| 6753 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6754 | resumeSession: true, |
| 6755 | config: Config{ |
| 6756 | MaxVersion: VersionTLS13, |
| 6757 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6758 | Bugs: ProtocolBugs{ |
| 6759 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6760 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6761 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6762 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6763 | }, |
| 6764 | }, |
| 6765 | }, |
| 6766 | flags: []string{ |
| 6767 | "-ticket-key", |
| 6768 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6769 | }, |
| 6770 | shouldFail: false, |
| 6771 | expectResumeRejected: true, |
| 6772 | }) |
| 6773 | |
| 6774 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6775 | testCases = append(testCases, testCase{ |
| 6776 | testType: serverTest, |
| 6777 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6778 | resumeSession: true, |
| 6779 | config: Config{ |
| 6780 | MaxVersion: VersionTLS13, |
| 6781 | Bugs: ProtocolBugs{ |
| 6782 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6783 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6784 | }, |
| 6785 | }, |
| 6786 | }, |
| 6787 | flags: []string{ |
| 6788 | "-ticket-key", |
| 6789 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6790 | }, |
| 6791 | expectResumeRejected: true, |
| 6792 | }) |
| 6793 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6794 | // If the client does not offer the cipher from the session, decline to |
| 6795 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6796 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6797 | testCases = append(testCases, testCase{ |
| 6798 | testType: serverTest, |
| 6799 | name: "Resume-Server-UnofferedCipher", |
| 6800 | resumeSession: true, |
| 6801 | config: Config{ |
| 6802 | MaxVersion: VersionTLS12, |
| 6803 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6804 | }, |
| 6805 | resumeConfig: &Config{ |
| 6806 | MaxVersion: VersionTLS12, |
| 6807 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6808 | Bugs: ProtocolBugs{ |
| 6809 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6810 | }, |
| 6811 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6812 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6813 | }) |
| 6814 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6815 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6816 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6817 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6818 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6819 | testCases = append(testCases, testCase{ |
| 6820 | testType: serverTest, |
| 6821 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6822 | resumeSession: true, |
| 6823 | config: Config{ |
| 6824 | MaxVersion: VersionTLS13, |
| 6825 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6826 | }, |
| 6827 | resumeConfig: &Config{ |
| 6828 | MaxVersion: VersionTLS13, |
| 6829 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6830 | Bugs: ProtocolBugs{ |
| 6831 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6832 | }, |
| 6833 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6834 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6835 | }) |
| 6836 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6837 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6838 | testCases = append(testCases, testCase{ |
| 6839 | name: "Resume-Client-CipherMismatch", |
| 6840 | resumeSession: true, |
| 6841 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6842 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6843 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6844 | }, |
| 6845 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6846 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6847 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6848 | Bugs: ProtocolBugs{ |
| 6849 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6850 | }, |
| 6851 | }, |
| 6852 | shouldFail: true, |
| 6853 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6854 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6855 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6856 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6857 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6858 | testCases = append(testCases, testCase{ |
| 6859 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6860 | resumeSession: true, |
| 6861 | config: Config{ |
| 6862 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6863 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6864 | }, |
| 6865 | resumeConfig: &Config{ |
| 6866 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6867 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6868 | }, |
| 6869 | }) |
| 6870 | |
| 6871 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6872 | testCases = append(testCases, testCase{ |
| 6873 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6874 | resumeSession: true, |
| 6875 | config: Config{ |
| 6876 | MaxVersion: VersionTLS13, |
| 6877 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6878 | }, |
| 6879 | resumeConfig: &Config{ |
| 6880 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6881 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6882 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6883 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6884 | }, |
| 6885 | }, |
| 6886 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6887 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6888 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6889 | |
| 6890 | testCases = append(testCases, testCase{ |
| 6891 | testType: serverTest, |
| 6892 | name: "Resume-Server-BinderWrongLength", |
| 6893 | resumeSession: true, |
| 6894 | config: Config{ |
| 6895 | MaxVersion: VersionTLS13, |
| 6896 | Bugs: ProtocolBugs{ |
| 6897 | SendShortPSKBinder: true, |
| 6898 | }, |
| 6899 | }, |
| 6900 | shouldFail: true, |
| 6901 | expectedLocalError: "remote error: error decrypting message", |
| 6902 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6903 | }) |
| 6904 | |
| 6905 | testCases = append(testCases, testCase{ |
| 6906 | testType: serverTest, |
| 6907 | name: "Resume-Server-NoPSKBinder", |
| 6908 | resumeSession: true, |
| 6909 | config: Config{ |
| 6910 | MaxVersion: VersionTLS13, |
| 6911 | Bugs: ProtocolBugs{ |
| 6912 | SendNoPSKBinder: true, |
| 6913 | }, |
| 6914 | }, |
| 6915 | shouldFail: true, |
| 6916 | expectedLocalError: "remote error: error decoding message", |
| 6917 | expectedError: ":DECODE_ERROR:", |
| 6918 | }) |
| 6919 | |
| 6920 | testCases = append(testCases, testCase{ |
| 6921 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6922 | name: "Resume-Server-ExtraPSKBinder", |
| 6923 | resumeSession: true, |
| 6924 | config: Config{ |
| 6925 | MaxVersion: VersionTLS13, |
| 6926 | Bugs: ProtocolBugs{ |
| 6927 | SendExtraPSKBinder: true, |
| 6928 | }, |
| 6929 | }, |
| 6930 | shouldFail: true, |
| 6931 | expectedLocalError: "remote error: illegal parameter", |
| 6932 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6933 | }) |
| 6934 | |
| 6935 | testCases = append(testCases, testCase{ |
| 6936 | testType: serverTest, |
| 6937 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6938 | resumeSession: true, |
| 6939 | config: Config{ |
| 6940 | MaxVersion: VersionTLS13, |
| 6941 | Bugs: ProtocolBugs{ |
| 6942 | ExtraPSKIdentity: true, |
| 6943 | }, |
| 6944 | }, |
| 6945 | shouldFail: true, |
| 6946 | expectedLocalError: "remote error: illegal parameter", |
| 6947 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6948 | }) |
| 6949 | |
| 6950 | testCases = append(testCases, testCase{ |
| 6951 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6952 | name: "Resume-Server-InvalidPSKBinder", |
| 6953 | resumeSession: true, |
| 6954 | config: Config{ |
| 6955 | MaxVersion: VersionTLS13, |
| 6956 | Bugs: ProtocolBugs{ |
| 6957 | SendInvalidPSKBinder: true, |
| 6958 | }, |
| 6959 | }, |
| 6960 | shouldFail: true, |
| 6961 | expectedLocalError: "remote error: error decrypting message", |
| 6962 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6963 | }) |
| 6964 | |
| 6965 | testCases = append(testCases, testCase{ |
| 6966 | testType: serverTest, |
| 6967 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6968 | resumeSession: true, |
| 6969 | config: Config{ |
| 6970 | MaxVersion: VersionTLS13, |
| 6971 | Bugs: ProtocolBugs{ |
| 6972 | PSKBinderFirst: true, |
| 6973 | }, |
| 6974 | }, |
| 6975 | shouldFail: true, |
| 6976 | expectedLocalError: "remote error: illegal parameter", |
| 6977 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6978 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6979 | } |
| 6980 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6981 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6982 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6983 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6984 | testType: serverTest, |
| 6985 | name: "Renegotiate-Server-Forbidden", |
| 6986 | config: Config{ |
| 6987 | MaxVersion: VersionTLS12, |
| 6988 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6989 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6990 | shouldFail: true, |
| 6991 | expectedError: ":NO_RENEGOTIATION:", |
| 6992 | expectedLocalError: "remote error: no renegotiation", |
| 6993 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6994 | // The server shouldn't echo the renegotiation extension unless |
| 6995 | // requested by the client. |
| 6996 | testCases = append(testCases, testCase{ |
| 6997 | testType: serverTest, |
| 6998 | name: "Renegotiate-Server-NoExt", |
| 6999 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7000 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7001 | Bugs: ProtocolBugs{ |
| 7002 | NoRenegotiationInfo: true, |
| 7003 | RequireRenegotiationInfo: true, |
| 7004 | }, |
| 7005 | }, |
| 7006 | shouldFail: true, |
| 7007 | expectedLocalError: "renegotiation extension missing", |
| 7008 | }) |
| 7009 | // The renegotiation SCSV should be sufficient for the server to echo |
| 7010 | // the extension. |
| 7011 | testCases = append(testCases, testCase{ |
| 7012 | testType: serverTest, |
| 7013 | name: "Renegotiate-Server-NoExt-SCSV", |
| 7014 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7015 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7016 | Bugs: ProtocolBugs{ |
| 7017 | NoRenegotiationInfo: true, |
| 7018 | SendRenegotiationSCSV: true, |
| 7019 | RequireRenegotiationInfo: true, |
| 7020 | }, |
| 7021 | }, |
| 7022 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7023 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7024 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7025 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7026 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7027 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7028 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7029 | }, |
| 7030 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7031 | renegotiate: 1, |
| 7032 | flags: []string{ |
| 7033 | "-renegotiate-freely", |
| 7034 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7035 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7036 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7037 | }) |
| 7038 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7039 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7040 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7041 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7042 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7043 | Bugs: ProtocolBugs{ |
| 7044 | EmptyRenegotiationInfo: true, |
| 7045 | }, |
| 7046 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7047 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7048 | shouldFail: true, |
| 7049 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7050 | }) |
| 7051 | testCases = append(testCases, testCase{ |
| 7052 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7053 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7054 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7055 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7056 | Bugs: ProtocolBugs{ |
| 7057 | BadRenegotiationInfo: true, |
| 7058 | }, |
| 7059 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7060 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7061 | shouldFail: true, |
| 7062 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7063 | }) |
| 7064 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7065 | name: "Renegotiate-Client-BadExt2", |
| 7066 | renegotiate: 1, |
| 7067 | config: Config{ |
| 7068 | MaxVersion: VersionTLS12, |
| 7069 | Bugs: ProtocolBugs{ |
| 7070 | BadRenegotiationInfoEnd: true, |
| 7071 | }, |
| 7072 | }, |
| 7073 | flags: []string{"-renegotiate-freely"}, |
| 7074 | shouldFail: true, |
| 7075 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7076 | }) |
| 7077 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7078 | name: "Renegotiate-Client-Downgrade", |
| 7079 | renegotiate: 1, |
| 7080 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7081 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7082 | Bugs: ProtocolBugs{ |
| 7083 | NoRenegotiationInfoAfterInitial: true, |
| 7084 | }, |
| 7085 | }, |
| 7086 | flags: []string{"-renegotiate-freely"}, |
| 7087 | shouldFail: true, |
| 7088 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7089 | }) |
| 7090 | testCases = append(testCases, testCase{ |
| 7091 | name: "Renegotiate-Client-Upgrade", |
| 7092 | renegotiate: 1, |
| 7093 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7094 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7095 | Bugs: ProtocolBugs{ |
| 7096 | NoRenegotiationInfoInInitial: true, |
| 7097 | }, |
| 7098 | }, |
| 7099 | flags: []string{"-renegotiate-freely"}, |
| 7100 | shouldFail: true, |
| 7101 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 7102 | }) |
| 7103 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7104 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7105 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7106 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7107 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7108 | Bugs: ProtocolBugs{ |
| 7109 | NoRenegotiationInfo: true, |
| 7110 | }, |
| 7111 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7112 | flags: []string{ |
| 7113 | "-renegotiate-freely", |
| 7114 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7115 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7116 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7117 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7118 | |
| 7119 | // Test that the server may switch ciphers on renegotiation without |
| 7120 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7121 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7122 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7123 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7124 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7125 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7126 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7127 | }, |
| 7128 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7129 | flags: []string{ |
| 7130 | "-renegotiate-freely", |
| 7131 | "-expect-total-renegotiations", "1", |
| 7132 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7133 | }) |
| 7134 | testCases = append(testCases, testCase{ |
| 7135 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7136 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7137 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7138 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7139 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7140 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7141 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7142 | flags: []string{ |
| 7143 | "-renegotiate-freely", |
| 7144 | "-expect-total-renegotiations", "1", |
| 7145 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7146 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7147 | |
| 7148 | // Test that the server may not switch versions on renegotiation. |
| 7149 | testCases = append(testCases, testCase{ |
| 7150 | name: "Renegotiate-Client-SwitchVersion", |
| 7151 | config: Config{ |
| 7152 | MaxVersion: VersionTLS12, |
| 7153 | // Pick a cipher which exists at both versions. |
| 7154 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7155 | Bugs: ProtocolBugs{ |
| 7156 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7157 | // Avoid failing early at the record layer. |
| 7158 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7159 | }, |
| 7160 | }, |
| 7161 | renegotiate: 1, |
| 7162 | flags: []string{ |
| 7163 | "-renegotiate-freely", |
| 7164 | "-expect-total-renegotiations", "1", |
| 7165 | }, |
| 7166 | shouldFail: true, |
| 7167 | expectedError: ":WRONG_SSL_VERSION:", |
| 7168 | }) |
| 7169 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7170 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7171 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7172 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7173 | config: Config{ |
| 7174 | MaxVersion: VersionTLS10, |
| 7175 | Bugs: ProtocolBugs{ |
| 7176 | RequireSameRenegoClientVersion: true, |
| 7177 | }, |
| 7178 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7179 | flags: []string{ |
| 7180 | "-renegotiate-freely", |
| 7181 | "-expect-total-renegotiations", "1", |
| 7182 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7183 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7184 | testCases = append(testCases, testCase{ |
| 7185 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7186 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7187 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7188 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7189 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7190 | NextProtos: []string{"foo"}, |
| 7191 | }, |
| 7192 | flags: []string{ |
| 7193 | "-false-start", |
| 7194 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7195 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7196 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7197 | }, |
| 7198 | shimWritesFirst: true, |
| 7199 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7200 | |
| 7201 | // Client-side renegotiation controls. |
| 7202 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7203 | name: "Renegotiate-Client-Forbidden-1", |
| 7204 | config: Config{ |
| 7205 | MaxVersion: VersionTLS12, |
| 7206 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7207 | renegotiate: 1, |
| 7208 | shouldFail: true, |
| 7209 | expectedError: ":NO_RENEGOTIATION:", |
| 7210 | expectedLocalError: "remote error: no renegotiation", |
| 7211 | }) |
| 7212 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7213 | name: "Renegotiate-Client-Once-1", |
| 7214 | config: Config{ |
| 7215 | MaxVersion: VersionTLS12, |
| 7216 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7217 | renegotiate: 1, |
| 7218 | flags: []string{ |
| 7219 | "-renegotiate-once", |
| 7220 | "-expect-total-renegotiations", "1", |
| 7221 | }, |
| 7222 | }) |
| 7223 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7224 | name: "Renegotiate-Client-Freely-1", |
| 7225 | config: Config{ |
| 7226 | MaxVersion: VersionTLS12, |
| 7227 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7228 | renegotiate: 1, |
| 7229 | flags: []string{ |
| 7230 | "-renegotiate-freely", |
| 7231 | "-expect-total-renegotiations", "1", |
| 7232 | }, |
| 7233 | }) |
| 7234 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7235 | name: "Renegotiate-Client-Once-2", |
| 7236 | config: Config{ |
| 7237 | MaxVersion: VersionTLS12, |
| 7238 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7239 | renegotiate: 2, |
| 7240 | flags: []string{"-renegotiate-once"}, |
| 7241 | shouldFail: true, |
| 7242 | expectedError: ":NO_RENEGOTIATION:", |
| 7243 | expectedLocalError: "remote error: no renegotiation", |
| 7244 | }) |
| 7245 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7246 | name: "Renegotiate-Client-Freely-2", |
| 7247 | config: Config{ |
| 7248 | MaxVersion: VersionTLS12, |
| 7249 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7250 | renegotiate: 2, |
| 7251 | flags: []string{ |
| 7252 | "-renegotiate-freely", |
| 7253 | "-expect-total-renegotiations", "2", |
| 7254 | }, |
| 7255 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7256 | testCases = append(testCases, testCase{ |
| 7257 | name: "Renegotiate-Client-NoIgnore", |
| 7258 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7259 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7260 | Bugs: ProtocolBugs{ |
| 7261 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7262 | }, |
| 7263 | }, |
| 7264 | shouldFail: true, |
| 7265 | expectedError: ":NO_RENEGOTIATION:", |
| 7266 | }) |
| 7267 | testCases = append(testCases, testCase{ |
| 7268 | name: "Renegotiate-Client-Ignore", |
| 7269 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7270 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7271 | Bugs: ProtocolBugs{ |
| 7272 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7273 | }, |
| 7274 | }, |
| 7275 | flags: []string{ |
| 7276 | "-renegotiate-ignore", |
| 7277 | "-expect-total-renegotiations", "0", |
| 7278 | }, |
| 7279 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7280 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7281 | // Renegotiation is not allowed at SSL 3.0. |
| 7282 | testCases = append(testCases, testCase{ |
| 7283 | name: "Renegotiate-Client-SSL3", |
| 7284 | config: Config{ |
| 7285 | MaxVersion: VersionSSL30, |
| 7286 | }, |
| 7287 | renegotiate: 1, |
| 7288 | flags: []string{ |
| 7289 | "-renegotiate-freely", |
| 7290 | "-expect-total-renegotiations", "1", |
| 7291 | }, |
| 7292 | shouldFail: true, |
| 7293 | expectedError: ":NO_RENEGOTIATION:", |
| 7294 | expectedLocalError: "remote error: no renegotiation", |
| 7295 | }) |
| 7296 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7297 | // Renegotiation is not allowed when there is an unfinished write. |
| 7298 | testCases = append(testCases, testCase{ |
| 7299 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7300 | config: Config{ |
| 7301 | MaxVersion: VersionTLS12, |
| 7302 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7303 | renegotiate: 1, |
| 7304 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7305 | flags: []string{ |
| 7306 | "-async", |
| 7307 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7308 | }, |
| 7309 | shouldFail: true, |
| 7310 | expectedError: ":NO_RENEGOTIATION:", |
| 7311 | // We do not successfully send the no_renegotiation alert in |
| 7312 | // this case. https://crbug.com/boringssl/130 |
| 7313 | }) |
| 7314 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7315 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7316 | testCases = append(testCases, testCase{ |
| 7317 | name: "StrayHelloRequest", |
| 7318 | config: Config{ |
| 7319 | MaxVersion: VersionTLS12, |
| 7320 | Bugs: ProtocolBugs{ |
| 7321 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7322 | }, |
| 7323 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7324 | shouldFail: true, |
| 7325 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7326 | }) |
| 7327 | testCases = append(testCases, testCase{ |
| 7328 | name: "StrayHelloRequest-Packed", |
| 7329 | config: Config{ |
| 7330 | MaxVersion: VersionTLS12, |
| 7331 | Bugs: ProtocolBugs{ |
| 7332 | PackHandshakeFlight: true, |
| 7333 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7334 | }, |
| 7335 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7336 | shouldFail: true, |
| 7337 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7338 | }) |
| 7339 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7340 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7341 | // the same record. |
| 7342 | testCases = append(testCases, testCase{ |
| 7343 | name: "Renegotiate-Client-Packed", |
| 7344 | config: Config{ |
| 7345 | MaxVersion: VersionTLS12, |
| 7346 | Bugs: ProtocolBugs{ |
| 7347 | PackHandshakeFlight: true, |
| 7348 | PackHelloRequestWithFinished: true, |
| 7349 | }, |
| 7350 | }, |
| 7351 | renegotiate: 1, |
| 7352 | flags: []string{ |
| 7353 | "-renegotiate-freely", |
| 7354 | "-expect-total-renegotiations", "1", |
| 7355 | }, |
| 7356 | }) |
| 7357 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7358 | // Renegotiation is forbidden in TLS 1.3. |
| 7359 | testCases = append(testCases, testCase{ |
| 7360 | name: "Renegotiate-Client-TLS13", |
| 7361 | config: Config{ |
| 7362 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7363 | Bugs: ProtocolBugs{ |
| 7364 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7365 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7366 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7367 | flags: []string{ |
| 7368 | "-renegotiate-freely", |
| 7369 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7370 | shouldFail: true, |
| 7371 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7372 | }) |
| 7373 | |
| 7374 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7375 | testCases = append(testCases, testCase{ |
| 7376 | name: "StrayHelloRequest-TLS13", |
| 7377 | config: Config{ |
| 7378 | MaxVersion: VersionTLS13, |
| 7379 | Bugs: ProtocolBugs{ |
| 7380 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7381 | }, |
| 7382 | }, |
| 7383 | shouldFail: true, |
| 7384 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7385 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7386 | |
| 7387 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7388 | // always reads as supporting it, regardless of whether it was |
| 7389 | // negotiated. |
| 7390 | testCases = append(testCases, testCase{ |
| 7391 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7392 | config: Config{ |
| 7393 | MaxVersion: VersionTLS13, |
| 7394 | Bugs: ProtocolBugs{ |
| 7395 | NoRenegotiationInfo: true, |
| 7396 | }, |
| 7397 | }, |
| 7398 | flags: []string{ |
| 7399 | "-expect-secure-renegotiation", |
| 7400 | }, |
| 7401 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7402 | |
| 7403 | // Certificates may not change on renegotiation. |
| 7404 | testCases = append(testCases, testCase{ |
| 7405 | name: "Renegotiation-CertificateChange", |
| 7406 | config: Config{ |
| 7407 | MaxVersion: VersionTLS12, |
| 7408 | Certificates: []Certificate{rsaCertificate}, |
| 7409 | Bugs: ProtocolBugs{ |
| 7410 | RenegotiationCertificate: &rsaChainCertificate, |
| 7411 | }, |
| 7412 | }, |
| 7413 | renegotiate: 1, |
| 7414 | flags: []string{"-renegotiate-freely"}, |
| 7415 | shouldFail: true, |
| 7416 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7417 | }) |
| 7418 | testCases = append(testCases, testCase{ |
| 7419 | name: "Renegotiation-CertificateChange-2", |
| 7420 | config: Config{ |
| 7421 | MaxVersion: VersionTLS12, |
| 7422 | Certificates: []Certificate{rsaCertificate}, |
| 7423 | Bugs: ProtocolBugs{ |
| 7424 | RenegotiationCertificate: &rsa1024Certificate, |
| 7425 | }, |
| 7426 | }, |
| 7427 | renegotiate: 1, |
| 7428 | flags: []string{"-renegotiate-freely"}, |
| 7429 | shouldFail: true, |
| 7430 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7431 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7432 | |
| 7433 | // We do not negotiate ALPN after the initial handshake. This is |
| 7434 | // error-prone and only risks bugs in consumers. |
| 7435 | testCases = append(testCases, testCase{ |
| 7436 | testType: clientTest, |
| 7437 | name: "Renegotiation-ForbidALPN", |
| 7438 | config: Config{ |
| 7439 | MaxVersion: VersionTLS12, |
| 7440 | Bugs: ProtocolBugs{ |
| 7441 | // Forcibly negotiate ALPN on both initial and |
| 7442 | // renegotiation handshakes. The test stack will |
| 7443 | // internally check the client does not offer |
| 7444 | // it. |
| 7445 | SendALPN: "foo", |
| 7446 | }, |
| 7447 | }, |
| 7448 | flags: []string{ |
| 7449 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7450 | "-expect-alpn", "foo", |
| 7451 | "-renegotiate-freely", |
| 7452 | }, |
| 7453 | renegotiate: 1, |
| 7454 | shouldFail: true, |
| 7455 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7456 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7457 | } |
| 7458 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7459 | func addDTLSReplayTests() { |
| 7460 | // Test that sequence number replays are detected. |
| 7461 | testCases = append(testCases, testCase{ |
| 7462 | protocol: dtls, |
| 7463 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7464 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7465 | replayWrites: true, |
| 7466 | }) |
| 7467 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7468 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7469 | // than the retransmit window. |
| 7470 | testCases = append(testCases, testCase{ |
| 7471 | protocol: dtls, |
| 7472 | name: "DTLS-Replay-LargeGaps", |
| 7473 | config: Config{ |
| 7474 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7475 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7476 | return in * 127 |
| 7477 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7478 | }, |
| 7479 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7480 | messageCount: 200, |
| 7481 | replayWrites: true, |
| 7482 | }) |
| 7483 | |
| 7484 | // Test the incoming sequence number changing non-monotonically. |
| 7485 | testCases = append(testCases, testCase{ |
| 7486 | protocol: dtls, |
| 7487 | name: "DTLS-Replay-NonMonotonic", |
| 7488 | config: Config{ |
| 7489 | Bugs: ProtocolBugs{ |
| 7490 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7491 | return in ^ 31 |
| 7492 | }, |
| 7493 | }, |
| 7494 | }, |
| 7495 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7496 | replayWrites: true, |
| 7497 | }) |
| 7498 | } |
| 7499 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7500 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7501 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7502 | id signatureAlgorithm |
| 7503 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7504 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7505 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7506 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7507 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7508 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7509 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7510 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7511 | // hash function doesn't have to match the curve and so the same |
| 7512 | // signature algorithm works with P-224. |
| 7513 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7514 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7515 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7516 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7517 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7518 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7519 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7520 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7521 | // Tests for key types prior to TLS 1.2. |
| 7522 | {"RSA", 0, testCertRSA}, |
| 7523 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7524 | } |
| 7525 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7526 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7527 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7528 | |
| 7529 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7530 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7531 | // versions a signing cipher. |
| 7532 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7533 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7534 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7535 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7536 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7537 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7538 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7539 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7540 | var allAlgorithms []signatureAlgorithm |
| 7541 | for _, alg := range testSignatureAlgorithms { |
| 7542 | if alg.id != 0 { |
| 7543 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7544 | } |
| 7545 | } |
| 7546 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7547 | // Make sure each signature algorithm works. Include some fake values in |
| 7548 | // the list and ensure they're ignored. |
| 7549 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7550 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7551 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7552 | continue |
| 7553 | } |
| 7554 | |
| 7555 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7556 | // or remove it in C. |
| 7557 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7558 | continue |
| 7559 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7560 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7561 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7562 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7563 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7564 | shouldSignFail = true |
| 7565 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7566 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7567 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7568 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7569 | shouldSignFail = true |
| 7570 | shouldVerifyFail = true |
| 7571 | } |
| 7572 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7573 | // the curve has to match the hash size. |
| 7574 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7575 | shouldSignFail = true |
| 7576 | shouldVerifyFail = true |
| 7577 | } |
| 7578 | |
| 7579 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7580 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7581 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7582 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7583 | |
| 7584 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7585 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7586 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7587 | } |
| 7588 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7589 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7590 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7591 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7592 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7593 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7594 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7595 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7596 | config: Config{ |
| 7597 | MaxVersion: ver.version, |
| 7598 | ClientAuth: RequireAnyClientCert, |
| 7599 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7600 | fakeSigAlg1, |
| 7601 | alg.id, |
| 7602 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7603 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7604 | }, |
| 7605 | flags: []string{ |
| 7606 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7607 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7608 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7609 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7610 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7611 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7612 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7613 | expectedError: signError, |
| 7614 | expectedPeerSignatureAlgorithm: alg.id, |
| 7615 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7616 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7617 | testCases = append(testCases, testCase{ |
| 7618 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7619 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7620 | config: Config{ |
| 7621 | MaxVersion: ver.version, |
| 7622 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7623 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7624 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7625 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7626 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7627 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7628 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7629 | // Some signature algorithms may not be advertised. |
| 7630 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7631 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7632 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7633 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7634 | flags: []string{ |
| 7635 | "-require-any-client-certificate", |
| 7636 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7637 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7638 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7639 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7640 | // Resume the session to assert the peer signature |
| 7641 | // algorithm is reported on both handshakes. |
| 7642 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7643 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7644 | expectedError: verifyError, |
| 7645 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7646 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7647 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7648 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7649 | testCases = append(testCases, testCase{ |
| 7650 | testType: serverTest, |
| 7651 | name: "ServerAuth-Sign" + suffix, |
| 7652 | config: Config{ |
| 7653 | MaxVersion: ver.version, |
| 7654 | CipherSuites: signingCiphers, |
| 7655 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7656 | fakeSigAlg1, |
| 7657 | alg.id, |
| 7658 | fakeSigAlg2, |
| 7659 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7660 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7661 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7662 | flags: []string{ |
| 7663 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7664 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7665 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7666 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7667 | }, |
| 7668 | shouldFail: shouldSignFail, |
| 7669 | expectedError: signError, |
| 7670 | expectedPeerSignatureAlgorithm: alg.id, |
| 7671 | }) |
| 7672 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7673 | |
| 7674 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7675 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7676 | config: Config{ |
| 7677 | MaxVersion: ver.version, |
| 7678 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7679 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7680 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7681 | alg.id, |
| 7682 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7683 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7684 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7685 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7686 | // Some signature algorithms may not be advertised. |
| 7687 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7688 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7689 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7690 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7691 | flags: []string{ |
| 7692 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7693 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7694 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7695 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7696 | // Resume the session to assert the peer signature |
| 7697 | // algorithm is reported on both handshakes. |
| 7698 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7699 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7700 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7701 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7702 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7703 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7704 | testCases = append(testCases, testCase{ |
| 7705 | testType: serverTest, |
| 7706 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7707 | config: Config{ |
| 7708 | MaxVersion: ver.version, |
| 7709 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7710 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7711 | alg.id, |
| 7712 | }, |
| 7713 | Bugs: ProtocolBugs{ |
| 7714 | InvalidSignature: true, |
| 7715 | }, |
| 7716 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7717 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7718 | flags: []string{ |
| 7719 | "-require-any-client-certificate", |
| 7720 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7721 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7722 | }, |
| 7723 | shouldFail: true, |
| 7724 | expectedError: ":BAD_SIGNATURE:", |
| 7725 | }) |
| 7726 | |
| 7727 | testCases = append(testCases, testCase{ |
| 7728 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7729 | config: Config{ |
| 7730 | MaxVersion: ver.version, |
| 7731 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7732 | CipherSuites: signingCiphers, |
| 7733 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7734 | alg.id, |
| 7735 | }, |
| 7736 | Bugs: ProtocolBugs{ |
| 7737 | InvalidSignature: true, |
| 7738 | }, |
| 7739 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7740 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7741 | flags: []string{ |
| 7742 | "-enable-all-curves", |
| 7743 | "-enable-ed25519", |
| 7744 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7745 | shouldFail: true, |
| 7746 | expectedError: ":BAD_SIGNATURE:", |
| 7747 | }) |
| 7748 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7749 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7750 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7751 | testCases = append(testCases, testCase{ |
| 7752 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7753 | config: Config{ |
| 7754 | MaxVersion: ver.version, |
| 7755 | ClientAuth: RequireAnyClientCert, |
| 7756 | VerifySignatureAlgorithms: allAlgorithms, |
| 7757 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7758 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7759 | flags: []string{ |
| 7760 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7761 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7762 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7763 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7764 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7765 | }, |
| 7766 | expectedPeerSignatureAlgorithm: alg.id, |
| 7767 | }) |
| 7768 | |
| 7769 | testCases = append(testCases, testCase{ |
| 7770 | testType: serverTest, |
| 7771 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7772 | config: Config{ |
| 7773 | MaxVersion: ver.version, |
| 7774 | CipherSuites: signingCiphers, |
| 7775 | VerifySignatureAlgorithms: allAlgorithms, |
| 7776 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7777 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7778 | flags: []string{ |
| 7779 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7780 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7781 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7782 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7783 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7784 | }, |
| 7785 | expectedPeerSignatureAlgorithm: alg.id, |
| 7786 | }) |
| 7787 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7788 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7789 | } |
| 7790 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7791 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7792 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7793 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7794 | config: Config{ |
| 7795 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7796 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7797 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7798 | signatureECDSAWithP521AndSHA512, |
| 7799 | signatureRSAPKCS1WithSHA384, |
| 7800 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7801 | }, |
| 7802 | }, |
| 7803 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7804 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7805 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7806 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7807 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7808 | }) |
| 7809 | |
| 7810 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7811 | name: "ClientAuth-SignatureType-TLS13", |
| 7812 | config: Config{ |
| 7813 | ClientAuth: RequireAnyClientCert, |
| 7814 | MaxVersion: VersionTLS13, |
| 7815 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7816 | signatureECDSAWithP521AndSHA512, |
| 7817 | signatureRSAPKCS1WithSHA384, |
| 7818 | signatureRSAPSSWithSHA384, |
| 7819 | signatureECDSAWithSHA1, |
| 7820 | }, |
| 7821 | }, |
| 7822 | flags: []string{ |
| 7823 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7824 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7825 | }, |
| 7826 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7827 | }) |
| 7828 | |
| 7829 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7830 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7831 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7832 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7833 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7834 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7835 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7836 | signatureECDSAWithP521AndSHA512, |
| 7837 | signatureRSAPKCS1WithSHA384, |
| 7838 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7839 | }, |
| 7840 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7841 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7842 | }) |
| 7843 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7844 | testCases = append(testCases, testCase{ |
| 7845 | testType: serverTest, |
| 7846 | name: "ServerAuth-SignatureType-TLS13", |
| 7847 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7848 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7849 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7850 | signatureECDSAWithP521AndSHA512, |
| 7851 | signatureRSAPKCS1WithSHA384, |
| 7852 | signatureRSAPSSWithSHA384, |
| 7853 | signatureECDSAWithSHA1, |
| 7854 | }, |
| 7855 | }, |
| 7856 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7857 | }) |
| 7858 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7859 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7860 | testCases = append(testCases, testCase{ |
| 7861 | testType: serverTest, |
| 7862 | name: "Verify-ClientAuth-SignatureType", |
| 7863 | config: Config{ |
| 7864 | MaxVersion: VersionTLS12, |
| 7865 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7866 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7867 | signatureRSAPKCS1WithSHA256, |
| 7868 | }, |
| 7869 | Bugs: ProtocolBugs{ |
| 7870 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7871 | }, |
| 7872 | }, |
| 7873 | flags: []string{ |
| 7874 | "-require-any-client-certificate", |
| 7875 | }, |
| 7876 | shouldFail: true, |
| 7877 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7878 | }) |
| 7879 | |
| 7880 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7881 | testType: serverTest, |
| 7882 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7883 | config: Config{ |
| 7884 | MaxVersion: VersionTLS13, |
| 7885 | Certificates: []Certificate{rsaCertificate}, |
| 7886 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7887 | signatureRSAPSSWithSHA256, |
| 7888 | }, |
| 7889 | Bugs: ProtocolBugs{ |
| 7890 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7891 | }, |
| 7892 | }, |
| 7893 | flags: []string{ |
| 7894 | "-require-any-client-certificate", |
| 7895 | }, |
| 7896 | shouldFail: true, |
| 7897 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7898 | }) |
| 7899 | |
| 7900 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7901 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7902 | config: Config{ |
| 7903 | MaxVersion: VersionTLS12, |
| 7904 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7905 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7906 | signatureRSAPKCS1WithSHA256, |
| 7907 | }, |
| 7908 | Bugs: ProtocolBugs{ |
| 7909 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7910 | }, |
| 7911 | }, |
| 7912 | shouldFail: true, |
| 7913 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7914 | }) |
| 7915 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7916 | testCases = append(testCases, testCase{ |
| 7917 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7918 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7919 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7920 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7921 | signatureRSAPSSWithSHA256, |
| 7922 | }, |
| 7923 | Bugs: ProtocolBugs{ |
| 7924 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7925 | }, |
| 7926 | }, |
| 7927 | shouldFail: true, |
| 7928 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7929 | }) |
| 7930 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7931 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 7932 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7933 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7934 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7935 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7936 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7937 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7938 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7939 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7940 | }, |
| 7941 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7942 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7943 | }, |
| 7944 | }, |
| 7945 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7946 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7947 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7948 | }, |
| 7949 | }) |
| 7950 | |
| 7951 | testCases = append(testCases, testCase{ |
| 7952 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7953 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7954 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7955 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7956 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7957 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7958 | }, |
| 7959 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7960 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7961 | }, |
| 7962 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7963 | flags: []string{ |
| 7964 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7965 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7966 | }, |
| 7967 | }) |
| 7968 | |
| 7969 | testCases = append(testCases, testCase{ |
| 7970 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7971 | config: Config{ |
| 7972 | MaxVersion: VersionTLS12, |
| 7973 | ClientAuth: RequireAnyClientCert, |
| 7974 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7975 | signatureECDSAWithSHA1, |
| 7976 | }, |
| 7977 | Bugs: ProtocolBugs{ |
| 7978 | NoSignatureAlgorithms: true, |
| 7979 | }, |
| 7980 | }, |
| 7981 | flags: []string{ |
| 7982 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7983 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7984 | }, |
| 7985 | }) |
| 7986 | |
| 7987 | testCases = append(testCases, testCase{ |
| 7988 | testType: serverTest, |
| 7989 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 7990 | config: Config{ |
| 7991 | MaxVersion: VersionTLS12, |
| 7992 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7993 | signatureECDSAWithSHA1, |
| 7994 | }, |
| 7995 | Bugs: ProtocolBugs{ |
| 7996 | NoSignatureAlgorithms: true, |
| 7997 | }, |
| 7998 | }, |
| 7999 | flags: []string{ |
| 8000 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8001 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8002 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8003 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8004 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8005 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8006 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8007 | config: Config{ |
| 8008 | MaxVersion: VersionTLS13, |
| 8009 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8010 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8011 | signatureRSAPKCS1WithSHA1, |
| 8012 | }, |
| 8013 | Bugs: ProtocolBugs{ |
| 8014 | NoSignatureAlgorithms: true, |
| 8015 | }, |
| 8016 | }, |
| 8017 | flags: []string{ |
| 8018 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8019 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8020 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8021 | shouldFail: true, |
| 8022 | // An empty CertificateRequest signature algorithm list is a |
| 8023 | // syntax error in TLS 1.3. |
| 8024 | expectedError: ":DECODE_ERROR:", |
| 8025 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8026 | }) |
| 8027 | |
| 8028 | testCases = append(testCases, testCase{ |
| 8029 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8030 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8031 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8032 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8033 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8034 | signatureRSAPKCS1WithSHA1, |
| 8035 | }, |
| 8036 | Bugs: ProtocolBugs{ |
| 8037 | NoSignatureAlgorithms: true, |
| 8038 | }, |
| 8039 | }, |
| 8040 | shouldFail: true, |
| 8041 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8042 | }) |
| 8043 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8044 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8045 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8046 | testCases = append(testCases, testCase{ |
| 8047 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8048 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8049 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8050 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8051 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8052 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8053 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8054 | }, |
| 8055 | Bugs: ProtocolBugs{ |
| 8056 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8057 | }, |
| 8058 | }, |
| 8059 | flags: []string{"-require-any-client-certificate"}, |
| 8060 | shouldFail: true, |
| 8061 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8062 | }) |
| 8063 | |
| 8064 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8065 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8066 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8067 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8068 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8069 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8070 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8071 | }, |
| 8072 | Bugs: ProtocolBugs{ |
| 8073 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8074 | }, |
| 8075 | }, |
| 8076 | shouldFail: true, |
| 8077 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8078 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8079 | testCases = append(testCases, testCase{ |
| 8080 | testType: serverTest, |
| 8081 | name: "ClientAuth-Enforced-TLS13", |
| 8082 | config: Config{ |
| 8083 | MaxVersion: VersionTLS13, |
| 8084 | Certificates: []Certificate{rsaCertificate}, |
| 8085 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8086 | signatureRSAPKCS1WithMD5, |
| 8087 | }, |
| 8088 | Bugs: ProtocolBugs{ |
| 8089 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8090 | IgnoreSignatureVersionChecks: true, |
| 8091 | }, |
| 8092 | }, |
| 8093 | flags: []string{"-require-any-client-certificate"}, |
| 8094 | shouldFail: true, |
| 8095 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8096 | }) |
| 8097 | |
| 8098 | testCases = append(testCases, testCase{ |
| 8099 | name: "ServerAuth-Enforced-TLS13", |
| 8100 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8101 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8102 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8103 | signatureRSAPKCS1WithMD5, |
| 8104 | }, |
| 8105 | Bugs: ProtocolBugs{ |
| 8106 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8107 | IgnoreSignatureVersionChecks: true, |
| 8108 | }, |
| 8109 | }, |
| 8110 | shouldFail: true, |
| 8111 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8112 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8113 | |
| 8114 | // Test that the agreed upon digest respects the client preferences and |
| 8115 | // the server digests. |
| 8116 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8117 | name: "NoCommonAlgorithms-Digests", |
| 8118 | config: Config{ |
| 8119 | MaxVersion: VersionTLS12, |
| 8120 | ClientAuth: RequireAnyClientCert, |
| 8121 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8122 | signatureRSAPKCS1WithSHA512, |
| 8123 | signatureRSAPKCS1WithSHA1, |
| 8124 | }, |
| 8125 | }, |
| 8126 | flags: []string{ |
| 8127 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8128 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8129 | "-digest-prefs", "SHA256", |
| 8130 | }, |
| 8131 | shouldFail: true, |
| 8132 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8133 | }) |
| 8134 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8135 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8136 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8137 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8138 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8139 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8140 | signatureRSAPKCS1WithSHA512, |
| 8141 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8142 | }, |
| 8143 | }, |
| 8144 | flags: []string{ |
| 8145 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8146 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8147 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8148 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8149 | shouldFail: true, |
| 8150 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8151 | }) |
| 8152 | testCases = append(testCases, testCase{ |
| 8153 | name: "NoCommonAlgorithms-TLS13", |
| 8154 | config: Config{ |
| 8155 | MaxVersion: VersionTLS13, |
| 8156 | ClientAuth: RequireAnyClientCert, |
| 8157 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8158 | signatureRSAPSSWithSHA512, |
| 8159 | signatureRSAPSSWithSHA384, |
| 8160 | }, |
| 8161 | }, |
| 8162 | flags: []string{ |
| 8163 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8164 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8165 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 8166 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8167 | shouldFail: true, |
| 8168 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8169 | }) |
| 8170 | testCases = append(testCases, testCase{ |
| 8171 | name: "Agree-Digest-SHA256", |
| 8172 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8173 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8174 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8175 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8176 | signatureRSAPKCS1WithSHA1, |
| 8177 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8178 | }, |
| 8179 | }, |
| 8180 | flags: []string{ |
| 8181 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8182 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8183 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8184 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8185 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8186 | }) |
| 8187 | testCases = append(testCases, testCase{ |
| 8188 | name: "Agree-Digest-SHA1", |
| 8189 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8190 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8191 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8192 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8193 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8194 | }, |
| 8195 | }, |
| 8196 | flags: []string{ |
| 8197 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8198 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8199 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8200 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8201 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8202 | }) |
| 8203 | testCases = append(testCases, testCase{ |
| 8204 | name: "Agree-Digest-Default", |
| 8205 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8206 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8207 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8208 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8209 | signatureRSAPKCS1WithSHA256, |
| 8210 | signatureECDSAWithP256AndSHA256, |
| 8211 | signatureRSAPKCS1WithSHA1, |
| 8212 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8213 | }, |
| 8214 | }, |
| 8215 | flags: []string{ |
| 8216 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8217 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8218 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8219 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8220 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8221 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8222 | // Test that the signing preference list may include extra algorithms |
| 8223 | // without negotiation problems. |
| 8224 | testCases = append(testCases, testCase{ |
| 8225 | testType: serverTest, |
| 8226 | name: "FilterExtraAlgorithms", |
| 8227 | config: Config{ |
| 8228 | MaxVersion: VersionTLS12, |
| 8229 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8230 | signatureRSAPKCS1WithSHA256, |
| 8231 | }, |
| 8232 | }, |
| 8233 | flags: []string{ |
| 8234 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8235 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8236 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8237 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8238 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8239 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8240 | }, |
| 8241 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8242 | }) |
| 8243 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8244 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8245 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8246 | testCases = append(testCases, testCase{ |
| 8247 | name: "CheckLeafCurve", |
| 8248 | config: Config{ |
| 8249 | MaxVersion: VersionTLS12, |
| 8250 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8251 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8252 | }, |
| 8253 | flags: []string{"-p384-only"}, |
| 8254 | shouldFail: true, |
| 8255 | expectedError: ":BAD_ECC_CERT:", |
| 8256 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8257 | |
| 8258 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8259 | testCases = append(testCases, testCase{ |
| 8260 | name: "CheckLeafCurve-TLS13", |
| 8261 | config: Config{ |
| 8262 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8263 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8264 | }, |
| 8265 | flags: []string{"-p384-only"}, |
| 8266 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8267 | |
| 8268 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8269 | testCases = append(testCases, testCase{ |
| 8270 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8271 | config: Config{ |
| 8272 | MaxVersion: VersionTLS12, |
| 8273 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8274 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8275 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8276 | signatureECDSAWithP384AndSHA384, |
| 8277 | }, |
| 8278 | }, |
| 8279 | }) |
| 8280 | |
| 8281 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8282 | testCases = append(testCases, testCase{ |
| 8283 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8284 | config: Config{ |
| 8285 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8286 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8287 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8288 | signatureECDSAWithP384AndSHA384, |
| 8289 | }, |
| 8290 | Bugs: ProtocolBugs{ |
| 8291 | SkipECDSACurveCheck: true, |
| 8292 | }, |
| 8293 | }, |
| 8294 | shouldFail: true, |
| 8295 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8296 | }) |
| 8297 | |
| 8298 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8299 | // account. |
| 8300 | testCases = append(testCases, testCase{ |
| 8301 | testType: serverTest, |
| 8302 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8303 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8304 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8305 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8306 | signatureECDSAWithP384AndSHA384, |
| 8307 | signatureECDSAWithP256AndSHA256, |
| 8308 | }, |
| 8309 | }, |
| 8310 | flags: []string{ |
| 8311 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8312 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8313 | }, |
| 8314 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8315 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8316 | |
| 8317 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8318 | // server does not attempt to sign in that case. |
| 8319 | testCases = append(testCases, testCase{ |
| 8320 | testType: serverTest, |
| 8321 | name: "RSA-PSS-Large", |
| 8322 | config: Config{ |
| 8323 | MaxVersion: VersionTLS13, |
| 8324 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8325 | signatureRSAPSSWithSHA512, |
| 8326 | }, |
| 8327 | }, |
| 8328 | flags: []string{ |
| 8329 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8330 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8331 | }, |
| 8332 | shouldFail: true, |
| 8333 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8334 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8335 | |
| 8336 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8337 | testCases = append(testCases, testCase{ |
| 8338 | testType: clientTest, |
| 8339 | name: "RSA-PSS-Default-Verify", |
| 8340 | config: Config{ |
| 8341 | MaxVersion: VersionTLS12, |
| 8342 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8343 | signatureRSAPSSWithSHA256, |
| 8344 | }, |
| 8345 | }, |
| 8346 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8347 | }) |
| 8348 | |
| 8349 | testCases = append(testCases, testCase{ |
| 8350 | testType: serverTest, |
| 8351 | name: "RSA-PSS-Default-Sign", |
| 8352 | config: Config{ |
| 8353 | MaxVersion: VersionTLS12, |
| 8354 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8355 | signatureRSAPSSWithSHA256, |
| 8356 | }, |
| 8357 | }, |
| 8358 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8359 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8360 | |
| 8361 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8362 | // Ed25519's signature algorithm. |
| 8363 | testCases = append(testCases, testCase{ |
| 8364 | testType: clientTest, |
| 8365 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8366 | config: Config{ |
| 8367 | MaxVersion: VersionTLS11, |
| 8368 | Certificates: []Certificate{ed25519Certificate}, |
| 8369 | Bugs: ProtocolBugs{ |
| 8370 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8371 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8372 | }, |
| 8373 | }, |
| 8374 | flags: []string{"-enable-ed25519"}, |
| 8375 | shouldFail: true, |
| 8376 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8377 | }) |
| 8378 | testCases = append(testCases, testCase{ |
| 8379 | testType: serverTest, |
| 8380 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8381 | config: Config{ |
| 8382 | MaxVersion: VersionTLS11, |
| 8383 | }, |
| 8384 | flags: []string{ |
| 8385 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8386 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8387 | }, |
| 8388 | shouldFail: true, |
| 8389 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8390 | }) |
| 8391 | testCases = append(testCases, testCase{ |
| 8392 | testType: serverTest, |
| 8393 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8394 | config: Config{ |
| 8395 | MaxVersion: VersionTLS11, |
| 8396 | Certificates: []Certificate{ed25519Certificate}, |
| 8397 | Bugs: ProtocolBugs{ |
| 8398 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8399 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8400 | }, |
| 8401 | }, |
| 8402 | flags: []string{ |
| 8403 | "-enable-ed25519", |
| 8404 | "-require-any-client-certificate", |
| 8405 | }, |
| 8406 | shouldFail: true, |
| 8407 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8408 | }) |
| 8409 | testCases = append(testCases, testCase{ |
| 8410 | testType: clientTest, |
| 8411 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8412 | config: Config{ |
| 8413 | MaxVersion: VersionTLS11, |
| 8414 | ClientAuth: RequireAnyClientCert, |
| 8415 | }, |
| 8416 | flags: []string{ |
| 8417 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8418 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8419 | }, |
| 8420 | shouldFail: true, |
| 8421 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8422 | }) |
| 8423 | |
| 8424 | // Test Ed25519 is not advertised by default. |
| 8425 | testCases = append(testCases, testCase{ |
| 8426 | testType: clientTest, |
| 8427 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8428 | config: Config{ |
| 8429 | Certificates: []Certificate{ed25519Certificate}, |
| 8430 | }, |
| 8431 | shouldFail: true, |
| 8432 | expectedLocalError: "tls: no common signature algorithms", |
| 8433 | }) |
| 8434 | |
| 8435 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8436 | // preferences. |
| 8437 | testCases = append(testCases, testCase{ |
| 8438 | testType: clientTest, |
| 8439 | name: "Ed25519DefaultDisable-NoAccept", |
| 8440 | config: Config{ |
| 8441 | Certificates: []Certificate{ed25519Certificate}, |
| 8442 | Bugs: ProtocolBugs{ |
| 8443 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8444 | }, |
| 8445 | }, |
| 8446 | shouldFail: true, |
| 8447 | expectedLocalError: "remote error: illegal parameter", |
| 8448 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8449 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8450 | |
| 8451 | // Test that configuring verify preferences changes what the client |
| 8452 | // advertises. |
| 8453 | testCases = append(testCases, testCase{ |
| 8454 | name: "VerifyPreferences-Advertised", |
| 8455 | config: Config{ |
| 8456 | Certificates: []Certificate{rsaCertificate}, |
| 8457 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8458 | signatureRSAPSSWithSHA256, |
| 8459 | signatureRSAPSSWithSHA384, |
| 8460 | signatureRSAPSSWithSHA512, |
| 8461 | }, |
| 8462 | }, |
| 8463 | flags: []string{ |
| 8464 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8465 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8466 | }, |
| 8467 | }) |
| 8468 | |
| 8469 | // Test that the client advertises a set which the runner can find |
| 8470 | // nothing in common with. |
| 8471 | testCases = append(testCases, testCase{ |
| 8472 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8473 | config: Config{ |
| 8474 | Certificates: []Certificate{rsaCertificate}, |
| 8475 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8476 | signatureRSAPSSWithSHA256, |
| 8477 | signatureRSAPSSWithSHA512, |
| 8478 | }, |
| 8479 | }, |
| 8480 | flags: []string{ |
| 8481 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8482 | }, |
| 8483 | shouldFail: true, |
| 8484 | expectedLocalError: "tls: no common signature algorithms", |
| 8485 | }) |
| 8486 | |
| 8487 | // Test that the client enforces its preferences when configured. |
| 8488 | testCases = append(testCases, testCase{ |
| 8489 | name: "VerifyPreferences-Enforced", |
| 8490 | config: Config{ |
| 8491 | Certificates: []Certificate{rsaCertificate}, |
| 8492 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8493 | signatureRSAPSSWithSHA256, |
| 8494 | signatureRSAPSSWithSHA512, |
| 8495 | }, |
| 8496 | Bugs: ProtocolBugs{ |
| 8497 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8498 | }, |
| 8499 | }, |
| 8500 | flags: []string{ |
| 8501 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8502 | }, |
| 8503 | shouldFail: true, |
| 8504 | expectedLocalError: "remote error: illegal parameter", |
| 8505 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8506 | }) |
| 8507 | |
| 8508 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8509 | // boolean toggle. |
| 8510 | testCases = append(testCases, testCase{ |
| 8511 | name: "VerifyPreferences-Ed25519", |
| 8512 | config: Config{ |
| 8513 | Certificates: []Certificate{ed25519Certificate}, |
| 8514 | }, |
| 8515 | flags: []string{ |
| 8516 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8517 | }, |
| 8518 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8519 | } |
| 8520 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8521 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8522 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8523 | var timeouts = []time.Duration{ |
| 8524 | 1 * time.Second, |
| 8525 | 2 * time.Second, |
| 8526 | 4 * time.Second, |
| 8527 | 8 * time.Second, |
| 8528 | 16 * time.Second, |
| 8529 | 32 * time.Second, |
| 8530 | 60 * time.Second, |
| 8531 | 60 * time.Second, |
| 8532 | 60 * time.Second, |
| 8533 | 60 * time.Second, |
| 8534 | 60 * time.Second, |
| 8535 | 60 * time.Second, |
| 8536 | 60 * time.Second, |
| 8537 | } |
| 8538 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8539 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8540 | // initial timeout duration was set to 250ms. |
| 8541 | var shortTimeouts = []time.Duration{ |
| 8542 | 250 * time.Millisecond, |
| 8543 | 500 * time.Millisecond, |
| 8544 | 1 * time.Second, |
| 8545 | 2 * time.Second, |
| 8546 | 4 * time.Second, |
| 8547 | 8 * time.Second, |
| 8548 | 16 * time.Second, |
| 8549 | 32 * time.Second, |
| 8550 | 60 * time.Second, |
| 8551 | 60 * time.Second, |
| 8552 | 60 * time.Second, |
| 8553 | 60 * time.Second, |
| 8554 | 60 * time.Second, |
| 8555 | } |
| 8556 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8557 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8558 | // These tests work by coordinating some behavior on both the shim and |
| 8559 | // the runner. |
| 8560 | // |
| 8561 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8562 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8563 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8564 | // timeout in the shim and acts as a synchronization point to help the |
| 8565 | // runner bracket each handshake flight. |
| 8566 | // |
| 8567 | // We assume the shim does not read from the channel eagerly. It must |
| 8568 | // first wait until it has sent flight N and is ready to receive |
| 8569 | // handshake flight N+1. At this point, it will process the timeout |
| 8570 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8571 | // as if the shim was idle for the specified amount of time. |
| 8572 | // |
| 8573 | // The runner then drops all packets received before the ACK and |
| 8574 | // continues waiting for flight N. This ordering results in one attempt |
| 8575 | // at sending flight N to be dropped. For the test to complete, the |
| 8576 | // shim must send flight N again, testing that the shim implements DTLS |
| 8577 | // retransmit on a timeout. |
| 8578 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8579 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8580 | // likely be more epochs to cross and the final message's retransmit may |
| 8581 | // be more complex. |
| 8582 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8583 | // Test that this is indeed the timeout schedule. Stress all |
| 8584 | // four patterns of handshake. |
| 8585 | for i := 1; i < len(timeouts); i++ { |
| 8586 | number := strconv.Itoa(i) |
| 8587 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8588 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8589 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8590 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8591 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8592 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8593 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8594 | }, |
| 8595 | }, |
| 8596 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8597 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8598 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8599 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8600 | protocol: dtls, |
| 8601 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8602 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8603 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8604 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8605 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8606 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8607 | }, |
| 8608 | }, |
| 8609 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8610 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8611 | }) |
| 8612 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8613 | |
| 8614 | // Test that exceeding the timeout schedule hits a read |
| 8615 | // timeout. |
| 8616 | testCases = append(testCases, testCase{ |
| 8617 | protocol: dtls, |
| 8618 | name: "DTLS-Retransmit-Timeout", |
| 8619 | config: Config{ |
| 8620 | MaxVersion: VersionTLS12, |
| 8621 | Bugs: ProtocolBugs{ |
| 8622 | TimeoutSchedule: timeouts, |
| 8623 | }, |
| 8624 | }, |
| 8625 | resumeSession: true, |
| 8626 | flags: []string{"-async"}, |
| 8627 | shouldFail: true, |
| 8628 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8629 | }) |
| 8630 | |
| 8631 | // Test that timeout handling has a fudge factor, due to API |
| 8632 | // problems. |
| 8633 | testCases = append(testCases, testCase{ |
| 8634 | protocol: dtls, |
| 8635 | name: "DTLS-Retransmit-Fudge", |
| 8636 | config: Config{ |
| 8637 | MaxVersion: VersionTLS12, |
| 8638 | Bugs: ProtocolBugs{ |
| 8639 | TimeoutSchedule: []time.Duration{ |
| 8640 | timeouts[0] - 10*time.Millisecond, |
| 8641 | }, |
| 8642 | }, |
| 8643 | }, |
| 8644 | resumeSession: true, |
| 8645 | flags: []string{"-async"}, |
| 8646 | }) |
| 8647 | |
| 8648 | // Test that the final Finished retransmitting isn't |
| 8649 | // duplicated if the peer badly fragments everything. |
| 8650 | testCases = append(testCases, testCase{ |
| 8651 | testType: serverTest, |
| 8652 | protocol: dtls, |
| 8653 | name: "DTLS-Retransmit-Fragmented", |
| 8654 | config: Config{ |
| 8655 | MaxVersion: VersionTLS12, |
| 8656 | Bugs: ProtocolBugs{ |
| 8657 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8658 | MaxHandshakeRecordLength: 2, |
| 8659 | }, |
| 8660 | }, |
| 8661 | flags: []string{"-async"}, |
| 8662 | }) |
| 8663 | |
| 8664 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8665 | testCases = append(testCases, testCase{ |
| 8666 | protocol: dtls, |
| 8667 | name: "DTLS-Retransmit-Short-Client", |
| 8668 | config: Config{ |
| 8669 | MaxVersion: VersionTLS12, |
| 8670 | Bugs: ProtocolBugs{ |
| 8671 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8672 | }, |
| 8673 | }, |
| 8674 | resumeSession: true, |
| 8675 | flags: []string{ |
| 8676 | "-async", |
| 8677 | "-initial-timeout-duration-ms", "250", |
| 8678 | }, |
| 8679 | }) |
| 8680 | testCases = append(testCases, testCase{ |
| 8681 | protocol: dtls, |
| 8682 | testType: serverTest, |
| 8683 | name: "DTLS-Retransmit-Short-Server", |
| 8684 | config: Config{ |
| 8685 | MaxVersion: VersionTLS12, |
| 8686 | Bugs: ProtocolBugs{ |
| 8687 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8688 | }, |
| 8689 | }, |
| 8690 | resumeSession: true, |
| 8691 | flags: []string{ |
| 8692 | "-async", |
| 8693 | "-initial-timeout-duration-ms", "250", |
| 8694 | }, |
| 8695 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8696 | } |
| 8697 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8698 | func addExportKeyingMaterialTests() { |
| 8699 | for _, vers := range tlsVersions { |
| 8700 | if vers.version == VersionSSL30 { |
| 8701 | continue |
| 8702 | } |
| 8703 | testCases = append(testCases, testCase{ |
| 8704 | name: "ExportKeyingMaterial-" + vers.name, |
| 8705 | config: Config{ |
| 8706 | MaxVersion: vers.version, |
| 8707 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8708 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8709 | exportKeyingMaterial: 1024, |
| 8710 | exportLabel: "label", |
| 8711 | exportContext: "context", |
| 8712 | useExportContext: true, |
| 8713 | }) |
| 8714 | testCases = append(testCases, testCase{ |
| 8715 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8716 | config: Config{ |
| 8717 | MaxVersion: vers.version, |
| 8718 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8719 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8720 | exportKeyingMaterial: 1024, |
| 8721 | }) |
| 8722 | testCases = append(testCases, testCase{ |
| 8723 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8724 | config: Config{ |
| 8725 | MaxVersion: vers.version, |
| 8726 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8727 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8728 | exportKeyingMaterial: 1024, |
| 8729 | useExportContext: true, |
| 8730 | }) |
| 8731 | testCases = append(testCases, testCase{ |
| 8732 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8733 | config: Config{ |
| 8734 | MaxVersion: vers.version, |
| 8735 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8736 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8737 | exportKeyingMaterial: 1, |
| 8738 | exportLabel: "label", |
| 8739 | exportContext: "context", |
| 8740 | useExportContext: true, |
| 8741 | }) |
| 8742 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8743 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8744 | testCases = append(testCases, testCase{ |
| 8745 | name: "ExportKeyingMaterial-SSL3", |
| 8746 | config: Config{ |
| 8747 | MaxVersion: VersionSSL30, |
| 8748 | }, |
| 8749 | exportKeyingMaterial: 1024, |
| 8750 | exportLabel: "label", |
| 8751 | exportContext: "context", |
| 8752 | useExportContext: true, |
| 8753 | shouldFail: true, |
| 8754 | expectedError: "failed to export keying material", |
| 8755 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8756 | |
| 8757 | // Exporters work during a False Start. |
| 8758 | testCases = append(testCases, testCase{ |
| 8759 | name: "ExportKeyingMaterial-FalseStart", |
| 8760 | config: Config{ |
| 8761 | MaxVersion: VersionTLS12, |
| 8762 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8763 | NextProtos: []string{"foo"}, |
| 8764 | Bugs: ProtocolBugs{ |
| 8765 | ExpectFalseStart: true, |
| 8766 | }, |
| 8767 | }, |
| 8768 | flags: []string{ |
| 8769 | "-false-start", |
| 8770 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8771 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8772 | }, |
| 8773 | shimWritesFirst: true, |
| 8774 | exportKeyingMaterial: 1024, |
| 8775 | exportLabel: "label", |
| 8776 | exportContext: "context", |
| 8777 | useExportContext: true, |
| 8778 | }) |
| 8779 | |
| 8780 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8781 | // triggering the exporter after every SSL_read call and configuring the |
| 8782 | // shim to run asynchronously. |
| 8783 | testCases = append(testCases, testCase{ |
| 8784 | name: "ExportKeyingMaterial-Renegotiate", |
| 8785 | config: Config{ |
| 8786 | MaxVersion: VersionTLS12, |
| 8787 | }, |
| 8788 | renegotiate: 1, |
| 8789 | flags: []string{ |
| 8790 | "-async", |
| 8791 | "-use-exporter-between-reads", |
| 8792 | "-renegotiate-freely", |
| 8793 | "-expect-total-renegotiations", "1", |
| 8794 | }, |
| 8795 | shouldFail: true, |
| 8796 | expectedError: "failed to export keying material", |
| 8797 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8798 | } |
| 8799 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8800 | func addTLSUniqueTests() { |
| 8801 | for _, isClient := range []bool{false, true} { |
| 8802 | for _, isResumption := range []bool{false, true} { |
| 8803 | for _, hasEMS := range []bool{false, true} { |
| 8804 | var suffix string |
| 8805 | if isResumption { |
| 8806 | suffix = "Resume-" |
| 8807 | } else { |
| 8808 | suffix = "Full-" |
| 8809 | } |
| 8810 | |
| 8811 | if hasEMS { |
| 8812 | suffix += "EMS-" |
| 8813 | } else { |
| 8814 | suffix += "NoEMS-" |
| 8815 | } |
| 8816 | |
| 8817 | if isClient { |
| 8818 | suffix += "Client" |
| 8819 | } else { |
| 8820 | suffix += "Server" |
| 8821 | } |
| 8822 | |
| 8823 | test := testCase{ |
| 8824 | name: "TLSUnique-" + suffix, |
| 8825 | testTLSUnique: true, |
| 8826 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8827 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8828 | Bugs: ProtocolBugs{ |
| 8829 | NoExtendedMasterSecret: !hasEMS, |
| 8830 | }, |
| 8831 | }, |
| 8832 | } |
| 8833 | |
| 8834 | if isResumption { |
| 8835 | test.resumeSession = true |
| 8836 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8837 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8838 | Bugs: ProtocolBugs{ |
| 8839 | NoExtendedMasterSecret: !hasEMS, |
| 8840 | }, |
| 8841 | } |
| 8842 | } |
| 8843 | |
| 8844 | if isResumption && !hasEMS { |
| 8845 | test.shouldFail = true |
| 8846 | test.expectedError = "failed to get tls-unique" |
| 8847 | } |
| 8848 | |
| 8849 | testCases = append(testCases, test) |
| 8850 | } |
| 8851 | } |
| 8852 | } |
| 8853 | } |
| 8854 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8855 | func addCustomExtensionTests() { |
| 8856 | expectedContents := "custom extension" |
| 8857 | emptyString := "" |
| 8858 | |
| 8859 | for _, isClient := range []bool{false, true} { |
| 8860 | suffix := "Server" |
| 8861 | flag := "-enable-server-custom-extension" |
| 8862 | testType := serverTest |
| 8863 | if isClient { |
| 8864 | suffix = "Client" |
| 8865 | flag = "-enable-client-custom-extension" |
| 8866 | testType = clientTest |
| 8867 | } |
| 8868 | |
| 8869 | testCases = append(testCases, testCase{ |
| 8870 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8871 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8872 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8873 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8874 | Bugs: ProtocolBugs{ |
| 8875 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8876 | ExpectedCustomExtension: &expectedContents, |
| 8877 | }, |
| 8878 | }, |
| 8879 | flags: []string{flag}, |
| 8880 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8881 | testCases = append(testCases, testCase{ |
| 8882 | testType: testType, |
| 8883 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8884 | config: Config{ |
| 8885 | MaxVersion: VersionTLS13, |
| 8886 | Bugs: ProtocolBugs{ |
| 8887 | CustomExtension: expectedContents, |
| 8888 | ExpectedCustomExtension: &expectedContents, |
| 8889 | }, |
| 8890 | }, |
| 8891 | flags: []string{flag}, |
| 8892 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8893 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 8894 | // 0-RTT is not currently supported with Custom Extensions. |
| 8895 | testCases = append(testCases, testCase{ |
| 8896 | testType: testType, |
| 8897 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 8898 | config: Config{ |
| 8899 | MaxVersion: VersionTLS13, |
| 8900 | Bugs: ProtocolBugs{ |
| 8901 | CustomExtension: expectedContents, |
| 8902 | ExpectedCustomExtension: &expectedContents, |
| 8903 | }, |
| 8904 | }, |
| 8905 | shouldFail: true, |
| 8906 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8907 | flags: []string{flag, "-enable-early-data"}, |
| 8908 | }) |
| 8909 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8910 | // If the parse callback fails, the handshake should also fail. |
| 8911 | testCases = append(testCases, testCase{ |
| 8912 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8913 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8914 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8915 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8916 | Bugs: ProtocolBugs{ |
| 8917 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8918 | ExpectedCustomExtension: &expectedContents, |
| 8919 | }, |
| 8920 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8921 | flags: []string{flag}, |
| 8922 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8923 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8924 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8925 | testCases = append(testCases, testCase{ |
| 8926 | testType: testType, |
| 8927 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 8928 | config: Config{ |
| 8929 | MaxVersion: VersionTLS13, |
| 8930 | Bugs: ProtocolBugs{ |
| 8931 | CustomExtension: expectedContents + "foo", |
| 8932 | ExpectedCustomExtension: &expectedContents, |
| 8933 | }, |
| 8934 | }, |
| 8935 | flags: []string{flag}, |
| 8936 | shouldFail: true, |
| 8937 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8938 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8939 | |
| 8940 | // If the add callback fails, the handshake should also fail. |
| 8941 | testCases = append(testCases, testCase{ |
| 8942 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8943 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8944 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8945 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8946 | Bugs: ProtocolBugs{ |
| 8947 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8948 | ExpectedCustomExtension: &expectedContents, |
| 8949 | }, |
| 8950 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8951 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8952 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8953 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8954 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8955 | testCases = append(testCases, testCase{ |
| 8956 | testType: testType, |
| 8957 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 8958 | config: Config{ |
| 8959 | MaxVersion: VersionTLS13, |
| 8960 | Bugs: ProtocolBugs{ |
| 8961 | CustomExtension: expectedContents, |
| 8962 | ExpectedCustomExtension: &expectedContents, |
| 8963 | }, |
| 8964 | }, |
| 8965 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8966 | shouldFail: true, |
| 8967 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8968 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8969 | |
| 8970 | // If the add callback returns zero, no extension should be |
| 8971 | // added. |
| 8972 | skipCustomExtension := expectedContents |
| 8973 | if isClient { |
| 8974 | // For the case where the client skips sending the |
| 8975 | // custom extension, the server must not “echo” it. |
| 8976 | skipCustomExtension = "" |
| 8977 | } |
| 8978 | testCases = append(testCases, testCase{ |
| 8979 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8980 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8981 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8982 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8983 | Bugs: ProtocolBugs{ |
| 8984 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8985 | ExpectedCustomExtension: &emptyString, |
| 8986 | }, |
| 8987 | }, |
| 8988 | flags: []string{flag, "-custom-extension-skip"}, |
| 8989 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8990 | testCases = append(testCases, testCase{ |
| 8991 | testType: testType, |
| 8992 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 8993 | config: Config{ |
| 8994 | MaxVersion: VersionTLS13, |
| 8995 | Bugs: ProtocolBugs{ |
| 8996 | CustomExtension: skipCustomExtension, |
| 8997 | ExpectedCustomExtension: &emptyString, |
| 8998 | }, |
| 8999 | }, |
| 9000 | flags: []string{flag, "-custom-extension-skip"}, |
| 9001 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9002 | } |
| 9003 | |
| 9004 | // The custom extension add callback should not be called if the client |
| 9005 | // doesn't send the extension. |
| 9006 | testCases = append(testCases, testCase{ |
| 9007 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9008 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9009 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9010 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9011 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9012 | ExpectedCustomExtension: &emptyString, |
| 9013 | }, |
| 9014 | }, |
| 9015 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9016 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9017 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9018 | testCases = append(testCases, testCase{ |
| 9019 | testType: serverTest, |
| 9020 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9021 | config: Config{ |
| 9022 | MaxVersion: VersionTLS13, |
| 9023 | Bugs: ProtocolBugs{ |
| 9024 | ExpectedCustomExtension: &emptyString, |
| 9025 | }, |
| 9026 | }, |
| 9027 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9028 | }) |
| 9029 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9030 | // Test an unknown extension from the server. |
| 9031 | testCases = append(testCases, testCase{ |
| 9032 | testType: clientTest, |
| 9033 | name: "UnknownExtension-Client", |
| 9034 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9035 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9036 | Bugs: ProtocolBugs{ |
| 9037 | CustomExtension: expectedContents, |
| 9038 | }, |
| 9039 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9040 | shouldFail: true, |
| 9041 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9042 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9043 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9044 | testCases = append(testCases, testCase{ |
| 9045 | testType: clientTest, |
| 9046 | name: "UnknownExtension-Client-TLS13", |
| 9047 | config: Config{ |
| 9048 | MaxVersion: VersionTLS13, |
| 9049 | Bugs: ProtocolBugs{ |
| 9050 | CustomExtension: expectedContents, |
| 9051 | }, |
| 9052 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9053 | shouldFail: true, |
| 9054 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9055 | expectedLocalError: "remote error: unsupported extension", |
| 9056 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9057 | testCases = append(testCases, testCase{ |
| 9058 | testType: clientTest, |
| 9059 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9060 | config: Config{ |
| 9061 | MaxVersion: VersionTLS13, |
| 9062 | Bugs: ProtocolBugs{ |
| 9063 | CustomUnencryptedExtension: expectedContents, |
| 9064 | }, |
| 9065 | }, |
| 9066 | shouldFail: true, |
| 9067 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9068 | // The shim must send an alert, but alerts at this point do not |
| 9069 | // get successfully decrypted by the runner. |
| 9070 | expectedLocalError: "local error: bad record MAC", |
| 9071 | }) |
| 9072 | testCases = append(testCases, testCase{ |
| 9073 | testType: clientTest, |
| 9074 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9075 | config: Config{ |
| 9076 | MaxVersion: VersionTLS13, |
| 9077 | Bugs: ProtocolBugs{ |
| 9078 | SendUnencryptedALPN: "foo", |
| 9079 | }, |
| 9080 | }, |
| 9081 | flags: []string{ |
| 9082 | "-advertise-alpn", "\x03foo\x03bar", |
| 9083 | }, |
| 9084 | shouldFail: true, |
| 9085 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9086 | // The shim must send an alert, but alerts at this point do not |
| 9087 | // get successfully decrypted by the runner. |
| 9088 | expectedLocalError: "local error: bad record MAC", |
| 9089 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9090 | |
| 9091 | // Test a known but unoffered extension from the server. |
| 9092 | testCases = append(testCases, testCase{ |
| 9093 | testType: clientTest, |
| 9094 | name: "UnofferedExtension-Client", |
| 9095 | config: Config{ |
| 9096 | MaxVersion: VersionTLS12, |
| 9097 | Bugs: ProtocolBugs{ |
| 9098 | SendALPN: "alpn", |
| 9099 | }, |
| 9100 | }, |
| 9101 | shouldFail: true, |
| 9102 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9103 | expectedLocalError: "remote error: unsupported extension", |
| 9104 | }) |
| 9105 | testCases = append(testCases, testCase{ |
| 9106 | testType: clientTest, |
| 9107 | name: "UnofferedExtension-Client-TLS13", |
| 9108 | config: Config{ |
| 9109 | MaxVersion: VersionTLS13, |
| 9110 | Bugs: ProtocolBugs{ |
| 9111 | SendALPN: "alpn", |
| 9112 | }, |
| 9113 | }, |
| 9114 | shouldFail: true, |
| 9115 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9116 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9117 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9118 | } |
| 9119 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9120 | func addRSAClientKeyExchangeTests() { |
| 9121 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9122 | testCases = append(testCases, testCase{ |
| 9123 | testType: serverTest, |
| 9124 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9125 | config: Config{ |
| 9126 | // Ensure the ClientHello version and final |
| 9127 | // version are different, to detect if the |
| 9128 | // server uses the wrong one. |
| 9129 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9130 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9131 | Bugs: ProtocolBugs{ |
| 9132 | BadRSAClientKeyExchange: bad, |
| 9133 | }, |
| 9134 | }, |
| 9135 | shouldFail: true, |
| 9136 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9137 | }) |
| 9138 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9139 | |
| 9140 | // The server must compare whatever was in ClientHello.version for the |
| 9141 | // RSA premaster. |
| 9142 | testCases = append(testCases, testCase{ |
| 9143 | testType: serverTest, |
| 9144 | name: "SendClientVersion-RSA", |
| 9145 | config: Config{ |
| 9146 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9147 | Bugs: ProtocolBugs{ |
| 9148 | SendClientVersion: 0x1234, |
| 9149 | }, |
| 9150 | }, |
| 9151 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9152 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9153 | } |
| 9154 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9155 | var testCurves = []struct { |
| 9156 | name string |
| 9157 | id CurveID |
| 9158 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9159 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9160 | {"P-256", CurveP256}, |
| 9161 | {"P-384", CurveP384}, |
| 9162 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9163 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9164 | } |
| 9165 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9166 | const bogusCurve = 0x1234 |
| 9167 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9168 | func addCurveTests() { |
| 9169 | for _, curve := range testCurves { |
| 9170 | testCases = append(testCases, testCase{ |
| 9171 | name: "CurveTest-Client-" + curve.name, |
| 9172 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9173 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9174 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9175 | CurvePreferences: []CurveID{curve.id}, |
| 9176 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9177 | flags: []string{ |
| 9178 | "-enable-all-curves", |
| 9179 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9180 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9181 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9182 | }) |
| 9183 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9184 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9185 | config: Config{ |
| 9186 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9187 | CurvePreferences: []CurveID{curve.id}, |
| 9188 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9189 | flags: []string{ |
| 9190 | "-enable-all-curves", |
| 9191 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9192 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9193 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9194 | }) |
| 9195 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9196 | testType: serverTest, |
| 9197 | name: "CurveTest-Server-" + curve.name, |
| 9198 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9199 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9200 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9201 | CurvePreferences: []CurveID{curve.id}, |
| 9202 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9203 | flags: []string{ |
| 9204 | "-enable-all-curves", |
| 9205 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9206 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9207 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9208 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9209 | testCases = append(testCases, testCase{ |
| 9210 | testType: serverTest, |
| 9211 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9212 | config: Config{ |
| 9213 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9214 | CurvePreferences: []CurveID{curve.id}, |
| 9215 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9216 | flags: []string{ |
| 9217 | "-enable-all-curves", |
| 9218 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9219 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9220 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9221 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9222 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9223 | |
| 9224 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9225 | testCases = append(testCases, testCase{ |
| 9226 | testType: serverTest, |
| 9227 | name: "UnknownCurve", |
| 9228 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9229 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9230 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9231 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9232 | }, |
| 9233 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9234 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9235 | // The server must be tolerant to bogus curves. |
| 9236 | testCases = append(testCases, testCase{ |
| 9237 | testType: serverTest, |
| 9238 | name: "UnknownCurve-TLS13", |
| 9239 | config: Config{ |
| 9240 | MaxVersion: VersionTLS13, |
| 9241 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9242 | }, |
| 9243 | }) |
| 9244 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9245 | // The server must not consider ECDHE ciphers when there are no |
| 9246 | // supported curves. |
| 9247 | testCases = append(testCases, testCase{ |
| 9248 | testType: serverTest, |
| 9249 | name: "NoSupportedCurves", |
| 9250 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9251 | MaxVersion: VersionTLS12, |
| 9252 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9253 | Bugs: ProtocolBugs{ |
| 9254 | NoSupportedCurves: true, |
| 9255 | }, |
| 9256 | }, |
| 9257 | shouldFail: true, |
| 9258 | expectedError: ":NO_SHARED_CIPHER:", |
| 9259 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9260 | testCases = append(testCases, testCase{ |
| 9261 | testType: serverTest, |
| 9262 | name: "NoSupportedCurves-TLS13", |
| 9263 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9264 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9265 | Bugs: ProtocolBugs{ |
| 9266 | NoSupportedCurves: true, |
| 9267 | }, |
| 9268 | }, |
| 9269 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9270 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9271 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9272 | |
| 9273 | // The server must fall back to another cipher when there are no |
| 9274 | // supported curves. |
| 9275 | testCases = append(testCases, testCase{ |
| 9276 | testType: serverTest, |
| 9277 | name: "NoCommonCurves", |
| 9278 | config: Config{ |
| 9279 | MaxVersion: VersionTLS12, |
| 9280 | CipherSuites: []uint16{ |
| 9281 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9282 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9283 | }, |
| 9284 | CurvePreferences: []CurveID{CurveP224}, |
| 9285 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9286 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9287 | }) |
| 9288 | |
| 9289 | // The client must reject bogus curves and disabled curves. |
| 9290 | testCases = append(testCases, testCase{ |
| 9291 | name: "BadECDHECurve", |
| 9292 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9293 | MaxVersion: VersionTLS12, |
| 9294 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9295 | Bugs: ProtocolBugs{ |
| 9296 | SendCurve: bogusCurve, |
| 9297 | }, |
| 9298 | }, |
| 9299 | shouldFail: true, |
| 9300 | expectedError: ":WRONG_CURVE:", |
| 9301 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9302 | testCases = append(testCases, testCase{ |
| 9303 | name: "BadECDHECurve-TLS13", |
| 9304 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9305 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9306 | Bugs: ProtocolBugs{ |
| 9307 | SendCurve: bogusCurve, |
| 9308 | }, |
| 9309 | }, |
| 9310 | shouldFail: true, |
| 9311 | expectedError: ":WRONG_CURVE:", |
| 9312 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9313 | |
| 9314 | testCases = append(testCases, testCase{ |
| 9315 | name: "UnsupportedCurve", |
| 9316 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9317 | MaxVersion: VersionTLS12, |
| 9318 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9319 | CurvePreferences: []CurveID{CurveP256}, |
| 9320 | Bugs: ProtocolBugs{ |
| 9321 | IgnorePeerCurvePreferences: true, |
| 9322 | }, |
| 9323 | }, |
| 9324 | flags: []string{"-p384-only"}, |
| 9325 | shouldFail: true, |
| 9326 | expectedError: ":WRONG_CURVE:", |
| 9327 | }) |
| 9328 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9329 | testCases = append(testCases, testCase{ |
| 9330 | // TODO(davidben): Add a TLS 1.3 version where |
| 9331 | // HelloRetryRequest requests an unsupported curve. |
| 9332 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9333 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9334 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9335 | CurvePreferences: []CurveID{CurveP384}, |
| 9336 | Bugs: ProtocolBugs{ |
| 9337 | SendCurve: CurveP256, |
| 9338 | }, |
| 9339 | }, |
| 9340 | flags: []string{"-p384-only"}, |
| 9341 | shouldFail: true, |
| 9342 | expectedError: ":WRONG_CURVE:", |
| 9343 | }) |
| 9344 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9345 | // Test invalid curve points. |
| 9346 | testCases = append(testCases, testCase{ |
| 9347 | name: "InvalidECDHPoint-Client", |
| 9348 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9349 | MaxVersion: VersionTLS12, |
| 9350 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9351 | CurvePreferences: []CurveID{CurveP256}, |
| 9352 | Bugs: ProtocolBugs{ |
| 9353 | InvalidECDHPoint: true, |
| 9354 | }, |
| 9355 | }, |
| 9356 | shouldFail: true, |
| 9357 | expectedError: ":INVALID_ENCODING:", |
| 9358 | }) |
| 9359 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9360 | name: "InvalidECDHPoint-Client-TLS13", |
| 9361 | config: Config{ |
| 9362 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9363 | CurvePreferences: []CurveID{CurveP256}, |
| 9364 | Bugs: ProtocolBugs{ |
| 9365 | InvalidECDHPoint: true, |
| 9366 | }, |
| 9367 | }, |
| 9368 | shouldFail: true, |
| 9369 | expectedError: ":INVALID_ENCODING:", |
| 9370 | }) |
| 9371 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9372 | testType: serverTest, |
| 9373 | name: "InvalidECDHPoint-Server", |
| 9374 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9375 | MaxVersion: VersionTLS12, |
| 9376 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9377 | CurvePreferences: []CurveID{CurveP256}, |
| 9378 | Bugs: ProtocolBugs{ |
| 9379 | InvalidECDHPoint: true, |
| 9380 | }, |
| 9381 | }, |
| 9382 | shouldFail: true, |
| 9383 | expectedError: ":INVALID_ENCODING:", |
| 9384 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9385 | testCases = append(testCases, testCase{ |
| 9386 | testType: serverTest, |
| 9387 | name: "InvalidECDHPoint-Server-TLS13", |
| 9388 | config: Config{ |
| 9389 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9390 | CurvePreferences: []CurveID{CurveP256}, |
| 9391 | Bugs: ProtocolBugs{ |
| 9392 | InvalidECDHPoint: true, |
| 9393 | }, |
| 9394 | }, |
| 9395 | shouldFail: true, |
| 9396 | expectedError: ":INVALID_ENCODING:", |
| 9397 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9398 | |
| 9399 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9400 | testCases = append(testCases, testCase{ |
| 9401 | name: "CurveID-Resume-Client", |
| 9402 | config: Config{ |
| 9403 | MaxVersion: VersionTLS12, |
| 9404 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9405 | CurvePreferences: []CurveID{CurveX25519}, |
| 9406 | }, |
| 9407 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9408 | resumeSession: true, |
| 9409 | }) |
| 9410 | testCases = append(testCases, testCase{ |
| 9411 | testType: serverTest, |
| 9412 | name: "CurveID-Resume-Server", |
| 9413 | config: Config{ |
| 9414 | MaxVersion: VersionTLS12, |
| 9415 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9416 | CurvePreferences: []CurveID{CurveX25519}, |
| 9417 | }, |
| 9418 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9419 | resumeSession: true, |
| 9420 | }) |
| 9421 | |
| 9422 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9423 | // one should be reported. |
| 9424 | testCases = append(testCases, testCase{ |
| 9425 | name: "CurveID-Resume-Client-TLS13", |
| 9426 | config: Config{ |
| 9427 | MaxVersion: VersionTLS13, |
| 9428 | CurvePreferences: []CurveID{CurveX25519}, |
| 9429 | }, |
| 9430 | resumeConfig: &Config{ |
| 9431 | MaxVersion: VersionTLS13, |
| 9432 | CurvePreferences: []CurveID{CurveP256}, |
| 9433 | }, |
| 9434 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9435 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9436 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9437 | }, |
| 9438 | resumeSession: true, |
| 9439 | }) |
| 9440 | testCases = append(testCases, testCase{ |
| 9441 | testType: serverTest, |
| 9442 | name: "CurveID-Resume-Server-TLS13", |
| 9443 | config: Config{ |
| 9444 | MaxVersion: VersionTLS13, |
| 9445 | CurvePreferences: []CurveID{CurveX25519}, |
| 9446 | }, |
| 9447 | resumeConfig: &Config{ |
| 9448 | MaxVersion: VersionTLS13, |
| 9449 | CurvePreferences: []CurveID{CurveP256}, |
| 9450 | }, |
| 9451 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9452 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9453 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9454 | }, |
| 9455 | resumeSession: true, |
| 9456 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9457 | |
| 9458 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9459 | testCases = append(testCases, testCase{ |
| 9460 | name: "PointFormat-ServerHello-TLS12", |
| 9461 | config: Config{ |
| 9462 | MaxVersion: VersionTLS12, |
| 9463 | Bugs: ProtocolBugs{ |
| 9464 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9465 | }, |
| 9466 | }, |
| 9467 | }) |
| 9468 | testCases = append(testCases, testCase{ |
| 9469 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9470 | config: Config{ |
| 9471 | MaxVersion: VersionTLS13, |
| 9472 | Bugs: ProtocolBugs{ |
| 9473 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9474 | }, |
| 9475 | }, |
| 9476 | shouldFail: true, |
| 9477 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9478 | }) |
| 9479 | |
| 9480 | // Test that we tolerate unknown point formats, as long as |
| 9481 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9482 | // check they are still functional. |
| 9483 | testCases = append(testCases, testCase{ |
| 9484 | name: "PointFormat-Client-Tolerance", |
| 9485 | config: Config{ |
| 9486 | MaxVersion: VersionTLS12, |
| 9487 | Bugs: ProtocolBugs{ |
| 9488 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9489 | }, |
| 9490 | }, |
| 9491 | }) |
| 9492 | testCases = append(testCases, testCase{ |
| 9493 | testType: serverTest, |
| 9494 | name: "PointFormat-Server-Tolerance", |
| 9495 | config: Config{ |
| 9496 | MaxVersion: VersionTLS12, |
| 9497 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9498 | Bugs: ProtocolBugs{ |
| 9499 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9500 | }, |
| 9501 | }, |
| 9502 | }) |
| 9503 | |
| 9504 | // Test TLS 1.2 does not require the point format extension to be |
| 9505 | // present. |
| 9506 | testCases = append(testCases, testCase{ |
| 9507 | name: "PointFormat-Client-Missing", |
| 9508 | config: Config{ |
| 9509 | MaxVersion: VersionTLS12, |
| 9510 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9511 | Bugs: ProtocolBugs{ |
| 9512 | SendSupportedPointFormats: []byte{}, |
| 9513 | }, |
| 9514 | }, |
| 9515 | }) |
| 9516 | testCases = append(testCases, testCase{ |
| 9517 | testType: serverTest, |
| 9518 | name: "PointFormat-Server-Missing", |
| 9519 | config: Config{ |
| 9520 | MaxVersion: VersionTLS12, |
| 9521 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9522 | Bugs: ProtocolBugs{ |
| 9523 | SendSupportedPointFormats: []byte{}, |
| 9524 | }, |
| 9525 | }, |
| 9526 | }) |
| 9527 | |
| 9528 | // If the point format extension is present, uncompressed points must be |
| 9529 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9530 | testCases = append(testCases, testCase{ |
| 9531 | name: "PointFormat-Client-MissingUncompressed", |
| 9532 | config: Config{ |
| 9533 | MaxVersion: VersionTLS12, |
| 9534 | Bugs: ProtocolBugs{ |
| 9535 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9536 | }, |
| 9537 | }, |
| 9538 | shouldFail: true, |
| 9539 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9540 | }) |
| 9541 | testCases = append(testCases, testCase{ |
| 9542 | testType: serverTest, |
| 9543 | name: "PointFormat-Server-MissingUncompressed", |
| 9544 | config: Config{ |
| 9545 | MaxVersion: VersionTLS12, |
| 9546 | Bugs: ProtocolBugs{ |
| 9547 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9548 | }, |
| 9549 | }, |
| 9550 | shouldFail: true, |
| 9551 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9552 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9553 | } |
| 9554 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9555 | func addTLS13RecordTests() { |
| 9556 | testCases = append(testCases, testCase{ |
| 9557 | name: "TLS13-RecordPadding", |
| 9558 | config: Config{ |
| 9559 | MaxVersion: VersionTLS13, |
| 9560 | MinVersion: VersionTLS13, |
| 9561 | Bugs: ProtocolBugs{ |
| 9562 | RecordPadding: 10, |
| 9563 | }, |
| 9564 | }, |
| 9565 | }) |
| 9566 | |
| 9567 | testCases = append(testCases, testCase{ |
| 9568 | name: "TLS13-EmptyRecords", |
| 9569 | config: Config{ |
| 9570 | MaxVersion: VersionTLS13, |
| 9571 | MinVersion: VersionTLS13, |
| 9572 | Bugs: ProtocolBugs{ |
| 9573 | OmitRecordContents: true, |
| 9574 | }, |
| 9575 | }, |
| 9576 | shouldFail: true, |
| 9577 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9578 | }) |
| 9579 | |
| 9580 | testCases = append(testCases, testCase{ |
| 9581 | name: "TLS13-OnlyPadding", |
| 9582 | config: Config{ |
| 9583 | MaxVersion: VersionTLS13, |
| 9584 | MinVersion: VersionTLS13, |
| 9585 | Bugs: ProtocolBugs{ |
| 9586 | OmitRecordContents: true, |
| 9587 | RecordPadding: 10, |
| 9588 | }, |
| 9589 | }, |
| 9590 | shouldFail: true, |
| 9591 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9592 | }) |
| 9593 | |
| 9594 | testCases = append(testCases, testCase{ |
| 9595 | name: "TLS13-WrongOuterRecord", |
| 9596 | config: Config{ |
| 9597 | MaxVersion: VersionTLS13, |
| 9598 | MinVersion: VersionTLS13, |
| 9599 | Bugs: ProtocolBugs{ |
| 9600 | OuterRecordType: recordTypeHandshake, |
| 9601 | }, |
| 9602 | }, |
| 9603 | shouldFail: true, |
| 9604 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9605 | }) |
| 9606 | } |
| 9607 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9608 | func addSessionTicketTests() { |
| 9609 | testCases = append(testCases, testCase{ |
| 9610 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9611 | // mean the server changed its mind on sending a ticket. |
| 9612 | name: "SendEmptySessionTicket", |
| 9613 | config: Config{ |
| 9614 | MaxVersion: VersionTLS12, |
| 9615 | Bugs: ProtocolBugs{ |
| 9616 | SendEmptySessionTicket: true, |
| 9617 | }, |
| 9618 | }, |
| 9619 | flags: []string{"-expect-no-session"}, |
| 9620 | }) |
| 9621 | |
| 9622 | // Test that the server ignores unknown PSK modes. |
| 9623 | testCases = append(testCases, testCase{ |
| 9624 | testType: serverTest, |
| 9625 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9626 | config: Config{ |
| 9627 | MaxVersion: VersionTLS13, |
| 9628 | Bugs: ProtocolBugs{ |
| 9629 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9630 | }, |
| 9631 | }, |
| 9632 | resumeSession: true, |
| 9633 | expectedResumeVersion: VersionTLS13, |
| 9634 | }) |
| 9635 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9636 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9637 | testCases = append(testCases, testCase{ |
| 9638 | testType: serverTest, |
| 9639 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9640 | config: Config{ |
| 9641 | MaxVersion: VersionTLS13, |
| 9642 | Bugs: ProtocolBugs{ |
| 9643 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9644 | ExpectNoNewSessionTicket: true, |
| 9645 | }, |
| 9646 | }, |
| 9647 | }) |
| 9648 | |
| 9649 | // 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] | 9650 | testCases = append(testCases, testCase{ |
| 9651 | testType: serverTest, |
| 9652 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9653 | config: Config{ |
| 9654 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9655 | }, |
| 9656 | resumeConfig: &Config{ |
| 9657 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9658 | Bugs: ProtocolBugs{ |
| 9659 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9660 | }, |
| 9661 | }, |
| 9662 | resumeSession: true, |
| 9663 | expectResumeRejected: true, |
| 9664 | }) |
| 9665 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9666 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9667 | testCases = append(testCases, testCase{ |
| 9668 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9669 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9670 | config: Config{ |
| 9671 | MaxVersion: VersionTLS13, |
| 9672 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9673 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9674 | }, |
| 9675 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9676 | resumeSession: true, |
| 9677 | flags: []string{ |
| 9678 | "-resumption-delay", "10", |
| 9679 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9680 | }) |
| 9681 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9682 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9683 | testCases = append(testCases, testCase{ |
| 9684 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9685 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9686 | config: Config{ |
| 9687 | MaxVersion: VersionTLS13, |
| 9688 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9689 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9690 | }, |
| 9691 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9692 | resumeSession: true, |
| 9693 | shouldFail: true, |
| 9694 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9695 | }) |
| 9696 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9697 | // Test that the server's ticket age skew reporting works. |
| 9698 | testCases = append(testCases, testCase{ |
| 9699 | testType: serverTest, |
| 9700 | name: "TLS13-TicketAgeSkew-Forward", |
| 9701 | config: Config{ |
| 9702 | MaxVersion: VersionTLS13, |
| 9703 | Bugs: ProtocolBugs{ |
| 9704 | SendTicketAge: 15 * time.Second, |
| 9705 | }, |
| 9706 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9707 | resumeSession: true, |
| 9708 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9709 | flags: []string{ |
| 9710 | "-resumption-delay", "10", |
| 9711 | "-expect-ticket-age-skew", "5", |
| 9712 | }, |
| 9713 | }) |
| 9714 | testCases = append(testCases, testCase{ |
| 9715 | testType: serverTest, |
| 9716 | name: "TLS13-TicketAgeSkew-Backward", |
| 9717 | config: Config{ |
| 9718 | MaxVersion: VersionTLS13, |
| 9719 | Bugs: ProtocolBugs{ |
| 9720 | SendTicketAge: 5 * time.Second, |
| 9721 | }, |
| 9722 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9723 | resumeSession: true, |
| 9724 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9725 | flags: []string{ |
| 9726 | "-resumption-delay", "10", |
| 9727 | "-expect-ticket-age-skew", "-5", |
| 9728 | }, |
| 9729 | }) |
| 9730 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9731 | testCases = append(testCases, testCase{ |
| 9732 | testType: clientTest, |
| 9733 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9734 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9735 | MaxVersion: VersionTLS13, |
| 9736 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9737 | }, |
| 9738 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9739 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9740 | "-expect-early-data-info", |
| 9741 | }, |
| 9742 | }) |
| 9743 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9744 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9745 | testCases = append(testCases, testCase{ |
| 9746 | testType: clientTest, |
| 9747 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9748 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9749 | MaxVersion: VersionTLS13, |
| 9750 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9751 | }, |
| 9752 | }) |
| 9753 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9754 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9755 | testType: clientTest, |
| 9756 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9757 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9758 | MaxVersion: VersionTLS13, |
| 9759 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9760 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9761 | DuplicateTicketEarlyDataInfo: true, |
| 9762 | }, |
| 9763 | }, |
| 9764 | shouldFail: true, |
| 9765 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9766 | expectedLocalError: "remote error: illegal parameter", |
| 9767 | }) |
| 9768 | |
| 9769 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9770 | testType: serverTest, |
| 9771 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9772 | config: Config{ |
| 9773 | MaxVersion: VersionTLS13, |
| 9774 | Bugs: ProtocolBugs{ |
| 9775 | ExpectTicketEarlyDataInfo: true, |
| 9776 | }, |
| 9777 | }, |
| 9778 | flags: []string{ |
| 9779 | "-enable-early-data", |
| 9780 | }, |
| 9781 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9782 | |
| 9783 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9784 | // is honored. |
| 9785 | testCases = append(testCases, testCase{ |
| 9786 | testType: clientTest, |
| 9787 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9788 | config: Config{ |
| 9789 | MaxVersion: VersionTLS13, |
| 9790 | Bugs: ProtocolBugs{ |
| 9791 | SendTicketLifetime: 20 * time.Second, |
| 9792 | }, |
| 9793 | }, |
| 9794 | flags: []string{ |
| 9795 | "-resumption-delay", "19", |
| 9796 | }, |
| 9797 | resumeSession: true, |
| 9798 | }) |
| 9799 | testCases = append(testCases, testCase{ |
| 9800 | testType: clientTest, |
| 9801 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9802 | config: Config{ |
| 9803 | MaxVersion: VersionTLS13, |
| 9804 | Bugs: ProtocolBugs{ |
| 9805 | SendTicketLifetime: 20 * time.Second, |
| 9806 | // The client should not offer the expired session. |
| 9807 | ExpectNoTLS13PSK: true, |
| 9808 | }, |
| 9809 | }, |
| 9810 | flags: []string{ |
| 9811 | "-resumption-delay", "21", |
| 9812 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9813 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9814 | expectResumeRejected: true, |
| 9815 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9816 | } |
| 9817 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9818 | func addChangeCipherSpecTests() { |
| 9819 | // Test missing ChangeCipherSpecs. |
| 9820 | testCases = append(testCases, testCase{ |
| 9821 | name: "SkipChangeCipherSpec-Client", |
| 9822 | config: Config{ |
| 9823 | MaxVersion: VersionTLS12, |
| 9824 | Bugs: ProtocolBugs{ |
| 9825 | SkipChangeCipherSpec: true, |
| 9826 | }, |
| 9827 | }, |
| 9828 | shouldFail: true, |
| 9829 | expectedError: ":UNEXPECTED_RECORD:", |
| 9830 | }) |
| 9831 | testCases = append(testCases, testCase{ |
| 9832 | testType: serverTest, |
| 9833 | name: "SkipChangeCipherSpec-Server", |
| 9834 | config: Config{ |
| 9835 | MaxVersion: VersionTLS12, |
| 9836 | Bugs: ProtocolBugs{ |
| 9837 | SkipChangeCipherSpec: true, |
| 9838 | }, |
| 9839 | }, |
| 9840 | shouldFail: true, |
| 9841 | expectedError: ":UNEXPECTED_RECORD:", |
| 9842 | }) |
| 9843 | testCases = append(testCases, testCase{ |
| 9844 | testType: serverTest, |
| 9845 | name: "SkipChangeCipherSpec-Server-NPN", |
| 9846 | config: Config{ |
| 9847 | MaxVersion: VersionTLS12, |
| 9848 | NextProtos: []string{"bar"}, |
| 9849 | Bugs: ProtocolBugs{ |
| 9850 | SkipChangeCipherSpec: true, |
| 9851 | }, |
| 9852 | }, |
| 9853 | flags: []string{ |
| 9854 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9855 | }, |
| 9856 | shouldFail: true, |
| 9857 | expectedError: ":UNEXPECTED_RECORD:", |
| 9858 | }) |
| 9859 | |
| 9860 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 9861 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 9862 | // rejected. Test both with and without handshake packing to handle both |
| 9863 | // when the partial post-CCS message is in its own record and when it is |
| 9864 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9865 | for _, packed := range []bool{false, true} { |
| 9866 | var suffix string |
| 9867 | if packed { |
| 9868 | suffix = "-Packed" |
| 9869 | } |
| 9870 | |
| 9871 | testCases = append(testCases, testCase{ |
| 9872 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 9873 | config: Config{ |
| 9874 | MaxVersion: VersionTLS12, |
| 9875 | Bugs: ProtocolBugs{ |
| 9876 | FragmentAcrossChangeCipherSpec: true, |
| 9877 | PackHandshakeFlight: packed, |
| 9878 | }, |
| 9879 | }, |
| 9880 | shouldFail: true, |
| 9881 | expectedError: ":UNEXPECTED_RECORD:", |
| 9882 | }) |
| 9883 | testCases = append(testCases, testCase{ |
| 9884 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 9885 | config: Config{ |
| 9886 | MaxVersion: VersionTLS12, |
| 9887 | }, |
| 9888 | resumeSession: true, |
| 9889 | resumeConfig: &Config{ |
| 9890 | MaxVersion: VersionTLS12, |
| 9891 | Bugs: ProtocolBugs{ |
| 9892 | FragmentAcrossChangeCipherSpec: true, |
| 9893 | PackHandshakeFlight: packed, |
| 9894 | }, |
| 9895 | }, |
| 9896 | shouldFail: true, |
| 9897 | expectedError: ":UNEXPECTED_RECORD:", |
| 9898 | }) |
| 9899 | testCases = append(testCases, testCase{ |
| 9900 | testType: serverTest, |
| 9901 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 9902 | config: Config{ |
| 9903 | MaxVersion: VersionTLS12, |
| 9904 | Bugs: ProtocolBugs{ |
| 9905 | FragmentAcrossChangeCipherSpec: true, |
| 9906 | PackHandshakeFlight: packed, |
| 9907 | }, |
| 9908 | }, |
| 9909 | shouldFail: true, |
| 9910 | expectedError: ":UNEXPECTED_RECORD:", |
| 9911 | }) |
| 9912 | testCases = append(testCases, testCase{ |
| 9913 | testType: serverTest, |
| 9914 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 9915 | config: Config{ |
| 9916 | MaxVersion: VersionTLS12, |
| 9917 | }, |
| 9918 | resumeSession: true, |
| 9919 | resumeConfig: &Config{ |
| 9920 | MaxVersion: VersionTLS12, |
| 9921 | Bugs: ProtocolBugs{ |
| 9922 | FragmentAcrossChangeCipherSpec: true, |
| 9923 | PackHandshakeFlight: packed, |
| 9924 | }, |
| 9925 | }, |
| 9926 | shouldFail: true, |
| 9927 | expectedError: ":UNEXPECTED_RECORD:", |
| 9928 | }) |
| 9929 | testCases = append(testCases, testCase{ |
| 9930 | testType: serverTest, |
| 9931 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 9932 | config: Config{ |
| 9933 | MaxVersion: VersionTLS12, |
| 9934 | NextProtos: []string{"bar"}, |
| 9935 | Bugs: ProtocolBugs{ |
| 9936 | FragmentAcrossChangeCipherSpec: true, |
| 9937 | PackHandshakeFlight: packed, |
| 9938 | }, |
| 9939 | }, |
| 9940 | flags: []string{ |
| 9941 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9942 | }, |
| 9943 | shouldFail: true, |
| 9944 | expectedError: ":UNEXPECTED_RECORD:", |
| 9945 | }) |
| 9946 | } |
| 9947 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 9948 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 9949 | // messages in the handshake queue. Do this by testing the server |
| 9950 | // reading the client Finished, reversing the flight so Finished comes |
| 9951 | // first. |
| 9952 | testCases = append(testCases, testCase{ |
| 9953 | protocol: dtls, |
| 9954 | testType: serverTest, |
| 9955 | name: "SendUnencryptedFinished-DTLS", |
| 9956 | config: Config{ |
| 9957 | MaxVersion: VersionTLS12, |
| 9958 | Bugs: ProtocolBugs{ |
| 9959 | SendUnencryptedFinished: true, |
| 9960 | ReverseHandshakeFragments: true, |
| 9961 | }, |
| 9962 | }, |
| 9963 | shouldFail: true, |
| 9964 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9965 | }) |
| 9966 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9967 | // Test synchronization between encryption changes and the handshake in |
| 9968 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 9969 | testCases = append(testCases, testCase{ |
| 9970 | name: "PartialEncryptedExtensionsWithServerHello", |
| 9971 | config: Config{ |
| 9972 | MaxVersion: VersionTLS13, |
| 9973 | Bugs: ProtocolBugs{ |
| 9974 | PartialEncryptedExtensionsWithServerHello: true, |
| 9975 | }, |
| 9976 | }, |
| 9977 | shouldFail: true, |
| 9978 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9979 | }) |
| 9980 | testCases = append(testCases, testCase{ |
| 9981 | testType: serverTest, |
| 9982 | name: "PartialClientFinishedWithClientHello", |
| 9983 | config: Config{ |
| 9984 | MaxVersion: VersionTLS13, |
| 9985 | Bugs: ProtocolBugs{ |
| 9986 | PartialClientFinishedWithClientHello: true, |
| 9987 | }, |
| 9988 | }, |
| 9989 | shouldFail: true, |
| 9990 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9991 | }) |
| 9992 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9993 | // Test that early ChangeCipherSpecs are handled correctly. |
| 9994 | testCases = append(testCases, testCase{ |
| 9995 | testType: serverTest, |
| 9996 | name: "EarlyChangeCipherSpec-server-1", |
| 9997 | config: Config{ |
| 9998 | MaxVersion: VersionTLS12, |
| 9999 | Bugs: ProtocolBugs{ |
| 10000 | EarlyChangeCipherSpec: 1, |
| 10001 | }, |
| 10002 | }, |
| 10003 | shouldFail: true, |
| 10004 | expectedError: ":UNEXPECTED_RECORD:", |
| 10005 | }) |
| 10006 | testCases = append(testCases, testCase{ |
| 10007 | testType: serverTest, |
| 10008 | name: "EarlyChangeCipherSpec-server-2", |
| 10009 | config: Config{ |
| 10010 | MaxVersion: VersionTLS12, |
| 10011 | Bugs: ProtocolBugs{ |
| 10012 | EarlyChangeCipherSpec: 2, |
| 10013 | }, |
| 10014 | }, |
| 10015 | shouldFail: true, |
| 10016 | expectedError: ":UNEXPECTED_RECORD:", |
| 10017 | }) |
| 10018 | testCases = append(testCases, testCase{ |
| 10019 | protocol: dtls, |
| 10020 | name: "StrayChangeCipherSpec", |
| 10021 | config: Config{ |
| 10022 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10023 | // that stray ChangeCipherSpec messages are |
| 10024 | // rejected. |
| 10025 | MaxVersion: VersionTLS12, |
| 10026 | Bugs: ProtocolBugs{ |
| 10027 | StrayChangeCipherSpec: true, |
| 10028 | }, |
| 10029 | }, |
| 10030 | }) |
| 10031 | |
| 10032 | // Test that the contents of ChangeCipherSpec are checked. |
| 10033 | testCases = append(testCases, testCase{ |
| 10034 | name: "BadChangeCipherSpec-1", |
| 10035 | config: Config{ |
| 10036 | MaxVersion: VersionTLS12, |
| 10037 | Bugs: ProtocolBugs{ |
| 10038 | BadChangeCipherSpec: []byte{2}, |
| 10039 | }, |
| 10040 | }, |
| 10041 | shouldFail: true, |
| 10042 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10043 | }) |
| 10044 | testCases = append(testCases, testCase{ |
| 10045 | name: "BadChangeCipherSpec-2", |
| 10046 | config: Config{ |
| 10047 | MaxVersion: VersionTLS12, |
| 10048 | Bugs: ProtocolBugs{ |
| 10049 | BadChangeCipherSpec: []byte{1, 1}, |
| 10050 | }, |
| 10051 | }, |
| 10052 | shouldFail: true, |
| 10053 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10054 | }) |
| 10055 | testCases = append(testCases, testCase{ |
| 10056 | protocol: dtls, |
| 10057 | name: "BadChangeCipherSpec-DTLS-1", |
| 10058 | config: Config{ |
| 10059 | MaxVersion: VersionTLS12, |
| 10060 | Bugs: ProtocolBugs{ |
| 10061 | BadChangeCipherSpec: []byte{2}, |
| 10062 | }, |
| 10063 | }, |
| 10064 | shouldFail: true, |
| 10065 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10066 | }) |
| 10067 | testCases = append(testCases, testCase{ |
| 10068 | protocol: dtls, |
| 10069 | name: "BadChangeCipherSpec-DTLS-2", |
| 10070 | config: Config{ |
| 10071 | MaxVersion: VersionTLS12, |
| 10072 | Bugs: ProtocolBugs{ |
| 10073 | BadChangeCipherSpec: []byte{1, 1}, |
| 10074 | }, |
| 10075 | }, |
| 10076 | shouldFail: true, |
| 10077 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10078 | }) |
| 10079 | } |
| 10080 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10081 | type perMessageTest struct { |
| 10082 | messageType uint8 |
| 10083 | test testCase |
| 10084 | } |
| 10085 | |
| 10086 | // makePerMessageTests returns a series of test templates which cover each |
| 10087 | // message in the TLS handshake. These may be used with bugs like |
| 10088 | // WrongMessageType to fully test a per-message bug. |
| 10089 | func makePerMessageTests() []perMessageTest { |
| 10090 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10091 | for _, protocol := range []protocol{tls, dtls} { |
| 10092 | var suffix string |
| 10093 | if protocol == dtls { |
| 10094 | suffix = "-DTLS" |
| 10095 | } |
| 10096 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10097 | ret = append(ret, perMessageTest{ |
| 10098 | messageType: typeClientHello, |
| 10099 | test: testCase{ |
| 10100 | protocol: protocol, |
| 10101 | testType: serverTest, |
| 10102 | name: "ClientHello" + suffix, |
| 10103 | config: Config{ |
| 10104 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10105 | }, |
| 10106 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10107 | }) |
| 10108 | |
| 10109 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10110 | ret = append(ret, perMessageTest{ |
| 10111 | messageType: typeHelloVerifyRequest, |
| 10112 | test: testCase{ |
| 10113 | protocol: protocol, |
| 10114 | name: "HelloVerifyRequest" + suffix, |
| 10115 | config: Config{ |
| 10116 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10117 | }, |
| 10118 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10119 | }) |
| 10120 | } |
| 10121 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10122 | ret = append(ret, perMessageTest{ |
| 10123 | messageType: typeServerHello, |
| 10124 | test: testCase{ |
| 10125 | protocol: protocol, |
| 10126 | name: "ServerHello" + suffix, |
| 10127 | config: Config{ |
| 10128 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10129 | }, |
| 10130 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10131 | }) |
| 10132 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10133 | ret = append(ret, perMessageTest{ |
| 10134 | messageType: typeCertificate, |
| 10135 | test: testCase{ |
| 10136 | protocol: protocol, |
| 10137 | name: "ServerCertificate" + suffix, |
| 10138 | config: Config{ |
| 10139 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10140 | }, |
| 10141 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10142 | }) |
| 10143 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10144 | ret = append(ret, perMessageTest{ |
| 10145 | messageType: typeCertificateStatus, |
| 10146 | test: testCase{ |
| 10147 | protocol: protocol, |
| 10148 | name: "CertificateStatus" + suffix, |
| 10149 | config: Config{ |
| 10150 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10151 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10152 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10153 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10154 | }) |
| 10155 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10156 | ret = append(ret, perMessageTest{ |
| 10157 | messageType: typeServerKeyExchange, |
| 10158 | test: testCase{ |
| 10159 | protocol: protocol, |
| 10160 | name: "ServerKeyExchange" + suffix, |
| 10161 | config: Config{ |
| 10162 | MaxVersion: VersionTLS12, |
| 10163 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10164 | }, |
| 10165 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10166 | }) |
| 10167 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10168 | ret = append(ret, perMessageTest{ |
| 10169 | messageType: typeCertificateRequest, |
| 10170 | test: testCase{ |
| 10171 | protocol: protocol, |
| 10172 | name: "CertificateRequest" + suffix, |
| 10173 | config: Config{ |
| 10174 | MaxVersion: VersionTLS12, |
| 10175 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10176 | }, |
| 10177 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10178 | }) |
| 10179 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10180 | ret = append(ret, perMessageTest{ |
| 10181 | messageType: typeServerHelloDone, |
| 10182 | test: testCase{ |
| 10183 | protocol: protocol, |
| 10184 | name: "ServerHelloDone" + suffix, |
| 10185 | config: Config{ |
| 10186 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10187 | }, |
| 10188 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10189 | }) |
| 10190 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10191 | ret = append(ret, perMessageTest{ |
| 10192 | messageType: typeCertificate, |
| 10193 | test: testCase{ |
| 10194 | testType: serverTest, |
| 10195 | protocol: protocol, |
| 10196 | name: "ClientCertificate" + suffix, |
| 10197 | config: Config{ |
| 10198 | Certificates: []Certificate{rsaCertificate}, |
| 10199 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10200 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10201 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10202 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10203 | }) |
| 10204 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10205 | ret = append(ret, perMessageTest{ |
| 10206 | messageType: typeCertificateVerify, |
| 10207 | test: testCase{ |
| 10208 | testType: serverTest, |
| 10209 | protocol: protocol, |
| 10210 | name: "CertificateVerify" + suffix, |
| 10211 | config: Config{ |
| 10212 | Certificates: []Certificate{rsaCertificate}, |
| 10213 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10214 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10215 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10216 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10217 | }) |
| 10218 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10219 | ret = append(ret, perMessageTest{ |
| 10220 | messageType: typeClientKeyExchange, |
| 10221 | test: testCase{ |
| 10222 | testType: serverTest, |
| 10223 | protocol: protocol, |
| 10224 | name: "ClientKeyExchange" + suffix, |
| 10225 | config: Config{ |
| 10226 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10227 | }, |
| 10228 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10229 | }) |
| 10230 | |
| 10231 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10232 | ret = append(ret, perMessageTest{ |
| 10233 | messageType: typeNextProtocol, |
| 10234 | test: testCase{ |
| 10235 | testType: serverTest, |
| 10236 | protocol: protocol, |
| 10237 | name: "NextProtocol" + suffix, |
| 10238 | config: Config{ |
| 10239 | MaxVersion: VersionTLS12, |
| 10240 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10241 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10242 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10243 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10244 | }) |
| 10245 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10246 | ret = append(ret, perMessageTest{ |
| 10247 | messageType: typeChannelID, |
| 10248 | test: testCase{ |
| 10249 | testType: serverTest, |
| 10250 | protocol: protocol, |
| 10251 | name: "ChannelID" + suffix, |
| 10252 | config: Config{ |
| 10253 | MaxVersion: VersionTLS12, |
| 10254 | ChannelID: channelIDKey, |
| 10255 | }, |
| 10256 | flags: []string{ |
| 10257 | "-expect-channel-id", |
| 10258 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10259 | }, |
| 10260 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10261 | }) |
| 10262 | } |
| 10263 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10264 | ret = append(ret, perMessageTest{ |
| 10265 | messageType: typeFinished, |
| 10266 | test: testCase{ |
| 10267 | testType: serverTest, |
| 10268 | protocol: protocol, |
| 10269 | name: "ClientFinished" + suffix, |
| 10270 | config: Config{ |
| 10271 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10272 | }, |
| 10273 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10274 | }) |
| 10275 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10276 | ret = append(ret, perMessageTest{ |
| 10277 | messageType: typeNewSessionTicket, |
| 10278 | test: testCase{ |
| 10279 | protocol: protocol, |
| 10280 | name: "NewSessionTicket" + suffix, |
| 10281 | config: Config{ |
| 10282 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10283 | }, |
| 10284 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10285 | }) |
| 10286 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10287 | ret = append(ret, perMessageTest{ |
| 10288 | messageType: typeFinished, |
| 10289 | test: testCase{ |
| 10290 | protocol: protocol, |
| 10291 | name: "ServerFinished" + suffix, |
| 10292 | config: Config{ |
| 10293 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10294 | }, |
| 10295 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10296 | }) |
| 10297 | |
| 10298 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10299 | |
| 10300 | ret = append(ret, perMessageTest{ |
| 10301 | messageType: typeClientHello, |
| 10302 | test: testCase{ |
| 10303 | testType: serverTest, |
| 10304 | name: "TLS13-ClientHello", |
| 10305 | config: Config{ |
| 10306 | MaxVersion: VersionTLS13, |
| 10307 | }, |
| 10308 | }, |
| 10309 | }) |
| 10310 | |
| 10311 | ret = append(ret, perMessageTest{ |
| 10312 | messageType: typeServerHello, |
| 10313 | test: testCase{ |
| 10314 | name: "TLS13-ServerHello", |
| 10315 | config: Config{ |
| 10316 | MaxVersion: VersionTLS13, |
| 10317 | }, |
| 10318 | }, |
| 10319 | }) |
| 10320 | |
| 10321 | ret = append(ret, perMessageTest{ |
| 10322 | messageType: typeEncryptedExtensions, |
| 10323 | test: testCase{ |
| 10324 | name: "TLS13-EncryptedExtensions", |
| 10325 | config: Config{ |
| 10326 | MaxVersion: VersionTLS13, |
| 10327 | }, |
| 10328 | }, |
| 10329 | }) |
| 10330 | |
| 10331 | ret = append(ret, perMessageTest{ |
| 10332 | messageType: typeCertificateRequest, |
| 10333 | test: testCase{ |
| 10334 | name: "TLS13-CertificateRequest", |
| 10335 | config: Config{ |
| 10336 | MaxVersion: VersionTLS13, |
| 10337 | ClientAuth: RequireAnyClientCert, |
| 10338 | }, |
| 10339 | }, |
| 10340 | }) |
| 10341 | |
| 10342 | ret = append(ret, perMessageTest{ |
| 10343 | messageType: typeCertificate, |
| 10344 | test: testCase{ |
| 10345 | name: "TLS13-ServerCertificate", |
| 10346 | config: Config{ |
| 10347 | MaxVersion: VersionTLS13, |
| 10348 | }, |
| 10349 | }, |
| 10350 | }) |
| 10351 | |
| 10352 | ret = append(ret, perMessageTest{ |
| 10353 | messageType: typeCertificateVerify, |
| 10354 | test: testCase{ |
| 10355 | name: "TLS13-ServerCertificateVerify", |
| 10356 | config: Config{ |
| 10357 | MaxVersion: VersionTLS13, |
| 10358 | }, |
| 10359 | }, |
| 10360 | }) |
| 10361 | |
| 10362 | ret = append(ret, perMessageTest{ |
| 10363 | messageType: typeFinished, |
| 10364 | test: testCase{ |
| 10365 | name: "TLS13-ServerFinished", |
| 10366 | config: Config{ |
| 10367 | MaxVersion: VersionTLS13, |
| 10368 | }, |
| 10369 | }, |
| 10370 | }) |
| 10371 | |
| 10372 | ret = append(ret, perMessageTest{ |
| 10373 | messageType: typeCertificate, |
| 10374 | test: testCase{ |
| 10375 | testType: serverTest, |
| 10376 | name: "TLS13-ClientCertificate", |
| 10377 | config: Config{ |
| 10378 | Certificates: []Certificate{rsaCertificate}, |
| 10379 | MaxVersion: VersionTLS13, |
| 10380 | }, |
| 10381 | flags: []string{"-require-any-client-certificate"}, |
| 10382 | }, |
| 10383 | }) |
| 10384 | |
| 10385 | ret = append(ret, perMessageTest{ |
| 10386 | messageType: typeCertificateVerify, |
| 10387 | test: testCase{ |
| 10388 | testType: serverTest, |
| 10389 | name: "TLS13-ClientCertificateVerify", |
| 10390 | config: Config{ |
| 10391 | Certificates: []Certificate{rsaCertificate}, |
| 10392 | MaxVersion: VersionTLS13, |
| 10393 | }, |
| 10394 | flags: []string{"-require-any-client-certificate"}, |
| 10395 | }, |
| 10396 | }) |
| 10397 | |
| 10398 | ret = append(ret, perMessageTest{ |
| 10399 | messageType: typeFinished, |
| 10400 | test: testCase{ |
| 10401 | testType: serverTest, |
| 10402 | name: "TLS13-ClientFinished", |
| 10403 | config: Config{ |
| 10404 | MaxVersion: VersionTLS13, |
| 10405 | }, |
| 10406 | }, |
| 10407 | }) |
| 10408 | |
| 10409 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10410 | } |
| 10411 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10412 | func addWrongMessageTypeTests() { |
| 10413 | for _, t := range makePerMessageTests() { |
| 10414 | t.test.name = "WrongMessageType-" + t.test.name |
| 10415 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10416 | t.test.shouldFail = true |
| 10417 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10418 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10419 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10420 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10421 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10422 | // an unencrypted alert while the server expects |
| 10423 | // encryption, so the alert is not readable by runner. |
| 10424 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10425 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10426 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10427 | testCases = append(testCases, t.test) |
| 10428 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10429 | |
| 10430 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10431 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10432 | // TLS 1.2. Test that we do not do this. |
| 10433 | testCases = append(testCases, testCase{ |
| 10434 | name: "SendServerHelloAsHelloRetryRequest", |
| 10435 | config: Config{ |
| 10436 | MaxVersion: VersionTLS12, |
| 10437 | Bugs: ProtocolBugs{ |
| 10438 | SendServerHelloAsHelloRetryRequest: true, |
| 10439 | }, |
| 10440 | }, |
| 10441 | shouldFail: true, |
| 10442 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10443 | expectedLocalError: "remote error: unexpected message", |
| 10444 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10445 | } |
| 10446 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10447 | func addTrailingMessageDataTests() { |
| 10448 | for _, t := range makePerMessageTests() { |
| 10449 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10450 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10451 | t.test.shouldFail = true |
| 10452 | t.test.expectedError = ":DECODE_ERROR:" |
| 10453 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10454 | |
| 10455 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10456 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10457 | // an unencrypted alert while the server expects |
| 10458 | // encryption, so the alert is not readable by runner. |
| 10459 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10460 | } |
| 10461 | |
| 10462 | if t.messageType == typeFinished { |
| 10463 | // Bad Finished messages read as the verify data having |
| 10464 | // the wrong length. |
| 10465 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10466 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10467 | } |
| 10468 | |
| 10469 | testCases = append(testCases, t.test) |
| 10470 | } |
| 10471 | } |
| 10472 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10473 | func addTLS13HandshakeTests() { |
| 10474 | testCases = append(testCases, testCase{ |
| 10475 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10476 | name: "NegotiatePSKResumption-TLS13", |
| 10477 | config: Config{ |
| 10478 | MaxVersion: VersionTLS13, |
| 10479 | Bugs: ProtocolBugs{ |
| 10480 | NegotiatePSKResumption: true, |
| 10481 | }, |
| 10482 | }, |
| 10483 | resumeSession: true, |
| 10484 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10485 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10486 | }) |
| 10487 | |
| 10488 | testCases = append(testCases, testCase{ |
| 10489 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10490 | name: "MissingKeyShare-Client", |
| 10491 | config: Config{ |
| 10492 | MaxVersion: VersionTLS13, |
| 10493 | Bugs: ProtocolBugs{ |
| 10494 | MissingKeyShare: true, |
| 10495 | }, |
| 10496 | }, |
| 10497 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10498 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10499 | }) |
| 10500 | |
| 10501 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10502 | testType: serverTest, |
| 10503 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10504 | config: Config{ |
| 10505 | MaxVersion: VersionTLS13, |
| 10506 | Bugs: ProtocolBugs{ |
| 10507 | MissingKeyShare: true, |
| 10508 | }, |
| 10509 | }, |
| 10510 | shouldFail: true, |
| 10511 | expectedError: ":MISSING_KEY_SHARE:", |
| 10512 | }) |
| 10513 | |
| 10514 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10515 | testType: serverTest, |
| 10516 | name: "DuplicateKeyShares", |
| 10517 | config: Config{ |
| 10518 | MaxVersion: VersionTLS13, |
| 10519 | Bugs: ProtocolBugs{ |
| 10520 | DuplicateKeyShares: true, |
| 10521 | }, |
| 10522 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10523 | shouldFail: true, |
| 10524 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10525 | }) |
| 10526 | |
| 10527 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10528 | testType: serverTest, |
| 10529 | name: "SkipEarlyData", |
| 10530 | config: Config{ |
| 10531 | MaxVersion: VersionTLS13, |
| 10532 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10533 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10534 | }, |
| 10535 | }, |
| 10536 | }) |
| 10537 | |
| 10538 | testCases = append(testCases, testCase{ |
| 10539 | testType: serverTest, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 10540 | name: "SkipEarlyData-TLS13Experiment", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10541 | config: Config{ |
| 10542 | MaxVersion: VersionTLS13, |
| 10543 | TLS13Variant: TLS13Experiment, |
| 10544 | Bugs: ProtocolBugs{ |
| 10545 | SendFakeEarlyDataLength: 4, |
| 10546 | }, |
| 10547 | }, |
| 10548 | flags: []string{"-tls13-variant", "1"}, |
| 10549 | }) |
| 10550 | |
| 10551 | testCases = append(testCases, testCase{ |
| 10552 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10553 | name: "SkipEarlyData-TLS13RecordTypeExperiment", |
| 10554 | config: Config{ |
| 10555 | MaxVersion: VersionTLS13, |
| 10556 | TLS13Variant: TLS13RecordTypeExperiment, |
| 10557 | Bugs: ProtocolBugs{ |
| 10558 | SendFakeEarlyDataLength: 4, |
| 10559 | }, |
| 10560 | }, |
| 10561 | flags: []string{"-tls13-variant", "2"}, |
| 10562 | }) |
| 10563 | |
| 10564 | testCases = append(testCases, testCase{ |
| 10565 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10566 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10567 | config: Config{ |
| 10568 | MaxVersion: VersionTLS13, |
| 10569 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10570 | SendFakeEarlyDataLength: 4, |
| 10571 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10572 | }, |
| 10573 | }, |
| 10574 | shouldFail: true, |
| 10575 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10576 | }) |
| 10577 | |
| 10578 | testCases = append(testCases, testCase{ |
| 10579 | testType: serverTest, |
| 10580 | name: "SkipEarlyData-TooMuchData", |
| 10581 | config: Config{ |
| 10582 | MaxVersion: VersionTLS13, |
| 10583 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10584 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10585 | }, |
| 10586 | }, |
| 10587 | shouldFail: true, |
| 10588 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10589 | }) |
| 10590 | |
| 10591 | testCases = append(testCases, testCase{ |
| 10592 | testType: serverTest, |
| 10593 | name: "SkipEarlyData-Interleaved", |
| 10594 | config: Config{ |
| 10595 | MaxVersion: VersionTLS13, |
| 10596 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10597 | SendFakeEarlyDataLength: 4, |
| 10598 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10599 | }, |
| 10600 | }, |
| 10601 | shouldFail: true, |
| 10602 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10603 | }) |
| 10604 | |
| 10605 | testCases = append(testCases, testCase{ |
| 10606 | testType: serverTest, |
| 10607 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10608 | config: Config{ |
| 10609 | MaxVersion: VersionTLS13, |
| 10610 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10611 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10612 | }, |
| 10613 | }, |
| 10614 | shouldFail: true, |
| 10615 | expectedError: ":UNEXPECTED_RECORD:", |
| 10616 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10617 | }) |
| 10618 | |
| 10619 | testCases = append(testCases, testCase{ |
| 10620 | testType: serverTest, |
| 10621 | name: "SkipEarlyData-HRR", |
| 10622 | config: Config{ |
| 10623 | MaxVersion: VersionTLS13, |
| 10624 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10625 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10626 | }, |
| 10627 | DefaultCurves: []CurveID{}, |
| 10628 | }, |
| 10629 | }) |
| 10630 | |
| 10631 | testCases = append(testCases, testCase{ |
| 10632 | testType: serverTest, |
| 10633 | name: "SkipEarlyData-HRR-Interleaved", |
| 10634 | config: Config{ |
| 10635 | MaxVersion: VersionTLS13, |
| 10636 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10637 | SendFakeEarlyDataLength: 4, |
| 10638 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10639 | }, |
| 10640 | DefaultCurves: []CurveID{}, |
| 10641 | }, |
| 10642 | shouldFail: true, |
| 10643 | expectedError: ":UNEXPECTED_RECORD:", |
| 10644 | }) |
| 10645 | |
| 10646 | testCases = append(testCases, testCase{ |
| 10647 | testType: serverTest, |
| 10648 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10649 | config: Config{ |
| 10650 | MaxVersion: VersionTLS13, |
| 10651 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10652 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10653 | }, |
| 10654 | DefaultCurves: []CurveID{}, |
| 10655 | }, |
| 10656 | shouldFail: true, |
| 10657 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10658 | }) |
| 10659 | |
| 10660 | // Test that skipping early data looking for cleartext correctly |
| 10661 | // processes an alert record. |
| 10662 | testCases = append(testCases, testCase{ |
| 10663 | testType: serverTest, |
| 10664 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10665 | config: Config{ |
| 10666 | MaxVersion: VersionTLS13, |
| 10667 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10668 | SendEarlyAlert: true, |
| 10669 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10670 | }, |
| 10671 | DefaultCurves: []CurveID{}, |
| 10672 | }, |
| 10673 | shouldFail: true, |
| 10674 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10675 | }) |
| 10676 | |
| 10677 | testCases = append(testCases, testCase{ |
| 10678 | testType: serverTest, |
| 10679 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10680 | config: Config{ |
| 10681 | MaxVersion: VersionTLS13, |
| 10682 | Bugs: ProtocolBugs{ |
| 10683 | SendEarlyDataOnSecondClientHello: true, |
| 10684 | }, |
| 10685 | DefaultCurves: []CurveID{}, |
| 10686 | }, |
| 10687 | shouldFail: true, |
| 10688 | expectedLocalError: "remote error: bad record MAC", |
| 10689 | }) |
| 10690 | |
| 10691 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10692 | testType: clientTest, |
| 10693 | name: "EmptyEncryptedExtensions", |
| 10694 | config: Config{ |
| 10695 | MaxVersion: VersionTLS13, |
| 10696 | Bugs: ProtocolBugs{ |
| 10697 | EmptyEncryptedExtensions: true, |
| 10698 | }, |
| 10699 | }, |
| 10700 | shouldFail: true, |
| 10701 | expectedLocalError: "remote error: error decoding message", |
| 10702 | }) |
| 10703 | |
| 10704 | testCases = append(testCases, testCase{ |
| 10705 | testType: clientTest, |
| 10706 | name: "EncryptedExtensionsWithKeyShare", |
| 10707 | config: Config{ |
| 10708 | MaxVersion: VersionTLS13, |
| 10709 | Bugs: ProtocolBugs{ |
| 10710 | EncryptedExtensionsWithKeyShare: true, |
| 10711 | }, |
| 10712 | }, |
| 10713 | shouldFail: true, |
| 10714 | expectedLocalError: "remote error: unsupported extension", |
| 10715 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10716 | |
| 10717 | testCases = append(testCases, testCase{ |
| 10718 | testType: serverTest, |
| 10719 | name: "SendHelloRetryRequest", |
| 10720 | config: Config{ |
| 10721 | MaxVersion: VersionTLS13, |
| 10722 | // Require a HelloRetryRequest for every curve. |
| 10723 | DefaultCurves: []CurveID{}, |
| 10724 | }, |
| 10725 | expectedCurveID: CurveX25519, |
| 10726 | }) |
| 10727 | |
| 10728 | testCases = append(testCases, testCase{ |
| 10729 | testType: serverTest, |
| 10730 | name: "SendHelloRetryRequest-2", |
| 10731 | config: Config{ |
| 10732 | MaxVersion: VersionTLS13, |
| 10733 | DefaultCurves: []CurveID{CurveP384}, |
| 10734 | }, |
| 10735 | // Although the ClientHello did not predict our preferred curve, |
| 10736 | // we always select it whether it is predicted or not. |
| 10737 | expectedCurveID: CurveX25519, |
| 10738 | }) |
| 10739 | |
| 10740 | testCases = append(testCases, testCase{ |
| 10741 | name: "UnknownCurve-HelloRetryRequest", |
| 10742 | config: Config{ |
| 10743 | MaxVersion: VersionTLS13, |
| 10744 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10745 | CurvePreferences: []CurveID{CurveP384}, |
| 10746 | Bugs: ProtocolBugs{ |
| 10747 | SendHelloRetryRequestCurve: bogusCurve, |
| 10748 | }, |
| 10749 | }, |
| 10750 | shouldFail: true, |
| 10751 | expectedError: ":WRONG_CURVE:", |
| 10752 | }) |
| 10753 | |
| 10754 | testCases = append(testCases, testCase{ |
| 10755 | name: "DisabledCurve-HelloRetryRequest", |
| 10756 | config: Config{ |
| 10757 | MaxVersion: VersionTLS13, |
| 10758 | CurvePreferences: []CurveID{CurveP256}, |
| 10759 | Bugs: ProtocolBugs{ |
| 10760 | IgnorePeerCurvePreferences: true, |
| 10761 | }, |
| 10762 | }, |
| 10763 | flags: []string{"-p384-only"}, |
| 10764 | shouldFail: true, |
| 10765 | expectedError: ":WRONG_CURVE:", |
| 10766 | }) |
| 10767 | |
| 10768 | testCases = append(testCases, testCase{ |
| 10769 | name: "UnnecessaryHelloRetryRequest", |
| 10770 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10771 | MaxVersion: VersionTLS13, |
| 10772 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10773 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10774 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10775 | }, |
| 10776 | }, |
| 10777 | shouldFail: true, |
| 10778 | expectedError: ":WRONG_CURVE:", |
| 10779 | }) |
| 10780 | |
| 10781 | testCases = append(testCases, testCase{ |
| 10782 | name: "SecondHelloRetryRequest", |
| 10783 | config: Config{ |
| 10784 | MaxVersion: VersionTLS13, |
| 10785 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10786 | CurvePreferences: []CurveID{CurveP384}, |
| 10787 | Bugs: ProtocolBugs{ |
| 10788 | SecondHelloRetryRequest: true, |
| 10789 | }, |
| 10790 | }, |
| 10791 | shouldFail: true, |
| 10792 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10793 | }) |
| 10794 | |
| 10795 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10796 | name: "HelloRetryRequest-Empty", |
| 10797 | config: Config{ |
| 10798 | MaxVersion: VersionTLS13, |
| 10799 | Bugs: ProtocolBugs{ |
| 10800 | AlwaysSendHelloRetryRequest: true, |
| 10801 | }, |
| 10802 | }, |
| 10803 | shouldFail: true, |
| 10804 | expectedError: ":DECODE_ERROR:", |
| 10805 | }) |
| 10806 | |
| 10807 | testCases = append(testCases, testCase{ |
| 10808 | name: "HelloRetryRequest-DuplicateCurve", |
| 10809 | config: Config{ |
| 10810 | MaxVersion: VersionTLS13, |
| 10811 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 10812 | // configuration. Assert this ExpectMissingKeyShare. |
| 10813 | CurvePreferences: []CurveID{CurveP384}, |
| 10814 | Bugs: ProtocolBugs{ |
| 10815 | ExpectMissingKeyShare: true, |
| 10816 | DuplicateHelloRetryRequestExtensions: true, |
| 10817 | }, |
| 10818 | }, |
| 10819 | shouldFail: true, |
| 10820 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10821 | expectedLocalError: "remote error: illegal parameter", |
| 10822 | }) |
| 10823 | |
| 10824 | testCases = append(testCases, testCase{ |
| 10825 | name: "HelloRetryRequest-Cookie", |
| 10826 | config: Config{ |
| 10827 | MaxVersion: VersionTLS13, |
| 10828 | Bugs: ProtocolBugs{ |
| 10829 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10830 | }, |
| 10831 | }, |
| 10832 | }) |
| 10833 | |
| 10834 | testCases = append(testCases, testCase{ |
| 10835 | name: "HelloRetryRequest-DuplicateCookie", |
| 10836 | config: Config{ |
| 10837 | MaxVersion: VersionTLS13, |
| 10838 | Bugs: ProtocolBugs{ |
| 10839 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10840 | DuplicateHelloRetryRequestExtensions: true, |
| 10841 | }, |
| 10842 | }, |
| 10843 | shouldFail: true, |
| 10844 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10845 | expectedLocalError: "remote error: illegal parameter", |
| 10846 | }) |
| 10847 | |
| 10848 | testCases = append(testCases, testCase{ |
| 10849 | name: "HelloRetryRequest-EmptyCookie", |
| 10850 | config: Config{ |
| 10851 | MaxVersion: VersionTLS13, |
| 10852 | Bugs: ProtocolBugs{ |
| 10853 | SendHelloRetryRequestCookie: []byte{}, |
| 10854 | }, |
| 10855 | }, |
| 10856 | shouldFail: true, |
| 10857 | expectedError: ":DECODE_ERROR:", |
| 10858 | }) |
| 10859 | |
| 10860 | testCases = append(testCases, testCase{ |
| 10861 | name: "HelloRetryRequest-Cookie-Curve", |
| 10862 | config: Config{ |
| 10863 | MaxVersion: VersionTLS13, |
| 10864 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10865 | CurvePreferences: []CurveID{CurveP384}, |
| 10866 | Bugs: ProtocolBugs{ |
| 10867 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10868 | ExpectMissingKeyShare: true, |
| 10869 | }, |
| 10870 | }, |
| 10871 | }) |
| 10872 | |
| 10873 | testCases = append(testCases, testCase{ |
| 10874 | name: "HelloRetryRequest-Unknown", |
| 10875 | config: Config{ |
| 10876 | MaxVersion: VersionTLS13, |
| 10877 | Bugs: ProtocolBugs{ |
| 10878 | CustomHelloRetryRequestExtension: "extension", |
| 10879 | }, |
| 10880 | }, |
| 10881 | shouldFail: true, |
| 10882 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10883 | expectedLocalError: "remote error: unsupported extension", |
| 10884 | }) |
| 10885 | |
| 10886 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10887 | testType: serverTest, |
| 10888 | name: "SecondClientHelloMissingKeyShare", |
| 10889 | config: Config{ |
| 10890 | MaxVersion: VersionTLS13, |
| 10891 | DefaultCurves: []CurveID{}, |
| 10892 | Bugs: ProtocolBugs{ |
| 10893 | SecondClientHelloMissingKeyShare: true, |
| 10894 | }, |
| 10895 | }, |
| 10896 | shouldFail: true, |
| 10897 | expectedError: ":MISSING_KEY_SHARE:", |
| 10898 | }) |
| 10899 | |
| 10900 | testCases = append(testCases, testCase{ |
| 10901 | testType: serverTest, |
| 10902 | name: "SecondClientHelloWrongCurve", |
| 10903 | config: Config{ |
| 10904 | MaxVersion: VersionTLS13, |
| 10905 | DefaultCurves: []CurveID{}, |
| 10906 | Bugs: ProtocolBugs{ |
| 10907 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 10908 | }, |
| 10909 | }, |
| 10910 | shouldFail: true, |
| 10911 | expectedError: ":WRONG_CURVE:", |
| 10912 | }) |
| 10913 | |
| 10914 | testCases = append(testCases, testCase{ |
| 10915 | name: "HelloRetryRequestVersionMismatch", |
| 10916 | config: Config{ |
| 10917 | MaxVersion: VersionTLS13, |
| 10918 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10919 | CurvePreferences: []CurveID{CurveP384}, |
| 10920 | Bugs: ProtocolBugs{ |
| 10921 | SendServerHelloVersion: 0x0305, |
| 10922 | }, |
| 10923 | }, |
| 10924 | shouldFail: true, |
| 10925 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10926 | }) |
| 10927 | |
| 10928 | testCases = append(testCases, testCase{ |
| 10929 | name: "HelloRetryRequestCurveMismatch", |
| 10930 | config: Config{ |
| 10931 | MaxVersion: VersionTLS13, |
| 10932 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10933 | CurvePreferences: []CurveID{CurveP384}, |
| 10934 | Bugs: ProtocolBugs{ |
| 10935 | // Send P-384 (correct) in the HelloRetryRequest. |
| 10936 | SendHelloRetryRequestCurve: CurveP384, |
| 10937 | // But send P-256 in the ServerHello. |
| 10938 | SendCurve: CurveP256, |
| 10939 | }, |
| 10940 | }, |
| 10941 | shouldFail: true, |
| 10942 | expectedError: ":WRONG_CURVE:", |
| 10943 | }) |
| 10944 | |
| 10945 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 10946 | // without sending it. |
| 10947 | testCases = append(testCases, testCase{ |
| 10948 | name: "SkipHelloRetryRequest", |
| 10949 | config: Config{ |
| 10950 | MaxVersion: VersionTLS13, |
| 10951 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10952 | CurvePreferences: []CurveID{CurveP384}, |
| 10953 | Bugs: ProtocolBugs{ |
| 10954 | SkipHelloRetryRequest: true, |
| 10955 | }, |
| 10956 | }, |
| 10957 | shouldFail: true, |
| 10958 | expectedError: ":WRONG_CURVE:", |
| 10959 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 10960 | |
| 10961 | testCases = append(testCases, testCase{ |
| 10962 | name: "TLS13-RequestContextInHandshake", |
| 10963 | config: Config{ |
| 10964 | MaxVersion: VersionTLS13, |
| 10965 | MinVersion: VersionTLS13, |
| 10966 | ClientAuth: RequireAnyClientCert, |
| 10967 | Bugs: ProtocolBugs{ |
| 10968 | SendRequestContext: []byte("request context"), |
| 10969 | }, |
| 10970 | }, |
| 10971 | flags: []string{ |
| 10972 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 10973 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 10974 | }, |
| 10975 | shouldFail: true, |
| 10976 | expectedError: ":DECODE_ERROR:", |
| 10977 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10978 | |
| 10979 | testCases = append(testCases, testCase{ |
| 10980 | testType: serverTest, |
| 10981 | name: "TLS13-TrailingKeyShareData", |
| 10982 | config: Config{ |
| 10983 | MaxVersion: VersionTLS13, |
| 10984 | Bugs: ProtocolBugs{ |
| 10985 | TrailingKeyShareData: true, |
| 10986 | }, |
| 10987 | }, |
| 10988 | shouldFail: true, |
| 10989 | expectedError: ":DECODE_ERROR:", |
| 10990 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 10991 | |
| 10992 | testCases = append(testCases, testCase{ |
| 10993 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 10994 | config: Config{ |
| 10995 | MaxVersion: VersionTLS13, |
| 10996 | Bugs: ProtocolBugs{ |
| 10997 | AlwaysSelectPSKIdentity: true, |
| 10998 | }, |
| 10999 | }, |
| 11000 | shouldFail: true, |
| 11001 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11002 | }) |
| 11003 | |
| 11004 | testCases = append(testCases, testCase{ |
| 11005 | name: "TLS13-InvalidPSKIdentity", |
| 11006 | config: Config{ |
| 11007 | MaxVersion: VersionTLS13, |
| 11008 | Bugs: ProtocolBugs{ |
| 11009 | SelectPSKIdentityOnResume: 1, |
| 11010 | }, |
| 11011 | }, |
| 11012 | resumeSession: true, |
| 11013 | shouldFail: true, |
| 11014 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 11015 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11016 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11017 | testCases = append(testCases, testCase{ |
| 11018 | testType: serverTest, |
| 11019 | name: "TLS13-ExtraPSKIdentity", |
| 11020 | config: Config{ |
| 11021 | MaxVersion: VersionTLS13, |
| 11022 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11023 | ExtraPSKIdentity: true, |
| 11024 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11025 | }, |
| 11026 | }, |
| 11027 | resumeSession: true, |
| 11028 | }) |
| 11029 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11030 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11031 | testCases = append(testCases, testCase{ |
| 11032 | name: "TLS13-CustomTicketExtension", |
| 11033 | config: Config{ |
| 11034 | MaxVersion: VersionTLS13, |
| 11035 | Bugs: ProtocolBugs{ |
| 11036 | CustomTicketExtension: "1234", |
| 11037 | }, |
| 11038 | }, |
| 11039 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11040 | |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11041 | for _, noSessionID := range []bool{false, true} { |
| 11042 | prefix := "TLS13Experiment" |
| 11043 | variant := TLS13Experiment |
| 11044 | if noSessionID { |
| 11045 | prefix = "TLS13NoSessionIDExperiment" |
| 11046 | variant = TLS13NoSessionIDExperiment |
| 11047 | } |
| 11048 | |
| 11049 | // Test that enabling a TLS 1.3 variant does not interfere with |
| 11050 | // TLS 1.2 session ID resumption. |
| 11051 | testCases = append(testCases, testCase{ |
| 11052 | testType: clientTest, |
| 11053 | name: prefix + "-ResumeTLS12SessionID", |
| 11054 | config: Config{ |
| 11055 | MaxVersion: VersionTLS12, |
| 11056 | SessionTicketsDisabled: true, |
| 11057 | }, |
| 11058 | resumeSession: true, |
| 11059 | flags: []string{"-tls13-variant", strconv.Itoa(variant)}, |
| 11060 | }) |
| 11061 | |
| 11062 | // Test that the server correctly echoes back session IDs of |
| 11063 | // various lengths. |
| 11064 | testCases = append(testCases, testCase{ |
| 11065 | testType: serverTest, |
| 11066 | name: prefix + "-EmptySessionID", |
| 11067 | config: Config{ |
| 11068 | MaxVersion: VersionTLS13, |
| 11069 | Bugs: ProtocolBugs{ |
| 11070 | SendClientHelloSessionID: []byte{}, |
| 11071 | }, |
| 11072 | }, |
| 11073 | tls13Variant: variant, |
| 11074 | }) |
| 11075 | |
| 11076 | testCases = append(testCases, testCase{ |
| 11077 | testType: serverTest, |
| 11078 | name: prefix + "-ShortSessionID", |
| 11079 | config: Config{ |
| 11080 | MaxVersion: VersionTLS13, |
| 11081 | Bugs: ProtocolBugs{ |
| 11082 | SendClientHelloSessionID: make([]byte, 16), |
| 11083 | }, |
| 11084 | }, |
| 11085 | tls13Variant: variant, |
| 11086 | }) |
| 11087 | |
| 11088 | testCases = append(testCases, testCase{ |
| 11089 | testType: serverTest, |
| 11090 | name: prefix + "-FullSessionID", |
| 11091 | config: Config{ |
| 11092 | MaxVersion: VersionTLS13, |
| 11093 | Bugs: ProtocolBugs{ |
| 11094 | SendClientHelloSessionID: make([]byte, 32), |
| 11095 | }, |
| 11096 | }, |
| 11097 | tls13Variant: variant, |
| 11098 | }) |
| 11099 | } |
| 11100 | |
| 11101 | // Test that the client sends a fake session ID in TLS13Experiment. |
| 11102 | testCases = append(testCases, testCase{ |
| 11103 | testType: clientTest, |
| 11104 | name: "TLS13Experiment-RequireSessionID", |
| 11105 | config: Config{ |
| 11106 | MaxVersion: VersionTLS13, |
| 11107 | Bugs: ProtocolBugs{ |
| 11108 | ExpectClientHelloSessionID: true, |
| 11109 | }, |
| 11110 | }, |
| 11111 | tls13Variant: TLS13Experiment, |
| 11112 | }) |
| 11113 | |
| 11114 | // Test that the client does not send a fake session ID in |
| 11115 | // TLS13NoSessionIDExperiment. |
| 11116 | testCases = append(testCases, testCase{ |
| 11117 | testType: clientTest, |
| 11118 | name: "TLS13NoSessionIDExperiment-RequireEmptySessionID", |
| 11119 | config: Config{ |
| 11120 | MaxVersion: VersionTLS13, |
| 11121 | Bugs: ProtocolBugs{ |
| 11122 | ExpectEmptyClientHelloSessionID: true, |
| 11123 | }, |
| 11124 | }, |
| 11125 | tls13Variant: TLS13NoSessionIDExperiment, |
| 11126 | }) |
| 11127 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11128 | testCases = append(testCases, testCase{ |
| 11129 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11130 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11131 | config: Config{ |
| 11132 | MaxVersion: VersionTLS13, |
| 11133 | MaxEarlyDataSize: 16384, |
| 11134 | }, |
| 11135 | resumeConfig: &Config{ |
| 11136 | MaxVersion: VersionTLS13, |
| 11137 | MaxEarlyDataSize: 16384, |
| 11138 | Bugs: ProtocolBugs{ |
| 11139 | AlwaysRejectEarlyData: true, |
| 11140 | }, |
| 11141 | }, |
| 11142 | resumeSession: true, |
| 11143 | flags: []string{ |
| 11144 | "-enable-early-data", |
| 11145 | "-expect-early-data-info", |
| 11146 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11147 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11148 | }, |
| 11149 | }) |
| 11150 | |
| 11151 | testCases = append(testCases, testCase{ |
| 11152 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11153 | name: "TLS13Experiment-EarlyData-Reject-Client", |
| 11154 | config: Config{ |
| 11155 | MaxVersion: VersionTLS13, |
| 11156 | MaxEarlyDataSize: 16384, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11157 | }, |
| 11158 | resumeConfig: &Config{ |
| 11159 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11160 | MaxEarlyDataSize: 16384, |
| 11161 | Bugs: ProtocolBugs{ |
| 11162 | AlwaysRejectEarlyData: true, |
| 11163 | }, |
| 11164 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11165 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11166 | resumeSession: true, |
| 11167 | flags: []string{ |
| 11168 | "-enable-early-data", |
| 11169 | "-expect-early-data-info", |
| 11170 | "-expect-reject-early-data", |
| 11171 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11172 | }, |
| 11173 | }) |
| 11174 | |
| 11175 | testCases = append(testCases, testCase{ |
| 11176 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11177 | name: "TLS13RecordTypeExperiment-EarlyData-Reject-Client", |
| 11178 | config: Config{ |
| 11179 | MaxVersion: VersionTLS13, |
| 11180 | MaxEarlyDataSize: 16384, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11181 | }, |
| 11182 | resumeConfig: &Config{ |
| 11183 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11184 | MaxEarlyDataSize: 16384, |
| 11185 | Bugs: ProtocolBugs{ |
| 11186 | AlwaysRejectEarlyData: true, |
| 11187 | }, |
| 11188 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11189 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11190 | resumeSession: true, |
| 11191 | flags: []string{ |
| 11192 | "-enable-early-data", |
| 11193 | "-expect-early-data-info", |
| 11194 | "-expect-reject-early-data", |
| 11195 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11196 | }, |
| 11197 | }) |
| 11198 | |
| 11199 | testCases = append(testCases, testCase{ |
| 11200 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11201 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11202 | config: Config{ |
| 11203 | MaxVersion: VersionTLS13, |
| 11204 | MaxEarlyDataSize: 16384, |
| 11205 | Certificates: []Certificate{rsaCertificate}, |
| 11206 | }, |
| 11207 | resumeConfig: &Config{ |
| 11208 | MaxVersion: VersionTLS13, |
| 11209 | MaxEarlyDataSize: 16384, |
| 11210 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11211 | SessionTicketsDisabled: true, |
| 11212 | }, |
| 11213 | resumeSession: true, |
| 11214 | expectResumeRejected: true, |
| 11215 | flags: []string{ |
| 11216 | "-enable-early-data", |
| 11217 | "-expect-early-data-info", |
| 11218 | "-expect-reject-early-data", |
| 11219 | "-on-resume-shim-writes-first", |
| 11220 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11221 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11222 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11223 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11224 | "-on-retry-expect-no-session", |
| 11225 | }, |
| 11226 | }) |
| 11227 | |
| 11228 | testCases = append(testCases, testCase{ |
| 11229 | testType: clientTest, |
| 11230 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11231 | config: Config{ |
| 11232 | MaxVersion: VersionTLS13, |
| 11233 | MaxEarlyDataSize: 16384, |
| 11234 | }, |
| 11235 | resumeConfig: &Config{ |
| 11236 | MaxVersion: VersionTLS13, |
| 11237 | MaxEarlyDataSize: 16384, |
| 11238 | Bugs: ProtocolBugs{ |
| 11239 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11240 | }, |
| 11241 | }, |
| 11242 | resumeSession: true, |
| 11243 | flags: []string{ |
| 11244 | "-enable-early-data", |
| 11245 | "-expect-early-data-info", |
| 11246 | "-expect-reject-early-data", |
| 11247 | }, |
| 11248 | }) |
| 11249 | |
| 11250 | // The client must check the server does not send the early_data |
| 11251 | // extension while rejecting the session. |
| 11252 | testCases = append(testCases, testCase{ |
| 11253 | testType: clientTest, |
| 11254 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11255 | config: Config{ |
| 11256 | MaxVersion: VersionTLS13, |
| 11257 | MaxEarlyDataSize: 16384, |
| 11258 | }, |
| 11259 | resumeConfig: &Config{ |
| 11260 | MaxVersion: VersionTLS13, |
| 11261 | SessionTicketsDisabled: true, |
| 11262 | Bugs: ProtocolBugs{ |
| 11263 | SendEarlyDataExtension: true, |
| 11264 | }, |
| 11265 | }, |
| 11266 | resumeSession: true, |
| 11267 | flags: []string{ |
| 11268 | "-enable-early-data", |
| 11269 | "-expect-early-data-info", |
| 11270 | }, |
| 11271 | shouldFail: true, |
| 11272 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11273 | }) |
| 11274 | |
| 11275 | // The client must fail with a dedicated error code if the server |
| 11276 | // responds with TLS 1.2 when offering 0-RTT. |
| 11277 | testCases = append(testCases, testCase{ |
| 11278 | testType: clientTest, |
| 11279 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11280 | config: Config{ |
| 11281 | MaxVersion: VersionTLS13, |
| 11282 | MaxEarlyDataSize: 16384, |
| 11283 | }, |
| 11284 | resumeConfig: &Config{ |
| 11285 | MaxVersion: VersionTLS12, |
| 11286 | }, |
| 11287 | resumeSession: true, |
| 11288 | flags: []string{ |
| 11289 | "-enable-early-data", |
| 11290 | "-expect-early-data-info", |
| 11291 | }, |
| 11292 | shouldFail: true, |
| 11293 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11294 | }) |
| 11295 | |
| 11296 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11297 | // the server sent an HRR. |
| 11298 | testCases = append(testCases, testCase{ |
| 11299 | testType: clientTest, |
| 11300 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11301 | config: Config{ |
| 11302 | MaxVersion: VersionTLS13, |
| 11303 | MaxEarlyDataSize: 16384, |
| 11304 | }, |
| 11305 | resumeConfig: &Config{ |
| 11306 | MaxVersion: VersionTLS13, |
| 11307 | MaxEarlyDataSize: 16384, |
| 11308 | Bugs: ProtocolBugs{ |
| 11309 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11310 | SendEarlyDataExtension: true, |
| 11311 | }, |
| 11312 | }, |
| 11313 | resumeSession: true, |
| 11314 | flags: []string{ |
| 11315 | "-enable-early-data", |
| 11316 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11317 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11318 | }, |
| 11319 | shouldFail: true, |
| 11320 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11321 | }) |
| 11322 | |
| 11323 | fooString := "foo" |
| 11324 | barString := "bar" |
| 11325 | |
| 11326 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11327 | // that changed it. |
| 11328 | testCases = append(testCases, testCase{ |
| 11329 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11330 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11331 | config: Config{ |
| 11332 | MaxVersion: VersionTLS13, |
| 11333 | MaxEarlyDataSize: 16384, |
| 11334 | Bugs: ProtocolBugs{ |
| 11335 | ALPNProtocol: &fooString, |
| 11336 | }, |
| 11337 | }, |
| 11338 | resumeConfig: &Config{ |
| 11339 | MaxVersion: VersionTLS13, |
| 11340 | MaxEarlyDataSize: 16384, |
| 11341 | Bugs: ProtocolBugs{ |
| 11342 | ALPNProtocol: &barString, |
| 11343 | }, |
| 11344 | }, |
| 11345 | resumeSession: true, |
| 11346 | flags: []string{ |
| 11347 | "-advertise-alpn", "\x03foo\x03bar", |
| 11348 | "-enable-early-data", |
| 11349 | "-expect-early-data-info", |
| 11350 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11351 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11352 | "-on-resume-expect-alpn", "foo", |
| 11353 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11354 | }, |
| 11355 | }) |
| 11356 | |
| 11357 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11358 | // ALPN was omitted from the first connection. |
| 11359 | testCases = append(testCases, testCase{ |
| 11360 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11361 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11362 | config: Config{ |
| 11363 | MaxVersion: VersionTLS13, |
| 11364 | MaxEarlyDataSize: 16384, |
| 11365 | }, |
| 11366 | resumeConfig: &Config{ |
| 11367 | MaxVersion: VersionTLS13, |
| 11368 | MaxEarlyDataSize: 16384, |
| 11369 | NextProtos: []string{"foo"}, |
| 11370 | }, |
| 11371 | resumeSession: true, |
| 11372 | flags: []string{ |
| 11373 | "-advertise-alpn", "\x03foo\x03bar", |
| 11374 | "-enable-early-data", |
| 11375 | "-expect-early-data-info", |
| 11376 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11377 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11378 | "-on-resume-expect-alpn", "", |
| 11379 | "-on-retry-expect-alpn", "foo", |
| 11380 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11381 | }, |
| 11382 | }) |
| 11383 | |
| 11384 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11385 | // ALPN was omitted from the second connection. |
| 11386 | testCases = append(testCases, testCase{ |
| 11387 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11388 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11389 | config: Config{ |
| 11390 | MaxVersion: VersionTLS13, |
| 11391 | MaxEarlyDataSize: 16384, |
| 11392 | NextProtos: []string{"foo"}, |
| 11393 | }, |
| 11394 | resumeConfig: &Config{ |
| 11395 | MaxVersion: VersionTLS13, |
| 11396 | MaxEarlyDataSize: 16384, |
| 11397 | }, |
| 11398 | resumeSession: true, |
| 11399 | flags: []string{ |
| 11400 | "-advertise-alpn", "\x03foo\x03bar", |
| 11401 | "-enable-early-data", |
| 11402 | "-expect-early-data-info", |
| 11403 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11404 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11405 | "-on-resume-expect-alpn", "foo", |
| 11406 | "-on-retry-expect-alpn", "", |
| 11407 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11408 | }, |
| 11409 | }) |
| 11410 | |
| 11411 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11412 | testCases = append(testCases, testCase{ |
| 11413 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11414 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11415 | config: Config{ |
| 11416 | MaxVersion: VersionTLS13, |
| 11417 | MaxEarlyDataSize: 16384, |
| 11418 | Bugs: ProtocolBugs{ |
| 11419 | ALPNProtocol: &fooString, |
| 11420 | }, |
| 11421 | }, |
| 11422 | resumeConfig: &Config{ |
| 11423 | MaxVersion: VersionTLS13, |
| 11424 | MaxEarlyDataSize: 16384, |
| 11425 | Bugs: ProtocolBugs{ |
| 11426 | AlwaysAcceptEarlyData: true, |
| 11427 | ALPNProtocol: &barString, |
| 11428 | }, |
| 11429 | }, |
| 11430 | resumeSession: true, |
| 11431 | flags: []string{ |
| 11432 | "-advertise-alpn", "\x03foo\x03bar", |
| 11433 | "-enable-early-data", |
| 11434 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11435 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11436 | "-on-resume-expect-alpn", "foo", |
| 11437 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11438 | }, |
| 11439 | shouldFail: true, |
| 11440 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11441 | }) |
| 11442 | |
| 11443 | // Test that the server correctly rejects 0-RTT when the previous |
| 11444 | // session did not allow early data on resumption. |
| 11445 | testCases = append(testCases, testCase{ |
| 11446 | testType: serverTest, |
| 11447 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11448 | config: Config{ |
| 11449 | MaxVersion: VersionTLS13, |
| 11450 | }, |
| 11451 | resumeConfig: &Config{ |
| 11452 | MaxVersion: VersionTLS13, |
| 11453 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11454 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11455 | ExpectEarlyDataAccepted: false, |
| 11456 | }, |
| 11457 | }, |
| 11458 | resumeSession: true, |
| 11459 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11460 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11461 | "-expect-reject-early-data", |
| 11462 | }, |
| 11463 | }) |
| 11464 | |
| 11465 | // Test that we reject early data where ALPN is omitted from the first |
| 11466 | // connection. |
| 11467 | testCases = append(testCases, testCase{ |
| 11468 | testType: serverTest, |
| 11469 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11470 | config: Config{ |
| 11471 | MaxVersion: VersionTLS13, |
| 11472 | NextProtos: []string{}, |
| 11473 | }, |
| 11474 | resumeConfig: &Config{ |
| 11475 | MaxVersion: VersionTLS13, |
| 11476 | NextProtos: []string{"foo"}, |
| 11477 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11478 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11479 | ExpectEarlyDataAccepted: false, |
| 11480 | }, |
| 11481 | }, |
| 11482 | resumeSession: true, |
| 11483 | flags: []string{ |
| 11484 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11485 | "-on-initial-select-alpn", "", |
| 11486 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11487 | }, |
| 11488 | }) |
| 11489 | |
| 11490 | // Test that we reject early data where ALPN is omitted from the second |
| 11491 | // connection. |
| 11492 | testCases = append(testCases, testCase{ |
| 11493 | testType: serverTest, |
| 11494 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11495 | config: Config{ |
| 11496 | MaxVersion: VersionTLS13, |
| 11497 | NextProtos: []string{"foo"}, |
| 11498 | }, |
| 11499 | resumeConfig: &Config{ |
| 11500 | MaxVersion: VersionTLS13, |
| 11501 | NextProtos: []string{}, |
| 11502 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11503 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11504 | ExpectEarlyDataAccepted: false, |
| 11505 | }, |
| 11506 | }, |
| 11507 | resumeSession: true, |
| 11508 | flags: []string{ |
| 11509 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11510 | "-on-initial-select-alpn", "foo", |
| 11511 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11512 | }, |
| 11513 | }) |
| 11514 | |
| 11515 | // Test that we reject early data with mismatched ALPN. |
| 11516 | testCases = append(testCases, testCase{ |
| 11517 | testType: serverTest, |
| 11518 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11519 | config: Config{ |
| 11520 | MaxVersion: VersionTLS13, |
| 11521 | NextProtos: []string{"foo"}, |
| 11522 | }, |
| 11523 | resumeConfig: &Config{ |
| 11524 | MaxVersion: VersionTLS13, |
| 11525 | NextProtos: []string{"bar"}, |
| 11526 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11527 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11528 | ExpectEarlyDataAccepted: false, |
| 11529 | }, |
| 11530 | }, |
| 11531 | resumeSession: true, |
| 11532 | flags: []string{ |
| 11533 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11534 | "-on-initial-select-alpn", "foo", |
| 11535 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11536 | }, |
| 11537 | }) |
| 11538 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11539 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11540 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11541 | testCases = append(testCases, testCase{ |
| 11542 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11543 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11544 | config: Config{ |
| 11545 | MaxVersion: VersionTLS13, |
| 11546 | MaxEarlyDataSize: 16384, |
| 11547 | RequestChannelID: true, |
| 11548 | }, |
| 11549 | resumeSession: true, |
| 11550 | expectChannelID: true, |
| 11551 | shouldFail: true, |
| 11552 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 11553 | flags: []string{ |
| 11554 | "-enable-early-data", |
| 11555 | "-expect-early-data-info", |
| 11556 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11557 | }, |
| 11558 | }) |
| 11559 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11560 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11561 | // to decline 0-RTT. |
| 11562 | testCases = append(testCases, testCase{ |
| 11563 | testType: clientTest, |
| 11564 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11565 | config: Config{ |
| 11566 | MaxVersion: VersionTLS13, |
| 11567 | MaxEarlyDataSize: 16384, |
| 11568 | RequestChannelID: true, |
| 11569 | Bugs: ProtocolBugs{ |
| 11570 | AlwaysRejectEarlyData: true, |
| 11571 | }, |
| 11572 | }, |
| 11573 | resumeSession: true, |
| 11574 | expectChannelID: true, |
| 11575 | flags: []string{ |
| 11576 | "-enable-early-data", |
| 11577 | "-expect-early-data-info", |
| 11578 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11579 | "-expect-reject-early-data", |
| 11580 | }, |
| 11581 | }) |
| 11582 | |
| 11583 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11584 | // to decline Channel ID. |
| 11585 | testCases = append(testCases, testCase{ |
| 11586 | testType: clientTest, |
| 11587 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11588 | config: Config{ |
| 11589 | MaxVersion: VersionTLS13, |
| 11590 | MaxEarlyDataSize: 16384, |
| 11591 | }, |
| 11592 | resumeSession: true, |
| 11593 | flags: []string{ |
| 11594 | "-enable-early-data", |
| 11595 | "-expect-early-data-info", |
| 11596 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11597 | "-expect-accept-early-data", |
| 11598 | }, |
| 11599 | }) |
| 11600 | |
| 11601 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11602 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11603 | testCases = append(testCases, testCase{ |
| 11604 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11605 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11606 | config: Config{ |
| 11607 | MaxVersion: VersionTLS13, |
| 11608 | ChannelID: channelIDKey, |
| 11609 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11610 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11611 | ExpectEarlyDataAccepted: false, |
| 11612 | }, |
| 11613 | }, |
| 11614 | resumeSession: true, |
| 11615 | expectChannelID: true, |
| 11616 | flags: []string{ |
| 11617 | "-enable-early-data", |
| 11618 | "-expect-reject-early-data", |
| 11619 | "-expect-channel-id", |
| 11620 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11621 | }, |
| 11622 | }) |
| 11623 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11624 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11625 | // if not offered Channel ID. |
| 11626 | testCases = append(testCases, testCase{ |
| 11627 | testType: serverTest, |
| 11628 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11629 | config: Config{ |
| 11630 | MaxVersion: VersionTLS13, |
| 11631 | Bugs: ProtocolBugs{ |
| 11632 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11633 | ExpectEarlyDataAccepted: true, |
| 11634 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11635 | }, |
| 11636 | }, |
| 11637 | resumeSession: true, |
| 11638 | expectChannelID: false, |
| 11639 | flags: []string{ |
| 11640 | "-enable-early-data", |
| 11641 | "-expect-accept-early-data", |
| 11642 | "-enable-channel-id", |
| 11643 | }, |
| 11644 | }) |
| 11645 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11646 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11647 | // The subsequent records should fail to decrypt. |
| 11648 | testCases = append(testCases, testCase{ |
| 11649 | testType: serverTest, |
| 11650 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11651 | config: Config{ |
| 11652 | MaxVersion: VersionTLS13, |
| 11653 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11654 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11655 | ExpectEarlyDataAccepted: true, |
| 11656 | SkipEndOfEarlyData: true, |
| 11657 | }, |
| 11658 | }, |
| 11659 | resumeSession: true, |
| 11660 | flags: []string{"-enable-early-data"}, |
| 11661 | shouldFail: true, |
| 11662 | expectedLocalError: "remote error: bad record MAC", |
| 11663 | expectedError: ":BAD_DECRYPT:", |
| 11664 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11665 | |
| 11666 | testCases = append(testCases, testCase{ |
| 11667 | testType: serverTest, |
| 11668 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11669 | config: Config{ |
| 11670 | MaxVersion: VersionTLS13, |
| 11671 | }, |
| 11672 | resumeConfig: &Config{ |
| 11673 | MaxVersion: VersionTLS13, |
| 11674 | Bugs: ProtocolBugs{ |
| 11675 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11676 | SendStrayEarlyHandshake: true, |
| 11677 | ExpectEarlyDataAccepted: true}, |
| 11678 | }, |
| 11679 | resumeSession: true, |
| 11680 | shouldFail: true, |
| 11681 | expectedError: ":UNEXPECTED_RECORD:", |
| 11682 | expectedLocalError: "remote error: unexpected message", |
| 11683 | flags: []string{ |
| 11684 | "-enable-early-data", |
| 11685 | }, |
| 11686 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11687 | |
| 11688 | // Test that the client reports TLS 1.3 as the version while sending |
| 11689 | // early data. |
| 11690 | testCases = append(testCases, testCase{ |
| 11691 | testType: clientTest, |
| 11692 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11693 | config: Config{ |
| 11694 | MaxVersion: VersionTLS13, |
| 11695 | MaxEarlyDataSize: 16384, |
| 11696 | }, |
| 11697 | resumeSession: true, |
| 11698 | flags: []string{ |
| 11699 | "-enable-early-data", |
| 11700 | "-expect-early-data-info", |
| 11701 | "-expect-accept-early-data", |
| 11702 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11703 | }, |
| 11704 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11705 | } |
| 11706 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11707 | func addTLS13CipherPreferenceTests() { |
| 11708 | // Test that client preference is honored if the shim has AES hardware |
| 11709 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 11710 | testCases = append(testCases, testCase{ |
| 11711 | testType: serverTest, |
| 11712 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 11713 | config: Config{ |
| 11714 | MaxVersion: VersionTLS13, |
| 11715 | CipherSuites: []uint16{ |
| 11716 | TLS_CHACHA20_POLY1305_SHA256, |
| 11717 | TLS_AES_128_GCM_SHA256, |
| 11718 | }, |
| 11719 | }, |
| 11720 | flags: []string{ |
| 11721 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11722 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11723 | }, |
| 11724 | }) |
| 11725 | |
| 11726 | testCases = append(testCases, testCase{ |
| 11727 | testType: serverTest, |
| 11728 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 11729 | config: Config{ |
| 11730 | MaxVersion: VersionTLS13, |
| 11731 | CipherSuites: []uint16{ |
| 11732 | TLS_AES_128_GCM_SHA256, |
| 11733 | TLS_CHACHA20_POLY1305_SHA256, |
| 11734 | }, |
| 11735 | }, |
| 11736 | flags: []string{ |
| 11737 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11738 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11739 | }, |
| 11740 | }) |
| 11741 | |
| 11742 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 11743 | // whether it has AES hardware. |
| 11744 | testCases = append(testCases, testCase{ |
| 11745 | name: "TLS13-CipherPreference-Client", |
| 11746 | config: Config{ |
| 11747 | MaxVersion: VersionTLS13, |
| 11748 | // Use the client cipher order. (This is the default but |
| 11749 | // is listed to be explicit.) |
| 11750 | PreferServerCipherSuites: false, |
| 11751 | }, |
| 11752 | flags: []string{ |
| 11753 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11754 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11755 | }, |
| 11756 | }) |
| 11757 | } |
| 11758 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11759 | func addPeekTests() { |
| 11760 | // Test SSL_peek works, including on empty records. |
| 11761 | testCases = append(testCases, testCase{ |
| 11762 | name: "Peek-Basic", |
| 11763 | sendEmptyRecords: 1, |
| 11764 | flags: []string{"-peek-then-read"}, |
| 11765 | }) |
| 11766 | |
| 11767 | // Test SSL_peek can drive the initial handshake. |
| 11768 | testCases = append(testCases, testCase{ |
| 11769 | name: "Peek-ImplicitHandshake", |
| 11770 | flags: []string{ |
| 11771 | "-peek-then-read", |
| 11772 | "-implicit-handshake", |
| 11773 | }, |
| 11774 | }) |
| 11775 | |
| 11776 | // Test SSL_peek can discover and drive a renegotiation. |
| 11777 | testCases = append(testCases, testCase{ |
| 11778 | name: "Peek-Renegotiate", |
| 11779 | config: Config{ |
| 11780 | MaxVersion: VersionTLS12, |
| 11781 | }, |
| 11782 | renegotiate: 1, |
| 11783 | flags: []string{ |
| 11784 | "-peek-then-read", |
| 11785 | "-renegotiate-freely", |
| 11786 | "-expect-total-renegotiations", "1", |
| 11787 | }, |
| 11788 | }) |
| 11789 | |
| 11790 | // Test SSL_peek can discover a close_notify. |
| 11791 | testCases = append(testCases, testCase{ |
| 11792 | name: "Peek-Shutdown", |
| 11793 | config: Config{ |
| 11794 | Bugs: ProtocolBugs{ |
| 11795 | ExpectCloseNotify: true, |
| 11796 | }, |
| 11797 | }, |
| 11798 | flags: []string{ |
| 11799 | "-peek-then-read", |
| 11800 | "-check-close-notify", |
| 11801 | }, |
| 11802 | }) |
| 11803 | |
| 11804 | // Test SSL_peek can discover an alert. |
| 11805 | testCases = append(testCases, testCase{ |
| 11806 | name: "Peek-Alert", |
| 11807 | config: Config{ |
| 11808 | Bugs: ProtocolBugs{ |
| 11809 | SendSpuriousAlert: alertRecordOverflow, |
| 11810 | }, |
| 11811 | }, |
| 11812 | flags: []string{"-peek-then-read"}, |
| 11813 | shouldFail: true, |
| 11814 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 11815 | }) |
| 11816 | |
| 11817 | // Test SSL_peek can handle KeyUpdate. |
| 11818 | testCases = append(testCases, testCase{ |
| 11819 | name: "Peek-KeyUpdate", |
| 11820 | config: Config{ |
| 11821 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11822 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 11823 | sendKeyUpdates: 1, |
| 11824 | keyUpdateRequest: keyUpdateNotRequested, |
| 11825 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11826 | }) |
| 11827 | } |
| 11828 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11829 | func addRecordVersionTests() { |
| 11830 | for _, ver := range tlsVersions { |
| 11831 | // Test that the record version is enforced. |
| 11832 | testCases = append(testCases, testCase{ |
| 11833 | name: "CheckRecordVersion-" + ver.name, |
| 11834 | config: Config{ |
| 11835 | MinVersion: ver.version, |
| 11836 | MaxVersion: ver.version, |
| 11837 | Bugs: ProtocolBugs{ |
| 11838 | SendRecordVersion: 0x03ff, |
| 11839 | }, |
| 11840 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11841 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11842 | shouldFail: true, |
| 11843 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11844 | }) |
| 11845 | |
| 11846 | // Test that the ClientHello may use any record version, for |
| 11847 | // compatibility reasons. |
| 11848 | testCases = append(testCases, testCase{ |
| 11849 | testType: serverTest, |
| 11850 | name: "LooseInitialRecordVersion-" + ver.name, |
| 11851 | config: Config{ |
| 11852 | MinVersion: ver.version, |
| 11853 | MaxVersion: ver.version, |
| 11854 | Bugs: ProtocolBugs{ |
| 11855 | SendInitialRecordVersion: 0x03ff, |
| 11856 | }, |
| 11857 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11858 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11859 | }) |
| 11860 | |
| 11861 | // Test that garbage ClientHello record versions are rejected. |
| 11862 | testCases = append(testCases, testCase{ |
| 11863 | testType: serverTest, |
| 11864 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 11865 | config: Config{ |
| 11866 | MinVersion: ver.version, |
| 11867 | MaxVersion: ver.version, |
| 11868 | Bugs: ProtocolBugs{ |
| 11869 | SendInitialRecordVersion: 0xffff, |
| 11870 | }, |
| 11871 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11872 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11873 | shouldFail: true, |
| 11874 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11875 | }) |
| 11876 | } |
| 11877 | } |
| 11878 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11879 | func addCertificateTests() { |
| 11880 | // Test that a certificate chain with intermediate may be sent and |
| 11881 | // received as both client and server. |
| 11882 | for _, ver := range tlsVersions { |
| 11883 | testCases = append(testCases, testCase{ |
| 11884 | testType: clientTest, |
| 11885 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 11886 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11887 | MinVersion: ver.version, |
| 11888 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11889 | Certificates: []Certificate{rsaChainCertificate}, |
| 11890 | ClientAuth: RequireAnyClientCert, |
| 11891 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11892 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11893 | expectPeerCertificate: &rsaChainCertificate, |
| 11894 | flags: []string{ |
| 11895 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11896 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11897 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11898 | }, |
| 11899 | }) |
| 11900 | |
| 11901 | testCases = append(testCases, testCase{ |
| 11902 | testType: serverTest, |
| 11903 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 11904 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11905 | MinVersion: ver.version, |
| 11906 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11907 | Certificates: []Certificate{rsaChainCertificate}, |
| 11908 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11909 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11910 | expectPeerCertificate: &rsaChainCertificate, |
| 11911 | flags: []string{ |
| 11912 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11913 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11914 | "-require-any-client-certificate", |
| 11915 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11916 | }, |
| 11917 | }) |
| 11918 | } |
| 11919 | } |
| 11920 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11921 | func addRetainOnlySHA256ClientCertTests() { |
| 11922 | for _, ver := range tlsVersions { |
| 11923 | // Test that enabling |
| 11924 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 11925 | // actually requesting a client certificate is a no-op. |
| 11926 | testCases = append(testCases, testCase{ |
| 11927 | testType: serverTest, |
| 11928 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 11929 | config: Config{ |
| 11930 | MinVersion: ver.version, |
| 11931 | MaxVersion: ver.version, |
| 11932 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11933 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11934 | flags: []string{ |
| 11935 | "-retain-only-sha256-client-cert-initial", |
| 11936 | "-retain-only-sha256-client-cert-resume", |
| 11937 | }, |
| 11938 | resumeSession: true, |
| 11939 | }) |
| 11940 | |
| 11941 | // Test that when retaining only a SHA-256 certificate is |
| 11942 | // enabled, the hash appears as expected. |
| 11943 | testCases = append(testCases, testCase{ |
| 11944 | testType: serverTest, |
| 11945 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 11946 | config: Config{ |
| 11947 | MinVersion: ver.version, |
| 11948 | MaxVersion: ver.version, |
| 11949 | Certificates: []Certificate{rsaCertificate}, |
| 11950 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11951 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11952 | flags: []string{ |
| 11953 | "-verify-peer", |
| 11954 | "-retain-only-sha256-client-cert-initial", |
| 11955 | "-retain-only-sha256-client-cert-resume", |
| 11956 | "-expect-sha256-client-cert-initial", |
| 11957 | "-expect-sha256-client-cert-resume", |
| 11958 | }, |
| 11959 | resumeSession: true, |
| 11960 | }) |
| 11961 | |
| 11962 | // Test that when the config changes from on to off, a |
| 11963 | // resumption is rejected because the server now wants the full |
| 11964 | // certificate chain. |
| 11965 | testCases = append(testCases, testCase{ |
| 11966 | testType: serverTest, |
| 11967 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 11968 | config: Config{ |
| 11969 | MinVersion: ver.version, |
| 11970 | MaxVersion: ver.version, |
| 11971 | Certificates: []Certificate{rsaCertificate}, |
| 11972 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11973 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11974 | flags: []string{ |
| 11975 | "-verify-peer", |
| 11976 | "-retain-only-sha256-client-cert-initial", |
| 11977 | "-expect-sha256-client-cert-initial", |
| 11978 | }, |
| 11979 | resumeSession: true, |
| 11980 | expectResumeRejected: true, |
| 11981 | }) |
| 11982 | |
| 11983 | // Test that when the config changes from off to on, a |
| 11984 | // resumption is rejected because the server now wants just the |
| 11985 | // hash. |
| 11986 | testCases = append(testCases, testCase{ |
| 11987 | testType: serverTest, |
| 11988 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 11989 | config: Config{ |
| 11990 | MinVersion: ver.version, |
| 11991 | MaxVersion: ver.version, |
| 11992 | Certificates: []Certificate{rsaCertificate}, |
| 11993 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11994 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11995 | flags: []string{ |
| 11996 | "-verify-peer", |
| 11997 | "-retain-only-sha256-client-cert-resume", |
| 11998 | "-expect-sha256-client-cert-resume", |
| 11999 | }, |
| 12000 | resumeSession: true, |
| 12001 | expectResumeRejected: true, |
| 12002 | }) |
| 12003 | } |
| 12004 | } |
| 12005 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12006 | func addECDSAKeyUsageTests() { |
| 12007 | p256 := elliptic.P256() |
| 12008 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 12009 | if err != nil { |
| 12010 | panic(err) |
| 12011 | } |
| 12012 | |
| 12013 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 12014 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 12015 | if err != nil { |
| 12016 | panic(err) |
| 12017 | } |
| 12018 | |
| 12019 | template := x509.Certificate{ |
| 12020 | SerialNumber: serialNumber, |
| 12021 | Subject: pkix.Name{ |
| 12022 | Organization: []string{"Acme Co"}, |
| 12023 | }, |
| 12024 | NotBefore: time.Now(), |
| 12025 | NotAfter: time.Now(), |
| 12026 | |
| 12027 | // An ECC certificate with only the keyAgreement key usgae may |
| 12028 | // be used with ECDH, but not ECDSA. |
| 12029 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 12030 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 12031 | BasicConstraintsValid: true, |
| 12032 | } |
| 12033 | |
| 12034 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 12035 | if err != nil { |
| 12036 | panic(err) |
| 12037 | } |
| 12038 | |
| 12039 | cert := Certificate{ |
| 12040 | Certificate: [][]byte{derBytes}, |
| 12041 | PrivateKey: priv, |
| 12042 | } |
| 12043 | |
| 12044 | for _, ver := range tlsVersions { |
| 12045 | if ver.version < VersionTLS12 { |
| 12046 | continue |
| 12047 | } |
| 12048 | |
| 12049 | testCases = append(testCases, testCase{ |
| 12050 | testType: clientTest, |
| 12051 | name: "ECDSAKeyUsage-" + ver.name, |
| 12052 | config: Config{ |
| 12053 | MinVersion: ver.version, |
| 12054 | MaxVersion: ver.version, |
| 12055 | Certificates: []Certificate{cert}, |
| 12056 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12057 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12058 | shouldFail: true, |
| 12059 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 12060 | }) |
| 12061 | } |
| 12062 | } |
| 12063 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12064 | func addExtraHandshakeTests() { |
| 12065 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 12066 | // to ensure there is no transport I/O. |
| 12067 | testCases = append(testCases, testCase{ |
| 12068 | testType: clientTest, |
| 12069 | name: "ExtraHandshake-Client-TLS12", |
| 12070 | config: Config{ |
| 12071 | MinVersion: VersionTLS12, |
| 12072 | MaxVersion: VersionTLS12, |
| 12073 | }, |
| 12074 | flags: []string{ |
| 12075 | "-async", |
| 12076 | "-no-op-extra-handshake", |
| 12077 | }, |
| 12078 | }) |
| 12079 | testCases = append(testCases, testCase{ |
| 12080 | testType: serverTest, |
| 12081 | name: "ExtraHandshake-Server-TLS12", |
| 12082 | config: Config{ |
| 12083 | MinVersion: VersionTLS12, |
| 12084 | MaxVersion: VersionTLS12, |
| 12085 | }, |
| 12086 | flags: []string{ |
| 12087 | "-async", |
| 12088 | "-no-op-extra-handshake", |
| 12089 | }, |
| 12090 | }) |
| 12091 | testCases = append(testCases, testCase{ |
| 12092 | testType: clientTest, |
| 12093 | name: "ExtraHandshake-Client-TLS13", |
| 12094 | config: Config{ |
| 12095 | MinVersion: VersionTLS13, |
| 12096 | MaxVersion: VersionTLS13, |
| 12097 | }, |
| 12098 | flags: []string{ |
| 12099 | "-async", |
| 12100 | "-no-op-extra-handshake", |
| 12101 | }, |
| 12102 | }) |
| 12103 | testCases = append(testCases, testCase{ |
| 12104 | testType: serverTest, |
| 12105 | name: "ExtraHandshake-Server-TLS13", |
| 12106 | config: Config{ |
| 12107 | MinVersion: VersionTLS13, |
| 12108 | MaxVersion: VersionTLS13, |
| 12109 | }, |
| 12110 | flags: []string{ |
| 12111 | "-async", |
| 12112 | "-no-op-extra-handshake", |
| 12113 | }, |
| 12114 | }) |
| 12115 | |
| 12116 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12117 | testCases = append(testCases, testCase{ |
| 12118 | testType: serverTest, |
| 12119 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12120 | config: Config{ |
| 12121 | MaxVersion: VersionTLS13, |
| 12122 | MinVersion: VersionTLS13, |
| 12123 | Bugs: ProtocolBugs{ |
| 12124 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12125 | ExpectEarlyDataAccepted: true, |
| 12126 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12127 | }, |
| 12128 | }, |
| 12129 | messageCount: 2, |
| 12130 | resumeSession: true, |
| 12131 | flags: []string{ |
| 12132 | "-async", |
| 12133 | "-enable-early-data", |
| 12134 | "-expect-accept-early-data", |
| 12135 | "-no-op-extra-handshake", |
| 12136 | }, |
| 12137 | }) |
| 12138 | |
| 12139 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12140 | // Start. We test this by handshaking twice and asserting the False |
| 12141 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12142 | // how the test works. |
| 12143 | testCases = append(testCases, testCase{ |
| 12144 | testType: clientTest, |
| 12145 | name: "ExtraHandshake-FalseStart", |
| 12146 | config: Config{ |
| 12147 | MaxVersion: VersionTLS12, |
| 12148 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12149 | NextProtos: []string{"foo"}, |
| 12150 | Bugs: ProtocolBugs{ |
| 12151 | ExpectFalseStart: true, |
| 12152 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12153 | }, |
| 12154 | }, |
| 12155 | flags: []string{ |
| 12156 | "-handshake-twice", |
| 12157 | "-false-start", |
| 12158 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12159 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12160 | }, |
| 12161 | shimWritesFirst: true, |
| 12162 | shouldFail: true, |
| 12163 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12164 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12165 | }) |
| 12166 | } |
| 12167 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12168 | // Test that omitted and empty extensions blocks are tolerated. |
| 12169 | func addOmitExtensionsTests() { |
| 12170 | for _, ver := range tlsVersions { |
| 12171 | if ver.version > VersionTLS12 { |
| 12172 | continue |
| 12173 | } |
| 12174 | |
| 12175 | testCases = append(testCases, testCase{ |
| 12176 | testType: serverTest, |
| 12177 | name: "OmitExtensions-ClientHello-" + ver.name, |
| 12178 | config: Config{ |
| 12179 | MinVersion: ver.version, |
| 12180 | MaxVersion: ver.version, |
| 12181 | SessionTicketsDisabled: true, |
| 12182 | Bugs: ProtocolBugs{ |
| 12183 | OmitExtensions: true, |
| 12184 | }, |
| 12185 | }, |
| 12186 | }) |
| 12187 | |
| 12188 | testCases = append(testCases, testCase{ |
| 12189 | testType: serverTest, |
| 12190 | name: "EmptyExtensions-ClientHello-" + ver.name, |
| 12191 | config: Config{ |
| 12192 | MinVersion: ver.version, |
| 12193 | MaxVersion: ver.version, |
| 12194 | SessionTicketsDisabled: true, |
| 12195 | Bugs: ProtocolBugs{ |
| 12196 | EmptyExtensions: true, |
| 12197 | }, |
| 12198 | }, |
| 12199 | }) |
| 12200 | |
| 12201 | testCases = append(testCases, testCase{ |
| 12202 | testType: clientTest, |
| 12203 | name: "OmitExtensions-ServerHello-" + ver.name, |
| 12204 | config: Config{ |
| 12205 | MinVersion: ver.version, |
| 12206 | MaxVersion: ver.version, |
| 12207 | SessionTicketsDisabled: true, |
| 12208 | Bugs: ProtocolBugs{ |
| 12209 | OmitExtensions: true, |
| 12210 | // Disable all ServerHello extensions so |
| 12211 | // OmitExtensions works. |
| 12212 | NoExtendedMasterSecret: true, |
| 12213 | NoRenegotiationInfo: true, |
| 12214 | }, |
| 12215 | }, |
| 12216 | }) |
| 12217 | |
| 12218 | testCases = append(testCases, testCase{ |
| 12219 | testType: clientTest, |
| 12220 | name: "EmptyExtensions-ServerHello-" + ver.name, |
| 12221 | config: Config{ |
| 12222 | MinVersion: ver.version, |
| 12223 | MaxVersion: ver.version, |
| 12224 | SessionTicketsDisabled: true, |
| 12225 | Bugs: ProtocolBugs{ |
| 12226 | EmptyExtensions: true, |
| 12227 | // Disable all ServerHello extensions so |
| 12228 | // EmptyExtensions works. |
| 12229 | NoExtendedMasterSecret: true, |
| 12230 | NoRenegotiationInfo: true, |
| 12231 | }, |
| 12232 | }, |
| 12233 | }) |
| 12234 | } |
| 12235 | } |
| 12236 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12237 | 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] | 12238 | defer wg.Done() |
| 12239 | |
| 12240 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12241 | var err error |
| 12242 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12243 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12244 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12245 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12246 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12247 | if err != nil { |
| 12248 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12249 | } |
| 12250 | break |
| 12251 | } |
| 12252 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12253 | } else if *repeatUntilFailure { |
| 12254 | for err == nil { |
| 12255 | statusChan <- statusMsg{test: test, started: true} |
| 12256 | err = runTest(test, shimPath, -1) |
| 12257 | } |
| 12258 | } else { |
| 12259 | statusChan <- statusMsg{test: test, started: true} |
| 12260 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12261 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12262 | statusChan <- statusMsg{test: test, err: err} |
| 12263 | } |
| 12264 | } |
| 12265 | |
| 12266 | type statusMsg struct { |
| 12267 | test *testCase |
| 12268 | started bool |
| 12269 | err error |
| 12270 | } |
| 12271 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12272 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12273 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12274 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12275 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12276 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12277 | if !*pipe { |
| 12278 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12279 | var erase string |
| 12280 | for i := 0; i < lineLen; i++ { |
| 12281 | erase += "\b \b" |
| 12282 | } |
| 12283 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12284 | } |
| 12285 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12286 | if msg.started { |
| 12287 | started++ |
| 12288 | } else { |
| 12289 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12290 | |
| 12291 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12292 | if msg.err == errUnimplemented { |
| 12293 | if *pipe { |
| 12294 | // Print each test instead of a status line. |
| 12295 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12296 | } |
| 12297 | unimplemented++ |
| 12298 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12299 | } else { |
| 12300 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12301 | failed++ |
| 12302 | testOutput.addResult(msg.test.name, "FAIL") |
| 12303 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12304 | } else { |
| 12305 | if *pipe { |
| 12306 | // Print each test instead of a status line. |
| 12307 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12308 | } |
| 12309 | testOutput.addResult(msg.test.name, "PASS") |
| 12310 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12311 | } |
| 12312 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12313 | if !*pipe { |
| 12314 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12315 | 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] | 12316 | lineLen = len(line) |
| 12317 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12318 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12319 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12320 | |
| 12321 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12322 | } |
| 12323 | |
| 12324 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12325 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12326 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12327 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12328 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12329 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12330 | addCipherSuiteTests() |
| 12331 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12332 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12333 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12334 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12335 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12336 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12337 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12338 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12339 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12340 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12341 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12342 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12343 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12344 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12345 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12346 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12347 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12348 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12349 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12350 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12351 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12352 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12353 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12354 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12355 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12356 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12357 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12358 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12359 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12360 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12361 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12362 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12363 | addExtraHandshakeTests() |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12364 | addOmitExtensionsTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12365 | |
| 12366 | var wg sync.WaitGroup |
| 12367 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12368 | statusChan := make(chan statusMsg, *numWorkers) |
| 12369 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12370 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12371 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12372 | if len(*shimConfigFile) != 0 { |
| 12373 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12374 | if err != nil { |
| 12375 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12376 | os.Exit(1) |
| 12377 | } |
| 12378 | |
| 12379 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12380 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12381 | os.Exit(1) |
| 12382 | } |
| 12383 | } |
| 12384 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12385 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12386 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12387 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12388 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12389 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12390 | } |
| 12391 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12392 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12393 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12394 | matched := true |
| 12395 | if len(*testToRun) != 0 { |
| 12396 | var err error |
| 12397 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12398 | if err != nil { |
| 12399 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12400 | os.Exit(1) |
| 12401 | } |
| 12402 | } |
| 12403 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12404 | if !*includeDisabled { |
| 12405 | for pattern := range shimConfig.DisabledTests { |
| 12406 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12407 | if err != nil { |
| 12408 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12409 | os.Exit(1) |
| 12410 | } |
| 12411 | |
| 12412 | if isDisabled { |
| 12413 | matched = false |
| 12414 | break |
| 12415 | } |
| 12416 | } |
| 12417 | } |
| 12418 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12419 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12420 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12421 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12422 | |
| 12423 | // Only run one test if repeating until failure. |
| 12424 | if *repeatUntilFailure { |
| 12425 | break |
| 12426 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12427 | } |
| 12428 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12429 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12430 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12431 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12432 | os.Exit(1) |
| 12433 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12434 | |
| 12435 | close(testChan) |
| 12436 | wg.Wait() |
| 12437 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12438 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12439 | |
| 12440 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12441 | |
| 12442 | if *jsonOutput != "" { |
| 12443 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12444 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12445 | } |
| 12446 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12447 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12448 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12449 | os.Exit(1) |
| 12450 | } |
| 12451 | |
| 12452 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12453 | os.Exit(1) |
| 12454 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12455 | } |