Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 1 | // Copyright (c) 2016, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 7fcfd3b | 2016-05-20 11:02:50 -0700 | [diff] [blame] | 14 | |
Adam Langley | dc7e9c4 | 2015-09-29 15:21:04 -0700 | [diff] [blame] | 15 | package runner |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
| 18 | "bytes" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 19 | "crypto/ecdsa" |
| 20 | "crypto/elliptic" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 21 | "crypto/rand" |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 22 | "crypto/x509" |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 23 | "crypto/x509/pkix" |
David Benjamin | 2561dc3 | 2014-08-24 01:25:27 -0400 | [diff] [blame] | 24 | "encoding/base64" |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 25 | "encoding/hex" |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 26 | "encoding/json" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 27 | "encoding/pem" |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 28 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 29 | "flag" |
| 30 | "fmt" |
| 31 | "io" |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 32 | "io/ioutil" |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 33 | "math/big" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 34 | "net" |
| 35 | "os" |
| 36 | "os/exec" |
David Benjamin | 884fdf1 | 2014-08-02 15:28:23 -0400 | [diff] [blame] | 37 | "path" |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 38 | "path/filepath" |
David Benjamin | 2bc8e6f | 2014-08-02 15:22:37 -0400 | [diff] [blame] | 39 | "runtime" |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 40 | "strconv" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 41 | "strings" |
| 42 | "sync" |
| 43 | "syscall" |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 44 | "time" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 45 | ) |
| 46 | |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 47 | var ( |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 48 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
| 49 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
| 50 | useLLDB = flag.Bool("lldb", false, "If true, run BoringSSL code under lldb") |
| 51 | flagDebug = flag.Bool("debug", false, "Hexdump the contents of the connection") |
| 52 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 53 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask bssl_shim to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
| 54 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 55 | pipe = flag.Bool("pipe", false, "If true, print status output suitable for piping into another program.") |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 56 | testToRun = flag.String("test", "", "The pattern to filter tests to run, or empty to run all tests") |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 57 | numWorkers = flag.Int("num-workers", runtime.NumCPU(), "The number of workers to run in parallel.") |
| 58 | shimPath = flag.String("shim-path", "../../../build/ssl/test/bssl_shim", "The location of the shim binary.") |
| 59 | resourceDir = flag.String("resource-dir", ".", "The directory in which to find certificate and key files.") |
| 60 | fuzzer = flag.Bool("fuzzer", false, "If true, tests against a BoringSSL built in fuzzer mode.") |
| 61 | transcriptDir = flag.String("transcript-dir", "", "The directory in which to write transcripts.") |
| 62 | idleTimeout = flag.Duration("idle-timeout", 15*time.Second, "The number of seconds to wait for a read or write to bssl_shim.") |
| 63 | deterministic = flag.Bool("deterministic", false, "If true, uses a deterministic PRNG in the runner.") |
| 64 | allowUnimplemented = flag.Bool("allow-unimplemented", false, "If true, report pass even if some tests are unimplemented.") |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 65 | looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 66 | shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") |
| 67 | includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 68 | repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 69 | ) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 70 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 71 | // ShimConfigurations is used with the “json” package and represents a shim |
| 72 | // config file. |
| 73 | type ShimConfiguration struct { |
| 74 | // DisabledTests maps from a glob-based pattern to a freeform string. |
| 75 | // The glob pattern is used to exclude tests from being run and the |
| 76 | // freeform string is unparsed but expected to explain why the test is |
| 77 | // disabled. |
| 78 | DisabledTests map[string]string |
| 79 | |
| 80 | // ErrorMap maps from expected error strings to the correct error |
| 81 | // string for the shim in question. For example, it might map |
| 82 | // “:NO_SHARED_CIPHER:” (a BoringSSL error string) to something |
| 83 | // like “SSL_ERROR_NO_CYPHER_OVERLAP”. |
| 84 | ErrorMap map[string]string |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 85 | |
| 86 | // HalfRTTTickets is the number of half-RTT tickets the client should |
| 87 | // expect before half-RTT data when testing 0-RTT. |
| 88 | HalfRTTTickets int |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 89 | } |
| 90 | |
David Benjamin | 794cc59 | 2017-03-25 22:24:23 -0500 | [diff] [blame] | 91 | // Setup shimConfig defaults aligning with BoringSSL. |
| 92 | var shimConfig ShimConfiguration = ShimConfiguration{ |
| 93 | HalfRTTTickets: 2, |
| 94 | } |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 95 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 96 | type testCert int |
| 97 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 98 | const ( |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 99 | testCertRSA testCert = iota |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 100 | testCertRSA1024 |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 101 | testCertRSAChain |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 102 | testCertECDSAP224 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 103 | testCertECDSAP256 |
| 104 | testCertECDSAP384 |
| 105 | testCertECDSAP521 |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 106 | testCertEd25519 |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 107 | ) |
| 108 | |
| 109 | const ( |
| 110 | rsaCertificateFile = "cert.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 111 | rsa1024CertificateFile = "rsa_1024_cert.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 112 | rsaChainCertificateFile = "rsa_chain_cert.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 113 | ecdsaP224CertificateFile = "ecdsa_p224_cert.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 114 | ecdsaP256CertificateFile = "ecdsa_p256_cert.pem" |
| 115 | ecdsaP384CertificateFile = "ecdsa_p384_cert.pem" |
| 116 | ecdsaP521CertificateFile = "ecdsa_p521_cert.pem" |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 117 | ed25519CertificateFile = "ed25519_cert.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 118 | ) |
| 119 | |
| 120 | const ( |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 121 | rsaKeyFile = "key.pem" |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 122 | rsa1024KeyFile = "rsa_1024_key.pem" |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 123 | rsaChainKeyFile = "rsa_chain_key.pem" |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 124 | ecdsaP224KeyFile = "ecdsa_p224_key.pem" |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 125 | ecdsaP256KeyFile = "ecdsa_p256_key.pem" |
| 126 | ecdsaP384KeyFile = "ecdsa_p384_key.pem" |
| 127 | ecdsaP521KeyFile = "ecdsa_p521_key.pem" |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 128 | ed25519KeyFile = "ed25519_key.pem" |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 129 | channelIDKeyFile = "channel_id_key.pem" |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 130 | ) |
| 131 | |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 132 | var ( |
| 133 | rsaCertificate Certificate |
| 134 | rsa1024Certificate Certificate |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 135 | rsaChainCertificate Certificate |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 136 | ecdsaP224Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 137 | ecdsaP256Certificate Certificate |
| 138 | ecdsaP384Certificate Certificate |
| 139 | ecdsaP521Certificate Certificate |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 140 | ed25519Certificate Certificate |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 141 | ) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 142 | |
| 143 | var testCerts = []struct { |
| 144 | id testCert |
| 145 | certFile, keyFile string |
| 146 | cert *Certificate |
| 147 | }{ |
| 148 | { |
| 149 | id: testCertRSA, |
| 150 | certFile: rsaCertificateFile, |
| 151 | keyFile: rsaKeyFile, |
| 152 | cert: &rsaCertificate, |
| 153 | }, |
| 154 | { |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 155 | id: testCertRSA1024, |
| 156 | certFile: rsa1024CertificateFile, |
| 157 | keyFile: rsa1024KeyFile, |
| 158 | cert: &rsa1024Certificate, |
| 159 | }, |
| 160 | { |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 161 | id: testCertRSAChain, |
| 162 | certFile: rsaChainCertificateFile, |
| 163 | keyFile: rsaChainKeyFile, |
| 164 | cert: &rsaChainCertificate, |
| 165 | }, |
| 166 | { |
Adam Langley | 898be92 | 2017-02-27 12:37:59 -0800 | [diff] [blame] | 167 | id: testCertECDSAP224, |
| 168 | certFile: ecdsaP224CertificateFile, |
| 169 | keyFile: ecdsaP224KeyFile, |
| 170 | cert: &ecdsaP224Certificate, |
| 171 | }, |
| 172 | { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 173 | id: testCertECDSAP256, |
| 174 | certFile: ecdsaP256CertificateFile, |
| 175 | keyFile: ecdsaP256KeyFile, |
| 176 | cert: &ecdsaP256Certificate, |
| 177 | }, |
| 178 | { |
| 179 | id: testCertECDSAP384, |
| 180 | certFile: ecdsaP384CertificateFile, |
| 181 | keyFile: ecdsaP384KeyFile, |
| 182 | cert: &ecdsaP384Certificate, |
| 183 | }, |
| 184 | { |
| 185 | id: testCertECDSAP521, |
| 186 | certFile: ecdsaP521CertificateFile, |
| 187 | keyFile: ecdsaP521KeyFile, |
| 188 | cert: &ecdsaP521Certificate, |
| 189 | }, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 190 | { |
| 191 | id: testCertEd25519, |
| 192 | certFile: ed25519CertificateFile, |
| 193 | keyFile: ed25519KeyFile, |
| 194 | cert: &ed25519Certificate, |
| 195 | }, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 196 | } |
| 197 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 198 | var channelIDKey *ecdsa.PrivateKey |
| 199 | var channelIDBytes []byte |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 200 | |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 201 | var testOCSPResponse = []byte{1, 2, 3, 4} |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 202 | var testSCTList = []byte{0, 6, 0, 4, 5, 6, 7, 8} |
David Benjamin | 61f9527 | 2014-11-25 01:55:35 -0500 | [diff] [blame] | 203 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 204 | var testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 205 | var testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 206 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 207 | func initCertificates() { |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 208 | for i := range testCerts { |
| 209 | cert, err := LoadX509KeyPair(path.Join(*resourceDir, testCerts[i].certFile), path.Join(*resourceDir, testCerts[i].keyFile)) |
| 210 | if err != nil { |
| 211 | panic(err) |
| 212 | } |
| 213 | cert.OCSPStaple = testOCSPResponse |
| 214 | cert.SignedCertificateTimestampList = testSCTList |
| 215 | *testCerts[i].cert = cert |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 216 | } |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 217 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 218 | channelIDPEMBlock, err := ioutil.ReadFile(path.Join(*resourceDir, channelIDKeyFile)) |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 219 | if err != nil { |
| 220 | panic(err) |
| 221 | } |
| 222 | channelIDDERBlock, _ := pem.Decode(channelIDPEMBlock) |
| 223 | if channelIDDERBlock.Type != "EC PRIVATE KEY" { |
| 224 | panic("bad key type") |
| 225 | } |
| 226 | channelIDKey, err = x509.ParseECPrivateKey(channelIDDERBlock.Bytes) |
| 227 | if err != nil { |
| 228 | panic(err) |
| 229 | } |
| 230 | if channelIDKey.Curve != elliptic.P256() { |
| 231 | panic("bad curve") |
| 232 | } |
| 233 | |
| 234 | channelIDBytes = make([]byte, 64) |
| 235 | writeIntPadded(channelIDBytes[:32], channelIDKey.X) |
| 236 | writeIntPadded(channelIDBytes[32:], channelIDKey.Y) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 237 | } |
| 238 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 239 | func getRunnerCertificate(t testCert) Certificate { |
| 240 | for _, cert := range testCerts { |
| 241 | if cert.id == t { |
| 242 | return *cert.cert |
| 243 | } |
| 244 | } |
| 245 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 246 | } |
| 247 | |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 248 | func getShimCertificate(t testCert) string { |
| 249 | for _, cert := range testCerts { |
| 250 | if cert.id == t { |
| 251 | return cert.certFile |
| 252 | } |
| 253 | } |
| 254 | panic("Unknown test certificate") |
| 255 | } |
| 256 | |
| 257 | func getShimKey(t testCert) string { |
| 258 | for _, cert := range testCerts { |
| 259 | if cert.id == t { |
| 260 | return cert.keyFile |
| 261 | } |
| 262 | } |
| 263 | panic("Unknown test certificate") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 266 | // recordVersionToWire maps a record-layer protocol version to its wire |
| 267 | // representation. |
| 268 | func recordVersionToWire(vers uint16, protocol protocol) uint16 { |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 269 | if protocol == dtls { |
| 270 | switch vers { |
| 271 | case VersionTLS12: |
| 272 | return VersionDTLS12 |
| 273 | case VersionTLS10: |
| 274 | return VersionDTLS10 |
| 275 | } |
| 276 | } else { |
| 277 | switch vers { |
| 278 | case VersionSSL30, VersionTLS10, VersionTLS11, VersionTLS12: |
| 279 | return vers |
Steven Valdez | c94998a | 2017-06-20 10:55:02 -0400 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
| 283 | panic("unknown version") |
| 284 | } |
| 285 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 286 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 287 | func encodeDERValues(values [][]byte) string { |
| 288 | var ret string |
| 289 | for i, v := range values { |
| 290 | if i > 0 { |
| 291 | ret += "," |
| 292 | } |
| 293 | ret += hex.EncodeToString(v) |
| 294 | } |
| 295 | |
| 296 | return ret |
| 297 | } |
| 298 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 299 | type testType int |
| 300 | |
| 301 | const ( |
| 302 | clientTest testType = iota |
| 303 | serverTest |
| 304 | ) |
| 305 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 306 | type protocol int |
| 307 | |
| 308 | const ( |
| 309 | tls protocol = iota |
| 310 | dtls |
| 311 | ) |
| 312 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 313 | const ( |
| 314 | alpn = 1 |
| 315 | npn = 2 |
| 316 | ) |
| 317 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 318 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 319 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 320 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 321 | name string |
| 322 | config Config |
| 323 | shouldFail bool |
| 324 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 325 | // expectedLocalError, if not empty, contains a substring that must be |
| 326 | // found in the local error. |
| 327 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 328 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 329 | // negotiated. |
| 330 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 331 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 332 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 333 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 334 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 335 | // should be negotiated. |
| 336 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 337 | // expectChannelID controls whether the connection should have |
| 338 | // negotiated a Channel ID with channelIDKey. |
| 339 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 340 | // expectedNextProto controls whether the connection should |
| 341 | // negotiate a next protocol via NPN or ALPN. |
| 342 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 343 | // expectNoNextProto, if true, means that no next protocol should be |
| 344 | // negotiated. |
| 345 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 346 | // expectedNextProtoType, if non-zero, is the expected next |
| 347 | // protocol negotiation mechanism. |
| 348 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 349 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 350 | // should be negotiated. If zero, none should be negotiated. |
| 351 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 352 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 353 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 354 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 355 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 356 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 357 | // algorithm that the peer should have used in the handshake. |
| 358 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 359 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 360 | // have used. |
| 361 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 362 | // messageLen is the length, in bytes, of the test message that will be |
| 363 | // sent. |
| 364 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 365 | // messageCount is the number of test messages that will be sent. |
| 366 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 367 | // certFile is the path to the certificate to use for the server. |
| 368 | certFile string |
| 369 | // keyFile is the path to the private key to use for the server. |
| 370 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 371 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 372 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 373 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 374 | // resumeRenewedSession controls whether a third connection should be |
| 375 | // tested which attempts to resume the second connection's session. |
| 376 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 377 | // expectResumeRejected, if true, specifies that the attempted |
| 378 | // resumption must be rejected by the client. This is only valid for a |
| 379 | // serverTest. |
| 380 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 381 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 382 | // resumption. Unless newSessionsOnResume is set, |
| 383 | // SessionTicketKey, ServerSessionCache, and |
| 384 | // ClientSessionCache are copied from the initial connection's |
| 385 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 386 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 387 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 388 | // use a different session resumption context. |
| 389 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 390 | // noSessionCache, if true, will cause the server to run without a |
| 391 | // session cache. |
| 392 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 393 | // sendPrefix sends a prefix on the socket before actually performing a |
| 394 | // handshake. |
| 395 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 396 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 397 | // message before doing a roundtrip with the runner. |
| 398 | shimWritesFirst bool |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 399 | // readWithUnfinishedWrite behaves like shimWritesFirst, but the shim |
| 400 | // does not complete the write until responding to the first runner |
| 401 | // message. |
| 402 | readWithUnfinishedWrite bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 403 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 404 | // connection immediately after the handshake rather than echoing |
| 405 | // messages from the runner. |
| 406 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 407 | // renegotiate indicates the number of times the connection should be |
| 408 | // renegotiated during the exchange. |
| 409 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 410 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 411 | // HelloRequest when the handshake completes. |
| 412 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 413 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 414 | // switched in just before renegotiation. |
| 415 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 416 | // replayWrites, if true, configures the underlying transport |
| 417 | // to replay every write it makes in DTLS tests. |
| 418 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 419 | // damageFirstWrite, if true, configures the underlying transport to |
| 420 | // damage the final byte of the first application data write. |
| 421 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 422 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 423 | // keying material and verify they match. |
| 424 | exportKeyingMaterial int |
| 425 | exportLabel string |
| 426 | exportContext string |
| 427 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 428 | // flags, if not empty, contains a list of command-line flags that will |
| 429 | // be passed to the shim program. |
| 430 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 431 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 432 | // which will be compared against the expected value. |
| 433 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 434 | // sendEmptyRecords is the number of consecutive empty records to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 435 | // before each test message. |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 436 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 437 | // sendWarningAlerts is the number of consecutive warning alerts to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 438 | // before each test message. |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 439 | sendWarningAlerts int |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 440 | // sendBogusAlertType, if true, causes a bogus alert of invalid type to |
| 441 | // be sent before each test message. |
| 442 | sendBogusAlertType bool |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 443 | // sendKeyUpdates is the number of consecutive key updates to send |
| 444 | // before and after the test message. |
| 445 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 446 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 447 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 448 | // expectMessageDropped, if true, means the test message is expected to |
| 449 | // be dropped by the client rather than echoed back. |
| 450 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 451 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 452 | // is expected to send. |
| 453 | expectPeerCertificate *Certificate |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 454 | // shimPrefix is the prefix that the shim will send to the server. |
| 455 | shimPrefix string |
| 456 | // resumeShimPrefix is the prefix that the shim will send to the server on a |
| 457 | // resumption. |
| 458 | resumeShimPrefix string |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 459 | // tls13Variant, if non-zero, causes both runner and shim to be |
| 460 | // configured with the specified TLS 1.3 variant. This is a convenience |
| 461 | // option for configuring both concurrently. |
| 462 | tls13Variant int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 465 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 466 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 467 | func writeTranscript(test *testCase, path string, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 468 | if len(data) == 0 { |
| 469 | return |
| 470 | } |
| 471 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 472 | settings, err := ioutil.ReadFile(path) |
| 473 | if err != nil { |
| 474 | fmt.Fprintf(os.Stderr, "Error reading %s: %s.\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 475 | return |
| 476 | } |
| 477 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 478 | settings = append(settings, data...) |
| 479 | if err := ioutil.WriteFile(path, settings, 0644); err != nil { |
| 480 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", path, err) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 484 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 485 | type timeoutConn struct { |
| 486 | net.Conn |
| 487 | timeout time.Duration |
| 488 | } |
| 489 | |
| 490 | func (t *timeoutConn) Read(b []byte) (int, error) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 491 | if !*useGDB { |
| 492 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 493 | return 0, err |
| 494 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 495 | } |
| 496 | return t.Conn.Read(b) |
| 497 | } |
| 498 | |
| 499 | func (t *timeoutConn) Write(b []byte) (int, error) { |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 500 | if !*useGDB { |
| 501 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 502 | return 0, err |
| 503 | } |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 504 | } |
| 505 | return t.Conn.Write(b) |
| 506 | } |
| 507 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 508 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, transcriptPrefix string, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 509 | if !test.noSessionCache { |
| 510 | if config.ClientSessionCache == nil { |
| 511 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 512 | } |
| 513 | if config.ServerSessionCache == nil { |
| 514 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 515 | } |
| 516 | } |
| 517 | if test.testType == clientTest { |
| 518 | if len(config.Certificates) == 0 { |
| 519 | config.Certificates = []Certificate{rsaCertificate} |
| 520 | } |
| 521 | } else { |
| 522 | // Supply a ServerName to ensure a constant session cache key, |
| 523 | // rather than falling back to net.Conn.RemoteAddr. |
| 524 | if len(config.ServerName) == 0 { |
| 525 | config.ServerName = "test" |
| 526 | } |
| 527 | } |
| 528 | if *fuzzer { |
| 529 | config.Bugs.NullAllCiphers = true |
| 530 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 531 | if *deterministic { |
| 532 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 533 | } |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 534 | if test.tls13Variant != 0 { |
| 535 | config.TLS13Variant = test.tls13Variant |
| 536 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 537 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 538 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 539 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 540 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 541 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 542 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 543 | } |
| 544 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 545 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 546 | local, peer := "client", "server" |
| 547 | if test.testType == clientTest { |
| 548 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 549 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 550 | connDebug := &recordingConn{ |
| 551 | Conn: conn, |
| 552 | isDatagram: test.protocol == dtls, |
| 553 | local: local, |
| 554 | peer: peer, |
| 555 | } |
| 556 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 557 | if *flagDebug { |
| 558 | defer connDebug.WriteTo(os.Stdout) |
| 559 | } |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 560 | if len(transcriptPrefix) != 0 { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 561 | defer func() { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 562 | path := transcriptPrefix + strconv.Itoa(num) |
| 563 | writeTranscript(test, path, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 564 | }() |
| 565 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 566 | |
| 567 | if config.Bugs.PacketAdaptor != nil { |
| 568 | config.Bugs.PacketAdaptor.debug = connDebug |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | if test.replayWrites { |
| 573 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 574 | } |
| 575 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 576 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 577 | if test.damageFirstWrite { |
| 578 | connDamage = newDamageAdaptor(conn) |
| 579 | conn = connDamage |
| 580 | } |
| 581 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 582 | if test.sendPrefix != "" { |
| 583 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 584 | return err |
| 585 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 586 | } |
| 587 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 588 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 589 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 590 | if test.protocol == dtls { |
| 591 | tlsConn = DTLSServer(conn, config) |
| 592 | } else { |
| 593 | tlsConn = Server(conn, config) |
| 594 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 595 | } else { |
| 596 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 597 | if test.protocol == dtls { |
| 598 | tlsConn = DTLSClient(conn, config) |
| 599 | } else { |
| 600 | tlsConn = Client(conn, config) |
| 601 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 602 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 603 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 604 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 605 | if err := tlsConn.Handshake(); err != nil { |
| 606 | return err |
| 607 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 608 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 609 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 610 | // expectations struct that can be specified separately for the two |
| 611 | // legs. |
| 612 | expectedVersion := test.expectedVersion |
| 613 | if isResume && test.expectedResumeVersion != 0 { |
| 614 | expectedVersion = test.expectedResumeVersion |
| 615 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 616 | connState := tlsConn.ConnectionState() |
| 617 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 618 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 619 | } |
| 620 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 621 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 622 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 623 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 624 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 625 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 626 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 627 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 628 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 629 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 630 | if channelID == nil { |
| 631 | return fmt.Errorf("no channel ID negotiated") |
| 632 | } |
| 633 | if channelID.Curve != channelIDKey.Curve || |
| 634 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 635 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 636 | return fmt.Errorf("incorrect channel ID") |
| 637 | } |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 638 | } else if connState.ChannelID != nil { |
| 639 | return fmt.Errorf("channel ID unexpectedly negotiated") |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 640 | } |
| 641 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 642 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 643 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 644 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 645 | } |
| 646 | } |
| 647 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 648 | if test.expectNoNextProto { |
| 649 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 650 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 651 | } |
| 652 | } |
| 653 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 654 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 655 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 656 | return fmt.Errorf("next proto type mismatch") |
| 657 | } |
| 658 | } |
| 659 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 660 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 661 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 662 | } |
| 663 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 664 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 665 | return fmt.Errorf("OCSP Response mismatch: got %x, wanted %x", tlsConn.OCSPResponse(), test.expectedOCSPResponse) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 666 | } |
| 667 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 668 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 669 | return fmt.Errorf("SCT list mismatch") |
| 670 | } |
| 671 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 672 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 673 | return fmt.Errorf("expected peer to use signature algorithm %04x, but got %04x", expected, connState.PeerSignatureAlgorithm) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 674 | } |
| 675 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 676 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 677 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 678 | } |
| 679 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 680 | if test.expectPeerCertificate != nil { |
| 681 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 682 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 683 | } |
| 684 | for i, cert := range connState.PeerCertificates { |
| 685 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 686 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 691 | if test.exportKeyingMaterial > 0 { |
| 692 | actual := make([]byte, test.exportKeyingMaterial) |
| 693 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 694 | return err |
| 695 | } |
| 696 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 697 | if err != nil { |
| 698 | return err |
| 699 | } |
| 700 | if !bytes.Equal(actual, expected) { |
| 701 | return fmt.Errorf("keying material mismatch") |
| 702 | } |
| 703 | } |
| 704 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 705 | if test.testTLSUnique { |
| 706 | var peersValue [12]byte |
| 707 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 708 | return err |
| 709 | } |
| 710 | expected := tlsConn.ConnectionState().TLSUnique |
| 711 | if !bytes.Equal(peersValue[:], expected) { |
| 712 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 713 | } |
| 714 | } |
| 715 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 716 | if test.sendHalfHelloRequest { |
| 717 | tlsConn.SendHalfHelloRequest() |
| 718 | } |
| 719 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 720 | shimPrefix := test.shimPrefix |
| 721 | if isResume { |
| 722 | shimPrefix = test.resumeShimPrefix |
| 723 | } |
| 724 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 725 | shimPrefix = "hello" |
| 726 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 727 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 728 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 729 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 730 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 731 | var buf = make([]byte, len(shimPrefix)) |
| 732 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 733 | if err != nil { |
| 734 | return err |
| 735 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 736 | if string(buf) != shimPrefix { |
| 737 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 738 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 739 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 740 | } |
| 741 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 742 | if test.renegotiateCiphers != nil { |
| 743 | config.CipherSuites = test.renegotiateCiphers |
| 744 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 745 | for i := 0; i < test.renegotiate; i++ { |
| 746 | if err := tlsConn.Renegotiate(); err != nil { |
| 747 | return err |
| 748 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 749 | } |
| 750 | } else if test.renegotiateCiphers != nil { |
| 751 | panic("renegotiateCiphers without renegotiate") |
| 752 | } |
| 753 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 754 | if test.damageFirstWrite { |
| 755 | connDamage.setDamage(true) |
| 756 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 757 | connDamage.setDamage(false) |
| 758 | } |
| 759 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 760 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 761 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 762 | if test.protocol == dtls { |
| 763 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 764 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 765 | // Read until EOF. |
| 766 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 767 | return err |
| 768 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 769 | if messageLen == 0 { |
| 770 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 771 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 772 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 773 | messageCount := test.messageCount |
| 774 | if messageCount == 0 { |
| 775 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 776 | } |
| 777 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 778 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 779 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 780 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 781 | } |
| 782 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 783 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 784 | tlsConn.Write(nil) |
| 785 | } |
| 786 | |
| 787 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 788 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 789 | } |
| 790 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 791 | if test.sendBogusAlertType { |
| 792 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 793 | } |
| 794 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 795 | testMessage := make([]byte, messageLen) |
| 796 | for i := range testMessage { |
| 797 | testMessage[i] = 0x42 ^ byte(j) |
| 798 | } |
| 799 | tlsConn.Write(testMessage) |
| 800 | |
| 801 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 802 | if shimPrefix != "" { |
| 803 | var buf = make([]byte, len(shimPrefix)) |
| 804 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 805 | if err != nil { |
| 806 | return err |
| 807 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 808 | if string(buf) != shimPrefix { |
| 809 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 810 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 811 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 812 | } |
| 813 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 814 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 815 | // The shim will not respond. |
| 816 | continue |
| 817 | } |
| 818 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 819 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 820 | // sends, the shim should respond only once. |
| 821 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 822 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 823 | return err |
| 824 | } |
| 825 | } |
| 826 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 827 | buf := make([]byte, len(testMessage)) |
| 828 | if test.protocol == dtls { |
| 829 | bufTmp := make([]byte, len(buf)+1) |
| 830 | n, err := tlsConn.Read(bufTmp) |
| 831 | if err != nil { |
| 832 | return err |
| 833 | } |
| 834 | if n != len(buf) { |
| 835 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 836 | } |
| 837 | copy(buf, bufTmp) |
| 838 | } else { |
| 839 | _, err := io.ReadFull(tlsConn, buf) |
| 840 | if err != nil { |
| 841 | return err |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | for i, v := range buf { |
| 846 | if v != testMessage[i]^0xff { |
| 847 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 848 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | |
| 852 | return nil |
| 853 | } |
| 854 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 855 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 856 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 857 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 858 | valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 859 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 860 | valgrindArgs = append(valgrindArgs, path) |
| 861 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 862 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 863 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 864 | } |
| 865 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 866 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 867 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 868 | xtermArgs = append(xtermArgs, path) |
| 869 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 870 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 871 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 872 | } |
| 873 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 874 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 875 | xtermArgs := []string{"-e", "lldb", "--"} |
| 876 | xtermArgs = append(xtermArgs, path) |
| 877 | xtermArgs = append(xtermArgs, args...) |
| 878 | |
| 879 | return exec.Command("xterm", xtermArgs...) |
| 880 | } |
| 881 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 882 | var ( |
| 883 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 884 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 885 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 886 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 887 | // accept accepts a connection from listener, unless waitChan signals a process |
| 888 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 889 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 890 | type connOrError struct { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 891 | conn net.Conn |
| 892 | err error |
| 893 | startTime, endTime time.Time |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 894 | } |
| 895 | connChan := make(chan connOrError, 1) |
| 896 | go func() { |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 897 | startTime := time.Now() |
Adam Langley | 182b573 | 2017-07-28 11:00:23 -0700 | [diff] [blame] | 898 | if !*useGDB { |
| 899 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
| 900 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 901 | conn, err := listener.Accept() |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 902 | endTime := time.Now() |
| 903 | connChan <- connOrError{conn, err, startTime, endTime} |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 904 | close(connChan) |
| 905 | }() |
| 906 | select { |
| 907 | case result := <-connChan: |
David Benjamin | c386440 | 2017-07-14 16:48:36 -0400 | [diff] [blame] | 908 | if result.err != nil { |
| 909 | // TODO(davidben): Remove this logging when |
| 910 | // https://crbug.com/boringssl/199 is resolved. |
| 911 | fmt.Fprintf(os.Stderr, "acceptOrWait failed, startTime=%v, endTime=%v\n", result.startTime, result.endTime) |
| 912 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 913 | return result.conn, result.err |
| 914 | case childErr := <-waitChan: |
| 915 | waitChan <- childErr |
| 916 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 917 | } |
| 918 | } |
| 919 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 920 | func translateExpectedError(errorStr string) string { |
| 921 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 922 | return translated |
| 923 | } |
| 924 | |
| 925 | if *looseErrors { |
| 926 | return "" |
| 927 | } |
| 928 | |
| 929 | return errorStr |
| 930 | } |
| 931 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 932 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 933 | // Help debugging panics on the Go side. |
| 934 | defer func() { |
| 935 | if r := recover(); r != nil { |
| 936 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 937 | panic(r) |
| 938 | } |
| 939 | }() |
| 940 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 941 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 942 | panic("Error expected without shouldFail in " + test.name) |
| 943 | } |
| 944 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 945 | if test.expectResumeRejected && !test.resumeSession { |
| 946 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 947 | } |
| 948 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 949 | for _, ver := range tlsVersions { |
| 950 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 951 | continue |
| 952 | } |
| 953 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 954 | if test.config.MaxVersion == 0 && test.config.MinVersion == 0 && test.expectedVersion == 0 { |
| 955 | panic(fmt.Sprintf("The name of test %q suggests that it's version specific, but min/max version in the Config is %x/%x. One of them should probably be %x", test.name, test.config.MinVersion, test.config.MaxVersion, ver.version)) |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 956 | } |
| 957 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 958 | if ver.tls13Variant != 0 { |
| 959 | var foundFlag bool |
| 960 | for _, flag := range test.flags { |
| 961 | if flag == "-tls13-variant" { |
| 962 | foundFlag = true |
| 963 | break |
| 964 | } |
| 965 | } |
| 966 | if !foundFlag && test.config.TLS13Variant != ver.tls13Variant && test.tls13Variant != ver.tls13Variant { |
| 967 | panic(fmt.Sprintf("The name of test %q suggests that uses an experimental TLS 1.3 variant, but neither the shim nor the runner configures it", test.name)) |
| 968 | } |
| 969 | } |
| 970 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 971 | } |
| 972 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 973 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 974 | if err != nil { |
| 975 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 976 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 977 | if err != nil { |
| 978 | panic(err) |
| 979 | } |
| 980 | defer func() { |
| 981 | if listener != nil { |
| 982 | listener.Close() |
| 983 | } |
| 984 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 985 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 986 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 987 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 988 | flags = append(flags, "-server") |
| 989 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 990 | flags = append(flags, "-key-file") |
| 991 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 992 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 993 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 994 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | flags = append(flags, "-cert-file") |
| 998 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 999 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1000 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1001 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1002 | } |
| 1003 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1004 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 1005 | if test.protocol == dtls { |
| 1006 | flags = append(flags, "-dtls") |
| 1007 | } |
| 1008 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1009 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1010 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1011 | resumeCount++ |
| 1012 | if test.resumeRenewedSession { |
| 1013 | resumeCount++ |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | if resumeCount > 0 { |
| 1018 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 1019 | } |
| 1020 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 1021 | if test.shimWritesFirst { |
| 1022 | flags = append(flags, "-shim-writes-first") |
| 1023 | } |
| 1024 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 1025 | if test.readWithUnfinishedWrite { |
| 1026 | flags = append(flags, "-read-with-unfinished-write") |
| 1027 | } |
| 1028 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 1029 | if test.shimShutsDown { |
| 1030 | flags = append(flags, "-shim-shuts-down") |
| 1031 | } |
| 1032 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1033 | if test.exportKeyingMaterial > 0 { |
| 1034 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 1035 | flags = append(flags, "-export-label", test.exportLabel) |
| 1036 | flags = append(flags, "-export-context", test.exportContext) |
| 1037 | if test.useExportContext { |
| 1038 | flags = append(flags, "-use-export-context") |
| 1039 | } |
| 1040 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 1041 | if test.expectResumeRejected { |
| 1042 | flags = append(flags, "-expect-session-miss") |
| 1043 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 1044 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 1045 | if test.testTLSUnique { |
| 1046 | flags = append(flags, "-tls-unique") |
| 1047 | } |
| 1048 | |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1049 | if test.tls13Variant != 0 { |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 1050 | flags = append(flags, "-tls13-variant", strconv.Itoa(test.tls13Variant)) |
| 1051 | } |
| 1052 | |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1053 | var transcriptPrefix string |
| 1054 | if len(*transcriptDir) != 0 { |
| 1055 | protocol := "tls" |
| 1056 | if test.protocol == dtls { |
| 1057 | protocol = "dtls" |
| 1058 | } |
| 1059 | |
| 1060 | side := "client" |
| 1061 | if test.testType == serverTest { |
| 1062 | side = "server" |
| 1063 | } |
| 1064 | |
| 1065 | dir := filepath.Join(*transcriptDir, protocol, side) |
| 1066 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 1067 | return err |
| 1068 | } |
| 1069 | transcriptPrefix = filepath.Join(dir, test.name+"-") |
| 1070 | flags = append(flags, "-write-settings", transcriptPrefix) |
| 1071 | } |
| 1072 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1073 | flags = append(flags, test.flags...) |
| 1074 | |
| 1075 | var shim *exec.Cmd |
| 1076 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1077 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1078 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1079 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1080 | } else if *useLLDB { |
| 1081 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1082 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1083 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1084 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1085 | shim.Stdin = os.Stdin |
| 1086 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1087 | shim.Stdout = &stdoutBuf |
| 1088 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1089 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1090 | shim.Env = os.Environ() |
| 1091 | shim.Env = append(shim.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10)) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1092 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1093 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1094 | } |
| 1095 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1096 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1097 | |
| 1098 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1099 | panic(err) |
| 1100 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1101 | waitChan := make(chan error, 1) |
| 1102 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1103 | |
| 1104 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1105 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1106 | if *deterministic { |
| 1107 | config.Rand = &deterministicRand{} |
| 1108 | } |
| 1109 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1110 | conn, err := acceptOrWait(listener, waitChan) |
| 1111 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1112 | err = doExchange(test, &config, conn, false /* not a resumption */, transcriptPrefix, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1113 | conn.Close() |
| 1114 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1115 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1116 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1117 | var resumeConfig Config |
| 1118 | if test.resumeConfig != nil { |
| 1119 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1120 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1121 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1122 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1123 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1124 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1125 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1126 | } else { |
| 1127 | resumeConfig = config |
| 1128 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1129 | var connResume net.Conn |
| 1130 | connResume, err = acceptOrWait(listener, waitChan) |
| 1131 | if err == nil { |
David Benjamin | 0fde2eb | 2017-06-30 19:11:22 -0400 | [diff] [blame] | 1132 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, transcriptPrefix, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1133 | connResume.Close() |
| 1134 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1135 | } |
| 1136 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1137 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1138 | // open more connections than expected. |
| 1139 | listener.Close() |
| 1140 | listener = nil |
| 1141 | |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1142 | var shimKilledLock sync.Mutex |
| 1143 | var shimKilled bool |
| 1144 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1145 | shimKilledLock.Lock() |
| 1146 | shimKilled = true |
| 1147 | shimKilledLock.Unlock() |
| 1148 | shim.Process.Kill() |
| 1149 | }) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1150 | childErr := <-waitChan |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1151 | waitTimeout.Stop() |
| 1152 | shimKilledLock.Lock() |
| 1153 | if shimKilled && err == nil { |
| 1154 | err = errors.New("timeout waiting for the shim to exit.") |
| 1155 | } |
| 1156 | shimKilledLock.Unlock() |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1157 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1158 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1159 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1160 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1161 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1162 | case 89: |
| 1163 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1164 | case 99: |
| 1165 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1166 | } |
| 1167 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1168 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1169 | // Account for Windows line endings. |
| 1170 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1171 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1172 | |
| 1173 | // Separate the errors from the shim and those from tools like |
| 1174 | // AddressSanitizer. |
| 1175 | var extraStderr string |
| 1176 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1177 | stderr = stderrParts[0] |
| 1178 | extraStderr = stderrParts[1] |
| 1179 | } |
| 1180 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1181 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1182 | expectedError := translateExpectedError(test.expectedError) |
| 1183 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1184 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1185 | localError := "none" |
| 1186 | if err != nil { |
| 1187 | localError = err.Error() |
| 1188 | } |
| 1189 | if len(test.expectedLocalError) != 0 { |
| 1190 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1191 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1192 | |
| 1193 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1194 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1195 | if childErr != nil { |
| 1196 | childError = childErr.Error() |
| 1197 | } |
| 1198 | |
| 1199 | var msg string |
| 1200 | switch { |
| 1201 | case failed && !test.shouldFail: |
| 1202 | msg = "unexpected failure" |
| 1203 | case !failed && test.shouldFail: |
| 1204 | msg = "unexpected success" |
| 1205 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1206 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1207 | default: |
| 1208 | panic("internal error") |
| 1209 | } |
| 1210 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1211 | return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s\n%s", msg, localError, childError, stdout, stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1212 | } |
| 1213 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1214 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1215 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1216 | } |
| 1217 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1218 | if *useValgrind && isValgrindError { |
| 1219 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1220 | } |
| 1221 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1222 | return nil |
| 1223 | } |
| 1224 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1225 | type tlsVersion struct { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1226 | name string |
| 1227 | // version is the protocol version. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1228 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1229 | // excludeFlag is the legacy shim flag to disable the version. |
| 1230 | excludeFlag string |
| 1231 | hasDTLS bool |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1232 | // versionDTLS, if non-zero, is the DTLS-specific representation of the version. |
| 1233 | versionDTLS uint16 |
| 1234 | // versionWire, if non-zero, is the wire representation of the |
| 1235 | // version. Otherwise the wire version is the protocol version or |
| 1236 | // versionDTLS. |
| 1237 | versionWire uint16 |
| 1238 | tls13Variant int |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1242 | // The shim uses the protocol version in its public API, but uses the |
| 1243 | // DTLS-specific version if it exists. |
| 1244 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1245 | return strconv.Itoa(int(vers.versionDTLS)) |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame] | 1246 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1247 | return strconv.Itoa(int(vers.version)) |
| 1248 | } |
| 1249 | |
| 1250 | func (vers tlsVersion) wire(protocol protocol) uint16 { |
| 1251 | if protocol == dtls && vers.versionDTLS != 0 { |
| 1252 | return vers.versionDTLS |
| 1253 | } |
| 1254 | if vers.versionWire != 0 { |
| 1255 | return vers.versionWire |
| 1256 | } |
| 1257 | return vers.version |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | var tlsVersions = []tlsVersion{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1261 | { |
| 1262 | name: "SSL3", |
| 1263 | version: VersionSSL30, |
| 1264 | excludeFlag: "-no-ssl3", |
| 1265 | }, |
| 1266 | { |
| 1267 | name: "TLS1", |
| 1268 | version: VersionTLS10, |
| 1269 | excludeFlag: "-no-tls1", |
| 1270 | hasDTLS: true, |
| 1271 | versionDTLS: VersionDTLS10, |
| 1272 | }, |
| 1273 | { |
| 1274 | name: "TLS11", |
| 1275 | version: VersionTLS11, |
| 1276 | excludeFlag: "-no-tls11", |
| 1277 | }, |
| 1278 | { |
| 1279 | name: "TLS12", |
| 1280 | version: VersionTLS12, |
| 1281 | excludeFlag: "-no-tls12", |
| 1282 | hasDTLS: true, |
| 1283 | versionDTLS: VersionDTLS12, |
| 1284 | }, |
| 1285 | { |
| 1286 | name: "TLS13", |
| 1287 | version: VersionTLS13, |
| 1288 | excludeFlag: "-no-tls13", |
| 1289 | versionWire: tls13DraftVersion, |
| 1290 | tls13Variant: TLS13Default, |
| 1291 | }, |
| 1292 | { |
| 1293 | name: "TLS13Experiment", |
| 1294 | version: VersionTLS13, |
| 1295 | excludeFlag: "-no-tls13", |
| 1296 | versionWire: tls13ExperimentVersion, |
| 1297 | tls13Variant: TLS13Experiment, |
| 1298 | }, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 1299 | { |
| 1300 | name: "TLS13RecordTypeExperiment", |
| 1301 | version: VersionTLS13, |
| 1302 | excludeFlag: "-no-tls13", |
| 1303 | versionWire: tls13RecordTypeExperimentVersion, |
| 1304 | tls13Variant: TLS13RecordTypeExperiment, |
| 1305 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | func allVersions(protocol protocol) []tlsVersion { |
| 1309 | if protocol == tls { |
| 1310 | return tlsVersions |
| 1311 | } |
| 1312 | |
| 1313 | var ret []tlsVersion |
| 1314 | for _, vers := range tlsVersions { |
| 1315 | if vers.hasDTLS { |
| 1316 | ret = append(ret, vers) |
| 1317 | } |
| 1318 | } |
| 1319 | return ret |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1322 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1323 | name string |
| 1324 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1328 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1329 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1330 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1331 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1332 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1333 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1334 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1335 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1336 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1337 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1338 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1339 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1340 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1341 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1342 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1343 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1344 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1345 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1346 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1347 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1348 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1349 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1350 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1351 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1352 | {"ECDHE-PSK-AES256-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1353 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1354 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1355 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1356 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1357 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1360 | func hasComponent(suiteName, component string) bool { |
| 1361 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1362 | } |
| 1363 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1364 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1365 | return hasComponent(suiteName, "GCM") || |
| 1366 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1367 | hasComponent(suiteName, "SHA384") || |
| 1368 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1369 | } |
| 1370 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1371 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1372 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1373 | } |
| 1374 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1375 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1376 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1377 | } |
| 1378 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1379 | func bigFromHex(hex string) *big.Int { |
| 1380 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1381 | if !ok { |
| 1382 | panic("failed to parse hex number 0x" + hex) |
| 1383 | } |
| 1384 | return ret |
| 1385 | } |
| 1386 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1387 | func addBasicTests() { |
| 1388 | basicTests := []testCase{ |
| 1389 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1390 | name: "NoFallbackSCSV", |
| 1391 | config: Config{ |
| 1392 | Bugs: ProtocolBugs{ |
| 1393 | FailIfNotFallbackSCSV: true, |
| 1394 | }, |
| 1395 | }, |
| 1396 | shouldFail: true, |
| 1397 | expectedLocalError: "no fallback SCSV found", |
| 1398 | }, |
| 1399 | { |
| 1400 | name: "SendFallbackSCSV", |
| 1401 | config: Config{ |
| 1402 | Bugs: ProtocolBugs{ |
| 1403 | FailIfNotFallbackSCSV: true, |
| 1404 | }, |
| 1405 | }, |
| 1406 | flags: []string{"-fallback-scsv"}, |
| 1407 | }, |
| 1408 | { |
| 1409 | name: "ClientCertificateTypes", |
| 1410 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1411 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1412 | ClientAuth: RequestClientCert, |
| 1413 | ClientCertificateTypes: []byte{ |
| 1414 | CertTypeDSSSign, |
| 1415 | CertTypeRSASign, |
| 1416 | CertTypeECDSASign, |
| 1417 | }, |
| 1418 | }, |
| 1419 | flags: []string{ |
| 1420 | "-expect-certificate-types", |
| 1421 | base64.StdEncoding.EncodeToString([]byte{ |
| 1422 | CertTypeDSSSign, |
| 1423 | CertTypeRSASign, |
| 1424 | CertTypeECDSASign, |
| 1425 | }), |
| 1426 | }, |
| 1427 | }, |
| 1428 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1429 | name: "UnauthenticatedECDH", |
| 1430 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1431 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1432 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1433 | Bugs: ProtocolBugs{ |
| 1434 | UnauthenticatedECDH: true, |
| 1435 | }, |
| 1436 | }, |
| 1437 | shouldFail: true, |
| 1438 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1439 | }, |
| 1440 | { |
| 1441 | name: "SkipCertificateStatus", |
| 1442 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1443 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1444 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1445 | Bugs: ProtocolBugs{ |
| 1446 | SkipCertificateStatus: true, |
| 1447 | }, |
| 1448 | }, |
| 1449 | flags: []string{ |
| 1450 | "-enable-ocsp-stapling", |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 1451 | // This test involves an optional message. Test the message callback |
| 1452 | // trace to ensure we do not miss or double-report any. |
| 1453 | "-expect-msg-callback", |
| 1454 | `write hs 1 |
| 1455 | read hs 2 |
| 1456 | read hs 11 |
| 1457 | read hs 12 |
| 1458 | read hs 14 |
| 1459 | write hs 16 |
| 1460 | write ccs |
| 1461 | write hs 20 |
| 1462 | read hs 4 |
| 1463 | read ccs |
| 1464 | read hs 20 |
| 1465 | read alert 1 0 |
| 1466 | `, |
| 1467 | }, |
| 1468 | }, |
| 1469 | { |
| 1470 | protocol: dtls, |
| 1471 | name: "SkipCertificateStatus-DTLS", |
| 1472 | config: Config{ |
| 1473 | MaxVersion: VersionTLS12, |
| 1474 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1475 | Bugs: ProtocolBugs{ |
| 1476 | SkipCertificateStatus: true, |
| 1477 | }, |
| 1478 | }, |
| 1479 | flags: []string{ |
| 1480 | "-enable-ocsp-stapling", |
| 1481 | // This test involves an optional message. Test the message callback |
| 1482 | // trace to ensure we do not miss or double-report any. |
| 1483 | "-expect-msg-callback", |
| 1484 | `write hs 1 |
| 1485 | read hs 3 |
| 1486 | write hs 1 |
| 1487 | read hs 2 |
| 1488 | read hs 11 |
| 1489 | read hs 12 |
| 1490 | read hs 14 |
| 1491 | write hs 16 |
| 1492 | write ccs |
| 1493 | write hs 20 |
| 1494 | read hs 4 |
| 1495 | read ccs |
| 1496 | read hs 20 |
| 1497 | read alert 1 0 |
| 1498 | `, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1499 | }, |
| 1500 | }, |
| 1501 | { |
| 1502 | name: "SkipServerKeyExchange", |
| 1503 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1504 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1505 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1506 | Bugs: ProtocolBugs{ |
| 1507 | SkipServerKeyExchange: true, |
| 1508 | }, |
| 1509 | }, |
| 1510 | shouldFail: true, |
| 1511 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1512 | }, |
| 1513 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1514 | testType: serverTest, |
| 1515 | name: "Alert", |
| 1516 | config: Config{ |
| 1517 | Bugs: ProtocolBugs{ |
| 1518 | SendSpuriousAlert: alertRecordOverflow, |
| 1519 | }, |
| 1520 | }, |
| 1521 | shouldFail: true, |
| 1522 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1523 | }, |
| 1524 | { |
| 1525 | protocol: dtls, |
| 1526 | testType: serverTest, |
| 1527 | name: "Alert-DTLS", |
| 1528 | config: Config{ |
| 1529 | Bugs: ProtocolBugs{ |
| 1530 | SendSpuriousAlert: alertRecordOverflow, |
| 1531 | }, |
| 1532 | }, |
| 1533 | shouldFail: true, |
| 1534 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1535 | }, |
| 1536 | { |
| 1537 | testType: serverTest, |
| 1538 | name: "FragmentAlert", |
| 1539 | config: Config{ |
| 1540 | Bugs: ProtocolBugs{ |
| 1541 | FragmentAlert: true, |
| 1542 | SendSpuriousAlert: alertRecordOverflow, |
| 1543 | }, |
| 1544 | }, |
| 1545 | shouldFail: true, |
| 1546 | expectedError: ":BAD_ALERT:", |
| 1547 | }, |
| 1548 | { |
| 1549 | protocol: dtls, |
| 1550 | testType: serverTest, |
| 1551 | name: "FragmentAlert-DTLS", |
| 1552 | config: Config{ |
| 1553 | Bugs: ProtocolBugs{ |
| 1554 | FragmentAlert: true, |
| 1555 | SendSpuriousAlert: alertRecordOverflow, |
| 1556 | }, |
| 1557 | }, |
| 1558 | shouldFail: true, |
| 1559 | expectedError: ":BAD_ALERT:", |
| 1560 | }, |
| 1561 | { |
| 1562 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1563 | name: "DoubleAlert", |
| 1564 | config: Config{ |
| 1565 | Bugs: ProtocolBugs{ |
| 1566 | DoubleAlert: true, |
| 1567 | SendSpuriousAlert: alertRecordOverflow, |
| 1568 | }, |
| 1569 | }, |
| 1570 | shouldFail: true, |
| 1571 | expectedError: ":BAD_ALERT:", |
| 1572 | }, |
| 1573 | { |
| 1574 | protocol: dtls, |
| 1575 | testType: serverTest, |
| 1576 | name: "DoubleAlert-DTLS", |
| 1577 | config: Config{ |
| 1578 | Bugs: ProtocolBugs{ |
| 1579 | DoubleAlert: true, |
| 1580 | SendSpuriousAlert: alertRecordOverflow, |
| 1581 | }, |
| 1582 | }, |
| 1583 | shouldFail: true, |
| 1584 | expectedError: ":BAD_ALERT:", |
| 1585 | }, |
| 1586 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1587 | name: "SkipNewSessionTicket", |
| 1588 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1589 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1590 | Bugs: ProtocolBugs{ |
| 1591 | SkipNewSessionTicket: true, |
| 1592 | }, |
| 1593 | }, |
| 1594 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1595 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1596 | }, |
| 1597 | { |
| 1598 | testType: serverTest, |
| 1599 | name: "FallbackSCSV", |
| 1600 | config: Config{ |
| 1601 | MaxVersion: VersionTLS11, |
| 1602 | Bugs: ProtocolBugs{ |
| 1603 | SendFallbackSCSV: true, |
| 1604 | }, |
| 1605 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1606 | shouldFail: true, |
| 1607 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1608 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1609 | }, |
| 1610 | { |
| 1611 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1612 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1613 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1614 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1615 | Bugs: ProtocolBugs{ |
| 1616 | SendFallbackSCSV: true, |
| 1617 | }, |
| 1618 | }, |
| 1619 | }, |
| 1620 | { |
| 1621 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1622 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1623 | config: Config{ |
| 1624 | MaxVersion: VersionTLS12, |
| 1625 | Bugs: ProtocolBugs{ |
| 1626 | SendFallbackSCSV: true, |
| 1627 | }, |
| 1628 | }, |
| 1629 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1630 | }, |
| 1631 | { |
| 1632 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1633 | name: "FragmentedClientVersion", |
| 1634 | config: Config{ |
| 1635 | Bugs: ProtocolBugs{ |
| 1636 | MaxHandshakeRecordLength: 1, |
| 1637 | FragmentClientVersion: true, |
| 1638 | }, |
| 1639 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1640 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1641 | }, |
| 1642 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1643 | testType: serverTest, |
| 1644 | name: "HttpGET", |
| 1645 | sendPrefix: "GET / HTTP/1.0\n", |
| 1646 | shouldFail: true, |
| 1647 | expectedError: ":HTTP_REQUEST:", |
| 1648 | }, |
| 1649 | { |
| 1650 | testType: serverTest, |
| 1651 | name: "HttpPOST", |
| 1652 | sendPrefix: "POST / HTTP/1.0\n", |
| 1653 | shouldFail: true, |
| 1654 | expectedError: ":HTTP_REQUEST:", |
| 1655 | }, |
| 1656 | { |
| 1657 | testType: serverTest, |
| 1658 | name: "HttpHEAD", |
| 1659 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1660 | shouldFail: true, |
| 1661 | expectedError: ":HTTP_REQUEST:", |
| 1662 | }, |
| 1663 | { |
| 1664 | testType: serverTest, |
| 1665 | name: "HttpPUT", |
| 1666 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1667 | shouldFail: true, |
| 1668 | expectedError: ":HTTP_REQUEST:", |
| 1669 | }, |
| 1670 | { |
| 1671 | testType: serverTest, |
| 1672 | name: "HttpCONNECT", |
| 1673 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1674 | shouldFail: true, |
| 1675 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1676 | }, |
| 1677 | { |
| 1678 | testType: serverTest, |
| 1679 | name: "Garbage", |
| 1680 | sendPrefix: "blah", |
| 1681 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1682 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1683 | }, |
| 1684 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1685 | name: "RSAEphemeralKey", |
| 1686 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1687 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1688 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1689 | Bugs: ProtocolBugs{ |
| 1690 | RSAEphemeralKey: true, |
| 1691 | }, |
| 1692 | }, |
| 1693 | shouldFail: true, |
| 1694 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1695 | }, |
| 1696 | { |
| 1697 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1698 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1699 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1700 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1701 | }, |
| 1702 | { |
| 1703 | protocol: dtls, |
| 1704 | name: "DisableEverything-DTLS", |
| 1705 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1706 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1707 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1708 | }, |
| 1709 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1710 | protocol: dtls, |
| 1711 | testType: serverTest, |
| 1712 | name: "MTU", |
| 1713 | config: Config{ |
| 1714 | Bugs: ProtocolBugs{ |
| 1715 | MaxPacketLength: 256, |
| 1716 | }, |
| 1717 | }, |
| 1718 | flags: []string{"-mtu", "256"}, |
| 1719 | }, |
| 1720 | { |
| 1721 | protocol: dtls, |
| 1722 | testType: serverTest, |
| 1723 | name: "MTUExceeded", |
| 1724 | config: Config{ |
| 1725 | Bugs: ProtocolBugs{ |
| 1726 | MaxPacketLength: 255, |
| 1727 | }, |
| 1728 | }, |
| 1729 | flags: []string{"-mtu", "256"}, |
| 1730 | shouldFail: true, |
| 1731 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1732 | }, |
| 1733 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1734 | name: "EmptyCertificateList", |
| 1735 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1736 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1737 | Bugs: ProtocolBugs{ |
| 1738 | EmptyCertificateList: true, |
| 1739 | }, |
| 1740 | }, |
| 1741 | shouldFail: true, |
| 1742 | expectedError: ":DECODE_ERROR:", |
| 1743 | }, |
| 1744 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1745 | name: "EmptyCertificateList-TLS13", |
| 1746 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1747 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1748 | Bugs: ProtocolBugs{ |
| 1749 | EmptyCertificateList: true, |
| 1750 | }, |
| 1751 | }, |
| 1752 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1753 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1754 | }, |
| 1755 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1756 | name: "TLSFatalBadPackets", |
| 1757 | damageFirstWrite: true, |
| 1758 | shouldFail: true, |
| 1759 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1760 | }, |
| 1761 | { |
| 1762 | protocol: dtls, |
| 1763 | name: "DTLSIgnoreBadPackets", |
| 1764 | damageFirstWrite: true, |
| 1765 | }, |
| 1766 | { |
| 1767 | protocol: dtls, |
| 1768 | name: "DTLSIgnoreBadPackets-Async", |
| 1769 | damageFirstWrite: true, |
| 1770 | flags: []string{"-async"}, |
| 1771 | }, |
| 1772 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1773 | name: "AppDataBeforeHandshake", |
| 1774 | config: Config{ |
| 1775 | Bugs: ProtocolBugs{ |
| 1776 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1777 | }, |
| 1778 | }, |
| 1779 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1780 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1781 | }, |
| 1782 | { |
| 1783 | name: "AppDataBeforeHandshake-Empty", |
| 1784 | config: Config{ |
| 1785 | Bugs: ProtocolBugs{ |
| 1786 | AppDataBeforeHandshake: []byte{}, |
| 1787 | }, |
| 1788 | }, |
| 1789 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1790 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1791 | }, |
| 1792 | { |
| 1793 | protocol: dtls, |
| 1794 | name: "AppDataBeforeHandshake-DTLS", |
| 1795 | config: Config{ |
| 1796 | Bugs: ProtocolBugs{ |
| 1797 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1798 | }, |
| 1799 | }, |
| 1800 | shouldFail: true, |
| 1801 | expectedError: ":UNEXPECTED_RECORD:", |
| 1802 | }, |
| 1803 | { |
| 1804 | protocol: dtls, |
| 1805 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1806 | config: Config{ |
| 1807 | Bugs: ProtocolBugs{ |
| 1808 | AppDataBeforeHandshake: []byte{}, |
| 1809 | }, |
| 1810 | }, |
| 1811 | shouldFail: true, |
| 1812 | expectedError: ":UNEXPECTED_RECORD:", |
| 1813 | }, |
| 1814 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1815 | name: "AppDataAfterChangeCipherSpec", |
| 1816 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1817 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1818 | Bugs: ProtocolBugs{ |
| 1819 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1820 | }, |
| 1821 | }, |
| 1822 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1823 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1824 | }, |
| 1825 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1826 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1827 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1828 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1829 | Bugs: ProtocolBugs{ |
| 1830 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1831 | }, |
| 1832 | }, |
| 1833 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1834 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1835 | }, |
| 1836 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1837 | protocol: dtls, |
| 1838 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1839 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1840 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1841 | Bugs: ProtocolBugs{ |
| 1842 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1843 | }, |
| 1844 | }, |
| 1845 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1846 | // application data. |
| 1847 | }, |
| 1848 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1849 | protocol: dtls, |
| 1850 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1851 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1852 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1853 | Bugs: ProtocolBugs{ |
| 1854 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1855 | }, |
| 1856 | }, |
| 1857 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1858 | // application data. |
| 1859 | }, |
| 1860 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1861 | name: "AlertAfterChangeCipherSpec", |
| 1862 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1863 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1864 | Bugs: ProtocolBugs{ |
| 1865 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1866 | }, |
| 1867 | }, |
| 1868 | shouldFail: true, |
| 1869 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1870 | }, |
| 1871 | { |
| 1872 | protocol: dtls, |
| 1873 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1874 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1875 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1876 | Bugs: ProtocolBugs{ |
| 1877 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1878 | }, |
| 1879 | }, |
| 1880 | shouldFail: true, |
| 1881 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1882 | }, |
| 1883 | { |
| 1884 | protocol: dtls, |
| 1885 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1886 | config: Config{ |
| 1887 | Bugs: ProtocolBugs{ |
| 1888 | ReorderHandshakeFragments: true, |
| 1889 | // Small enough that every handshake message is |
| 1890 | // fragmented. |
| 1891 | MaxHandshakeRecordLength: 2, |
| 1892 | }, |
| 1893 | }, |
| 1894 | }, |
| 1895 | { |
| 1896 | protocol: dtls, |
| 1897 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1898 | config: Config{ |
| 1899 | Bugs: ProtocolBugs{ |
| 1900 | ReorderHandshakeFragments: true, |
| 1901 | // Large enough that no handshake message is |
| 1902 | // fragmented. |
| 1903 | MaxHandshakeRecordLength: 2048, |
| 1904 | }, |
| 1905 | }, |
| 1906 | }, |
| 1907 | { |
| 1908 | protocol: dtls, |
| 1909 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1910 | config: Config{ |
| 1911 | Bugs: ProtocolBugs{ |
| 1912 | ReorderHandshakeFragments: true, |
| 1913 | MixCompleteMessageWithFragments: true, |
| 1914 | MaxHandshakeRecordLength: 2, |
| 1915 | }, |
| 1916 | }, |
| 1917 | }, |
| 1918 | { |
| 1919 | name: "SendInvalidRecordType", |
| 1920 | config: Config{ |
| 1921 | Bugs: ProtocolBugs{ |
| 1922 | SendInvalidRecordType: true, |
| 1923 | }, |
| 1924 | }, |
| 1925 | shouldFail: true, |
| 1926 | expectedError: ":UNEXPECTED_RECORD:", |
| 1927 | }, |
| 1928 | { |
| 1929 | protocol: dtls, |
| 1930 | name: "SendInvalidRecordType-DTLS", |
| 1931 | config: Config{ |
| 1932 | Bugs: ProtocolBugs{ |
| 1933 | SendInvalidRecordType: true, |
| 1934 | }, |
| 1935 | }, |
| 1936 | shouldFail: true, |
| 1937 | expectedError: ":UNEXPECTED_RECORD:", |
| 1938 | }, |
| 1939 | { |
| 1940 | name: "FalseStart-SkipServerSecondLeg", |
| 1941 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1942 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1943 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1944 | NextProtos: []string{"foo"}, |
| 1945 | Bugs: ProtocolBugs{ |
| 1946 | SkipNewSessionTicket: true, |
| 1947 | SkipChangeCipherSpec: true, |
| 1948 | SkipFinished: true, |
| 1949 | ExpectFalseStart: true, |
| 1950 | }, |
| 1951 | }, |
| 1952 | flags: []string{ |
| 1953 | "-false-start", |
| 1954 | "-handshake-never-done", |
| 1955 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1956 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1957 | }, |
| 1958 | shimWritesFirst: true, |
| 1959 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1960 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1961 | }, |
| 1962 | { |
| 1963 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1964 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1965 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1966 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1967 | NextProtos: []string{"foo"}, |
| 1968 | Bugs: ProtocolBugs{ |
| 1969 | SkipNewSessionTicket: true, |
| 1970 | SkipChangeCipherSpec: true, |
| 1971 | SkipFinished: true, |
| 1972 | }, |
| 1973 | }, |
| 1974 | flags: []string{ |
| 1975 | "-implicit-handshake", |
| 1976 | "-false-start", |
| 1977 | "-handshake-never-done", |
| 1978 | "-advertise-alpn", "\x03foo", |
| 1979 | }, |
| 1980 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1981 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1982 | }, |
| 1983 | { |
| 1984 | testType: serverTest, |
| 1985 | name: "FailEarlyCallback", |
| 1986 | flags: []string{"-fail-early-callback"}, |
| 1987 | shouldFail: true, |
| 1988 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1989 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1990 | }, |
| 1991 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1992 | name: "FailCertCallback-Client-TLS12", |
| 1993 | config: Config{ |
| 1994 | MaxVersion: VersionTLS12, |
| 1995 | ClientAuth: RequestClientCert, |
| 1996 | }, |
| 1997 | flags: []string{"-fail-cert-callback"}, |
| 1998 | shouldFail: true, |
| 1999 | expectedError: ":CERT_CB_ERROR:", |
| 2000 | expectedLocalError: "remote error: internal error", |
| 2001 | }, |
| 2002 | { |
| 2003 | testType: serverTest, |
| 2004 | name: "FailCertCallback-Server-TLS12", |
| 2005 | config: Config{ |
| 2006 | MaxVersion: VersionTLS12, |
| 2007 | }, |
| 2008 | flags: []string{"-fail-cert-callback"}, |
| 2009 | shouldFail: true, |
| 2010 | expectedError: ":CERT_CB_ERROR:", |
| 2011 | expectedLocalError: "remote error: internal error", |
| 2012 | }, |
| 2013 | { |
| 2014 | name: "FailCertCallback-Client-TLS13", |
| 2015 | config: Config{ |
| 2016 | MaxVersion: VersionTLS13, |
| 2017 | ClientAuth: RequestClientCert, |
| 2018 | }, |
| 2019 | flags: []string{"-fail-cert-callback"}, |
| 2020 | shouldFail: true, |
| 2021 | expectedError: ":CERT_CB_ERROR:", |
| 2022 | expectedLocalError: "remote error: internal error", |
| 2023 | }, |
| 2024 | { |
| 2025 | testType: serverTest, |
| 2026 | name: "FailCertCallback-Server-TLS13", |
| 2027 | config: Config{ |
| 2028 | MaxVersion: VersionTLS13, |
| 2029 | }, |
| 2030 | flags: []string{"-fail-cert-callback"}, |
| 2031 | shouldFail: true, |
| 2032 | expectedError: ":CERT_CB_ERROR:", |
| 2033 | expectedLocalError: "remote error: internal error", |
| 2034 | }, |
| 2035 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2036 | protocol: dtls, |
| 2037 | name: "FragmentMessageTypeMismatch-DTLS", |
| 2038 | config: Config{ |
| 2039 | Bugs: ProtocolBugs{ |
| 2040 | MaxHandshakeRecordLength: 2, |
| 2041 | FragmentMessageTypeMismatch: true, |
| 2042 | }, |
| 2043 | }, |
| 2044 | shouldFail: true, |
| 2045 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2046 | }, |
| 2047 | { |
| 2048 | protocol: dtls, |
| 2049 | name: "FragmentMessageLengthMismatch-DTLS", |
| 2050 | config: Config{ |
| 2051 | Bugs: ProtocolBugs{ |
| 2052 | MaxHandshakeRecordLength: 2, |
| 2053 | FragmentMessageLengthMismatch: true, |
| 2054 | }, |
| 2055 | }, |
| 2056 | shouldFail: true, |
| 2057 | expectedError: ":FRAGMENT_MISMATCH:", |
| 2058 | }, |
| 2059 | { |
| 2060 | protocol: dtls, |
| 2061 | name: "SplitFragments-Header-DTLS", |
| 2062 | config: Config{ |
| 2063 | Bugs: ProtocolBugs{ |
| 2064 | SplitFragments: 2, |
| 2065 | }, |
| 2066 | }, |
| 2067 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2068 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2069 | }, |
| 2070 | { |
| 2071 | protocol: dtls, |
| 2072 | name: "SplitFragments-Boundary-DTLS", |
| 2073 | config: Config{ |
| 2074 | Bugs: ProtocolBugs{ |
| 2075 | SplitFragments: dtlsRecordHeaderLen, |
| 2076 | }, |
| 2077 | }, |
| 2078 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2079 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2080 | }, |
| 2081 | { |
| 2082 | protocol: dtls, |
| 2083 | name: "SplitFragments-Body-DTLS", |
| 2084 | config: Config{ |
| 2085 | Bugs: ProtocolBugs{ |
| 2086 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 2087 | }, |
| 2088 | }, |
| 2089 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 2090 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2091 | }, |
| 2092 | { |
| 2093 | protocol: dtls, |
| 2094 | name: "SendEmptyFragments-DTLS", |
| 2095 | config: Config{ |
| 2096 | Bugs: ProtocolBugs{ |
| 2097 | SendEmptyFragments: true, |
| 2098 | }, |
| 2099 | }, |
| 2100 | }, |
| 2101 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2102 | name: "BadFinished-Client", |
| 2103 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2104 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2105 | Bugs: ProtocolBugs{ |
| 2106 | BadFinished: true, |
| 2107 | }, |
| 2108 | }, |
| 2109 | shouldFail: true, |
| 2110 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2111 | }, |
| 2112 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2113 | name: "BadFinished-Client-TLS13", |
| 2114 | config: Config{ |
| 2115 | MaxVersion: VersionTLS13, |
| 2116 | Bugs: ProtocolBugs{ |
| 2117 | BadFinished: true, |
| 2118 | }, |
| 2119 | }, |
| 2120 | shouldFail: true, |
| 2121 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2122 | }, |
| 2123 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 2124 | testType: serverTest, |
| 2125 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2126 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2127 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2128 | Bugs: ProtocolBugs{ |
| 2129 | BadFinished: true, |
| 2130 | }, |
| 2131 | }, |
| 2132 | shouldFail: true, |
| 2133 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2134 | }, |
| 2135 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2136 | testType: serverTest, |
| 2137 | name: "BadFinished-Server-TLS13", |
| 2138 | config: Config{ |
| 2139 | MaxVersion: VersionTLS13, |
| 2140 | Bugs: ProtocolBugs{ |
| 2141 | BadFinished: true, |
| 2142 | }, |
| 2143 | }, |
| 2144 | shouldFail: true, |
| 2145 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2146 | }, |
| 2147 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2148 | name: "FalseStart-BadFinished", |
| 2149 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2150 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2151 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2152 | NextProtos: []string{"foo"}, |
| 2153 | Bugs: ProtocolBugs{ |
| 2154 | BadFinished: true, |
| 2155 | ExpectFalseStart: true, |
| 2156 | }, |
| 2157 | }, |
| 2158 | flags: []string{ |
| 2159 | "-false-start", |
| 2160 | "-handshake-never-done", |
| 2161 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 2162 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2163 | }, |
| 2164 | shimWritesFirst: true, |
| 2165 | shouldFail: true, |
| 2166 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 2167 | }, |
| 2168 | { |
| 2169 | name: "NoFalseStart-NoALPN", |
| 2170 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2171 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2172 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2173 | Bugs: ProtocolBugs{ |
| 2174 | ExpectFalseStart: true, |
| 2175 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2176 | }, |
| 2177 | }, |
| 2178 | flags: []string{ |
| 2179 | "-false-start", |
| 2180 | }, |
| 2181 | shimWritesFirst: true, |
| 2182 | shouldFail: true, |
| 2183 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2184 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2185 | }, |
| 2186 | { |
| 2187 | name: "NoFalseStart-NoAEAD", |
| 2188 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2189 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2190 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2191 | NextProtos: []string{"foo"}, |
| 2192 | Bugs: ProtocolBugs{ |
| 2193 | ExpectFalseStart: true, |
| 2194 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2195 | }, |
| 2196 | }, |
| 2197 | flags: []string{ |
| 2198 | "-false-start", |
| 2199 | "-advertise-alpn", "\x03foo", |
| 2200 | }, |
| 2201 | shimWritesFirst: true, |
| 2202 | shouldFail: true, |
| 2203 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2204 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2205 | }, |
| 2206 | { |
| 2207 | name: "NoFalseStart-RSA", |
| 2208 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2209 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2210 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2211 | NextProtos: []string{"foo"}, |
| 2212 | Bugs: ProtocolBugs{ |
| 2213 | ExpectFalseStart: true, |
| 2214 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2215 | }, |
| 2216 | }, |
| 2217 | flags: []string{ |
| 2218 | "-false-start", |
| 2219 | "-advertise-alpn", "\x03foo", |
| 2220 | }, |
| 2221 | shimWritesFirst: true, |
| 2222 | shouldFail: true, |
| 2223 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2224 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2225 | }, |
| 2226 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2227 | protocol: dtls, |
| 2228 | name: "SendSplitAlert-Sync", |
| 2229 | config: Config{ |
| 2230 | Bugs: ProtocolBugs{ |
| 2231 | SendSplitAlert: true, |
| 2232 | }, |
| 2233 | }, |
| 2234 | }, |
| 2235 | { |
| 2236 | protocol: dtls, |
| 2237 | name: "SendSplitAlert-Async", |
| 2238 | config: Config{ |
| 2239 | Bugs: ProtocolBugs{ |
| 2240 | SendSplitAlert: true, |
| 2241 | }, |
| 2242 | }, |
| 2243 | flags: []string{"-async"}, |
| 2244 | }, |
| 2245 | { |
| 2246 | protocol: dtls, |
| 2247 | name: "PackDTLSHandshake", |
| 2248 | config: Config{ |
| 2249 | Bugs: ProtocolBugs{ |
| 2250 | MaxHandshakeRecordLength: 2, |
| 2251 | PackHandshakeFragments: 20, |
| 2252 | PackHandshakeRecords: 200, |
| 2253 | }, |
| 2254 | }, |
| 2255 | }, |
| 2256 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2257 | name: "SendEmptyRecords-Pass", |
| 2258 | sendEmptyRecords: 32, |
| 2259 | }, |
| 2260 | { |
| 2261 | name: "SendEmptyRecords", |
| 2262 | sendEmptyRecords: 33, |
| 2263 | shouldFail: true, |
| 2264 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2265 | }, |
| 2266 | { |
| 2267 | name: "SendEmptyRecords-Async", |
| 2268 | sendEmptyRecords: 33, |
| 2269 | flags: []string{"-async"}, |
| 2270 | shouldFail: true, |
| 2271 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2272 | }, |
| 2273 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2274 | name: "SendWarningAlerts-Pass", |
| 2275 | config: Config{ |
| 2276 | MaxVersion: VersionTLS12, |
| 2277 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2278 | sendWarningAlerts: 4, |
| 2279 | }, |
| 2280 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2281 | protocol: dtls, |
| 2282 | name: "SendWarningAlerts-DTLS-Pass", |
| 2283 | config: Config{ |
| 2284 | MaxVersion: VersionTLS12, |
| 2285 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2286 | sendWarningAlerts: 4, |
| 2287 | }, |
| 2288 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2289 | name: "SendWarningAlerts-TLS13", |
| 2290 | config: Config{ |
| 2291 | MaxVersion: VersionTLS13, |
| 2292 | }, |
| 2293 | sendWarningAlerts: 4, |
| 2294 | shouldFail: true, |
| 2295 | expectedError: ":BAD_ALERT:", |
| 2296 | expectedLocalError: "remote error: error decoding message", |
| 2297 | }, |
| 2298 | { |
| 2299 | name: "SendWarningAlerts", |
| 2300 | config: Config{ |
| 2301 | MaxVersion: VersionTLS12, |
| 2302 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2303 | sendWarningAlerts: 5, |
| 2304 | shouldFail: true, |
| 2305 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2306 | }, |
| 2307 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2308 | name: "SendWarningAlerts-Async", |
| 2309 | config: Config{ |
| 2310 | MaxVersion: VersionTLS12, |
| 2311 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2312 | sendWarningAlerts: 5, |
| 2313 | flags: []string{"-async"}, |
| 2314 | shouldFail: true, |
| 2315 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2316 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2317 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2318 | name: "SendBogusAlertType", |
| 2319 | sendBogusAlertType: true, |
| 2320 | shouldFail: true, |
| 2321 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2322 | expectedLocalError: "remote error: illegal parameter", |
| 2323 | }, |
| 2324 | { |
| 2325 | protocol: dtls, |
| 2326 | name: "SendBogusAlertType-DTLS", |
| 2327 | sendBogusAlertType: true, |
| 2328 | shouldFail: true, |
| 2329 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2330 | expectedLocalError: "remote error: illegal parameter", |
| 2331 | }, |
| 2332 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2333 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2334 | config: Config{ |
| 2335 | MaxVersion: VersionTLS13, |
| 2336 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2337 | sendKeyUpdates: 33, |
| 2338 | keyUpdateRequest: keyUpdateNotRequested, |
| 2339 | shouldFail: true, |
| 2340 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2341 | }, |
| 2342 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2343 | name: "EmptySessionID", |
| 2344 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2345 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2346 | SessionTicketsDisabled: true, |
| 2347 | }, |
| 2348 | noSessionCache: true, |
| 2349 | flags: []string{"-expect-no-session"}, |
| 2350 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2351 | { |
| 2352 | name: "Unclean-Shutdown", |
| 2353 | config: Config{ |
| 2354 | Bugs: ProtocolBugs{ |
| 2355 | NoCloseNotify: true, |
| 2356 | ExpectCloseNotify: true, |
| 2357 | }, |
| 2358 | }, |
| 2359 | shimShutsDown: true, |
| 2360 | flags: []string{"-check-close-notify"}, |
| 2361 | shouldFail: true, |
| 2362 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2363 | }, |
| 2364 | { |
| 2365 | name: "Unclean-Shutdown-Ignored", |
| 2366 | config: Config{ |
| 2367 | Bugs: ProtocolBugs{ |
| 2368 | NoCloseNotify: true, |
| 2369 | }, |
| 2370 | }, |
| 2371 | shimShutsDown: true, |
| 2372 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2373 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2374 | name: "Unclean-Shutdown-Alert", |
| 2375 | config: Config{ |
| 2376 | Bugs: ProtocolBugs{ |
| 2377 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2378 | ExpectCloseNotify: true, |
| 2379 | }, |
| 2380 | }, |
| 2381 | shimShutsDown: true, |
| 2382 | flags: []string{"-check-close-notify"}, |
| 2383 | shouldFail: true, |
| 2384 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2385 | }, |
| 2386 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2387 | name: "LargePlaintext", |
| 2388 | config: Config{ |
| 2389 | Bugs: ProtocolBugs{ |
| 2390 | SendLargeRecords: true, |
| 2391 | }, |
| 2392 | }, |
| 2393 | messageLen: maxPlaintext + 1, |
| 2394 | shouldFail: true, |
| 2395 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2396 | }, |
| 2397 | { |
| 2398 | protocol: dtls, |
| 2399 | name: "LargePlaintext-DTLS", |
| 2400 | config: Config{ |
| 2401 | Bugs: ProtocolBugs{ |
| 2402 | SendLargeRecords: true, |
| 2403 | }, |
| 2404 | }, |
| 2405 | messageLen: maxPlaintext + 1, |
| 2406 | shouldFail: true, |
| 2407 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2408 | }, |
| 2409 | { |
| 2410 | name: "LargeCiphertext", |
| 2411 | config: Config{ |
| 2412 | Bugs: ProtocolBugs{ |
| 2413 | SendLargeRecords: true, |
| 2414 | }, |
| 2415 | }, |
| 2416 | messageLen: maxPlaintext * 2, |
| 2417 | shouldFail: true, |
| 2418 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2419 | }, |
| 2420 | { |
| 2421 | protocol: dtls, |
| 2422 | name: "LargeCiphertext-DTLS", |
| 2423 | config: Config{ |
| 2424 | Bugs: ProtocolBugs{ |
| 2425 | SendLargeRecords: true, |
| 2426 | }, |
| 2427 | }, |
| 2428 | messageLen: maxPlaintext * 2, |
| 2429 | // Unlike the other four cases, DTLS drops records which |
| 2430 | // are invalid before authentication, so the connection |
| 2431 | // does not fail. |
| 2432 | expectMessageDropped: true, |
| 2433 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2434 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2435 | name: "BadHelloRequest-1", |
| 2436 | renegotiate: 1, |
| 2437 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2438 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2439 | Bugs: ProtocolBugs{ |
| 2440 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2441 | }, |
| 2442 | }, |
| 2443 | flags: []string{ |
| 2444 | "-renegotiate-freely", |
| 2445 | "-expect-total-renegotiations", "1", |
| 2446 | }, |
| 2447 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2448 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2449 | }, |
| 2450 | { |
| 2451 | name: "BadHelloRequest-2", |
| 2452 | renegotiate: 1, |
| 2453 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2454 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2455 | Bugs: ProtocolBugs{ |
| 2456 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2457 | }, |
| 2458 | }, |
| 2459 | flags: []string{ |
| 2460 | "-renegotiate-freely", |
| 2461 | "-expect-total-renegotiations", "1", |
| 2462 | }, |
| 2463 | shouldFail: true, |
| 2464 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2465 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2466 | { |
| 2467 | testType: serverTest, |
| 2468 | name: "SupportTicketsWithSessionID", |
| 2469 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2470 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2471 | SessionTicketsDisabled: true, |
| 2472 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2473 | resumeConfig: &Config{ |
| 2474 | MaxVersion: VersionTLS12, |
| 2475 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2476 | resumeSession: true, |
| 2477 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2478 | { |
| 2479 | protocol: dtls, |
| 2480 | name: "DTLS-SendExtraFinished", |
| 2481 | config: Config{ |
| 2482 | Bugs: ProtocolBugs{ |
| 2483 | SendExtraFinished: true, |
| 2484 | }, |
| 2485 | }, |
| 2486 | shouldFail: true, |
| 2487 | expectedError: ":UNEXPECTED_RECORD:", |
| 2488 | }, |
| 2489 | { |
| 2490 | protocol: dtls, |
| 2491 | name: "DTLS-SendExtraFinished-Reordered", |
| 2492 | config: Config{ |
| 2493 | Bugs: ProtocolBugs{ |
| 2494 | MaxHandshakeRecordLength: 2, |
| 2495 | ReorderHandshakeFragments: true, |
| 2496 | SendExtraFinished: true, |
| 2497 | }, |
| 2498 | }, |
| 2499 | shouldFail: true, |
| 2500 | expectedError: ":UNEXPECTED_RECORD:", |
| 2501 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2502 | { |
| 2503 | testType: serverTest, |
| 2504 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2505 | config: Config{ |
| 2506 | // Choose a cipher suite that does not involve |
| 2507 | // elliptic curves, so no extensions are |
| 2508 | // involved. |
| 2509 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2510 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2511 | Bugs: ProtocolBugs{ |
| 2512 | SendV2ClientHello: true, |
| 2513 | }, |
| 2514 | }, |
| 2515 | sendPrefix: string([]byte{ |
| 2516 | byte(recordTypeHandshake), |
| 2517 | 3, 1, // version |
| 2518 | 0, 0, // length |
| 2519 | }), |
| 2520 | // A no-op empty record may not be sent before V2ClientHello. |
| 2521 | shouldFail: true, |
| 2522 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2523 | }, |
| 2524 | { |
| 2525 | testType: serverTest, |
| 2526 | name: "V2ClientHello-WarningAlertPrefix", |
| 2527 | config: Config{ |
| 2528 | // Choose a cipher suite that does not involve |
| 2529 | // elliptic curves, so no extensions are |
| 2530 | // involved. |
| 2531 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2532 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2533 | Bugs: ProtocolBugs{ |
| 2534 | SendV2ClientHello: true, |
| 2535 | }, |
| 2536 | }, |
| 2537 | sendPrefix: string([]byte{ |
| 2538 | byte(recordTypeAlert), |
| 2539 | 3, 1, // version |
| 2540 | 0, 2, // length |
| 2541 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2542 | }), |
| 2543 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2544 | shouldFail: true, |
| 2545 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2546 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2547 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2548 | name: "KeyUpdate-Client", |
| 2549 | config: Config{ |
| 2550 | MaxVersion: VersionTLS13, |
| 2551 | }, |
| 2552 | sendKeyUpdates: 1, |
| 2553 | keyUpdateRequest: keyUpdateNotRequested, |
| 2554 | }, |
| 2555 | { |
| 2556 | testType: serverTest, |
| 2557 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2558 | config: Config{ |
| 2559 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2560 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2561 | sendKeyUpdates: 1, |
| 2562 | keyUpdateRequest: keyUpdateNotRequested, |
| 2563 | }, |
| 2564 | { |
| 2565 | name: "KeyUpdate-InvalidRequestMode", |
| 2566 | config: Config{ |
| 2567 | MaxVersion: VersionTLS13, |
| 2568 | }, |
| 2569 | sendKeyUpdates: 1, |
| 2570 | keyUpdateRequest: 42, |
| 2571 | shouldFail: true, |
| 2572 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2573 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2574 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2575 | // Test that KeyUpdates are acknowledged properly. |
| 2576 | name: "KeyUpdate-RequestACK", |
| 2577 | config: Config{ |
| 2578 | MaxVersion: VersionTLS13, |
| 2579 | Bugs: ProtocolBugs{ |
| 2580 | RejectUnsolicitedKeyUpdate: true, |
| 2581 | }, |
| 2582 | }, |
| 2583 | // Test the shim receiving many KeyUpdates in a row. |
| 2584 | sendKeyUpdates: 5, |
| 2585 | messageCount: 5, |
| 2586 | keyUpdateRequest: keyUpdateRequested, |
| 2587 | }, |
| 2588 | { |
| 2589 | // Test that KeyUpdates are acknowledged properly if the |
| 2590 | // peer's KeyUpdate is discovered while a write is |
| 2591 | // pending. |
| 2592 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2593 | config: Config{ |
| 2594 | MaxVersion: VersionTLS13, |
| 2595 | Bugs: ProtocolBugs{ |
| 2596 | RejectUnsolicitedKeyUpdate: true, |
| 2597 | }, |
| 2598 | }, |
| 2599 | // Test the shim receiving many KeyUpdates in a row. |
| 2600 | sendKeyUpdates: 5, |
| 2601 | messageCount: 5, |
| 2602 | keyUpdateRequest: keyUpdateRequested, |
| 2603 | readWithUnfinishedWrite: true, |
| 2604 | flags: []string{"-async"}, |
| 2605 | }, |
| 2606 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2607 | name: "SendSNIWarningAlert", |
| 2608 | config: Config{ |
| 2609 | MaxVersion: VersionTLS12, |
| 2610 | Bugs: ProtocolBugs{ |
| 2611 | SendSNIWarningAlert: true, |
| 2612 | }, |
| 2613 | }, |
| 2614 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2615 | { |
| 2616 | testType: serverTest, |
| 2617 | name: "ExtraCompressionMethods-TLS12", |
| 2618 | config: Config{ |
| 2619 | MaxVersion: VersionTLS12, |
| 2620 | Bugs: ProtocolBugs{ |
| 2621 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2622 | }, |
| 2623 | }, |
| 2624 | }, |
| 2625 | { |
| 2626 | testType: serverTest, |
| 2627 | name: "ExtraCompressionMethods-TLS13", |
| 2628 | config: Config{ |
| 2629 | MaxVersion: VersionTLS13, |
| 2630 | Bugs: ProtocolBugs{ |
| 2631 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2632 | }, |
| 2633 | }, |
| 2634 | shouldFail: true, |
| 2635 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2636 | expectedLocalError: "remote error: illegal parameter", |
| 2637 | }, |
| 2638 | { |
| 2639 | testType: serverTest, |
| 2640 | name: "NoNullCompression-TLS12", |
| 2641 | config: Config{ |
| 2642 | MaxVersion: VersionTLS12, |
| 2643 | Bugs: ProtocolBugs{ |
| 2644 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2645 | }, |
| 2646 | }, |
| 2647 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2648 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2649 | expectedLocalError: "remote error: illegal parameter", |
| 2650 | }, |
| 2651 | { |
| 2652 | testType: serverTest, |
| 2653 | name: "NoNullCompression-TLS13", |
| 2654 | config: Config{ |
| 2655 | MaxVersion: VersionTLS13, |
| 2656 | Bugs: ProtocolBugs{ |
| 2657 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2658 | }, |
| 2659 | }, |
| 2660 | shouldFail: true, |
| 2661 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2662 | expectedLocalError: "remote error: illegal parameter", |
| 2663 | }, |
David Benjamin | 413e79e | 2017-07-01 10:11:53 -0400 | [diff] [blame] | 2664 | // Test that the client rejects invalid compression methods |
| 2665 | // from the server. |
| 2666 | { |
| 2667 | testType: clientTest, |
| 2668 | name: "InvalidCompressionMethod", |
| 2669 | config: Config{ |
| 2670 | MaxVersion: VersionTLS12, |
| 2671 | Bugs: ProtocolBugs{ |
| 2672 | SendCompressionMethod: 1, |
| 2673 | }, |
| 2674 | }, |
| 2675 | shouldFail: true, |
| 2676 | expectedError: ":UNSUPPORTED_COMPRESSION_ALGORITHM:", |
| 2677 | expectedLocalError: "remote error: illegal parameter", |
| 2678 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2679 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2680 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2681 | config: Config{ |
| 2682 | MaxVersion: VersionTLS12, |
| 2683 | Bugs: ProtocolBugs{ |
| 2684 | ExpectGREASE: true, |
| 2685 | }, |
| 2686 | }, |
| 2687 | flags: []string{"-enable-grease"}, |
| 2688 | }, |
| 2689 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2690 | name: "GREASE-Client-TLS13", |
| 2691 | config: Config{ |
| 2692 | MaxVersion: VersionTLS13, |
| 2693 | Bugs: ProtocolBugs{ |
| 2694 | ExpectGREASE: true, |
| 2695 | }, |
| 2696 | }, |
| 2697 | flags: []string{"-enable-grease"}, |
| 2698 | }, |
| 2699 | { |
| 2700 | testType: serverTest, |
| 2701 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2702 | config: Config{ |
| 2703 | MaxVersion: VersionTLS13, |
| 2704 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2705 | // TLS 1.3 servers are expected to |
| 2706 | // always enable GREASE. TLS 1.3 is new, |
| 2707 | // so there is no existing ecosystem to |
| 2708 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2709 | ExpectGREASE: true, |
| 2710 | }, |
| 2711 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2712 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2713 | { |
| 2714 | // Test the server so there is a large certificate as |
| 2715 | // well as application data. |
| 2716 | testType: serverTest, |
| 2717 | name: "MaxSendFragment", |
| 2718 | config: Config{ |
| 2719 | Bugs: ProtocolBugs{ |
| 2720 | MaxReceivePlaintext: 512, |
| 2721 | }, |
| 2722 | }, |
| 2723 | messageLen: 1024, |
| 2724 | flags: []string{ |
| 2725 | "-max-send-fragment", "512", |
| 2726 | "-read-size", "1024", |
| 2727 | }, |
| 2728 | }, |
| 2729 | { |
| 2730 | // Test the server so there is a large certificate as |
| 2731 | // well as application data. |
| 2732 | testType: serverTest, |
| 2733 | name: "MaxSendFragment-TooLarge", |
| 2734 | config: Config{ |
| 2735 | Bugs: ProtocolBugs{ |
| 2736 | // Ensure that some of the records are |
| 2737 | // 512. |
| 2738 | MaxReceivePlaintext: 511, |
| 2739 | }, |
| 2740 | }, |
| 2741 | messageLen: 1024, |
| 2742 | flags: []string{ |
| 2743 | "-max-send-fragment", "512", |
| 2744 | "-read-size", "1024", |
| 2745 | }, |
| 2746 | shouldFail: true, |
| 2747 | expectedLocalError: "local error: record overflow", |
| 2748 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2749 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2750 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2751 | |
| 2752 | // Test that very large messages can be received. |
| 2753 | cert := rsaCertificate |
| 2754 | for i := 0; i < 50; i++ { |
| 2755 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2756 | } |
| 2757 | testCases = append(testCases, testCase{ |
| 2758 | name: "LargeMessage", |
| 2759 | config: Config{ |
| 2760 | Certificates: []Certificate{cert}, |
| 2761 | }, |
| 2762 | }) |
| 2763 | testCases = append(testCases, testCase{ |
| 2764 | protocol: dtls, |
| 2765 | name: "LargeMessage-DTLS", |
| 2766 | config: Config{ |
| 2767 | Certificates: []Certificate{cert}, |
| 2768 | }, |
| 2769 | }) |
| 2770 | |
| 2771 | // They are rejected if the maximum certificate chain length is capped. |
| 2772 | testCases = append(testCases, testCase{ |
| 2773 | name: "LargeMessage-Reject", |
| 2774 | config: Config{ |
| 2775 | Certificates: []Certificate{cert}, |
| 2776 | }, |
| 2777 | flags: []string{"-max-cert-list", "16384"}, |
| 2778 | shouldFail: true, |
| 2779 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2780 | }) |
| 2781 | testCases = append(testCases, testCase{ |
| 2782 | protocol: dtls, |
| 2783 | name: "LargeMessage-Reject-DTLS", |
| 2784 | config: Config{ |
| 2785 | Certificates: []Certificate{cert}, |
| 2786 | }, |
| 2787 | flags: []string{"-max-cert-list", "16384"}, |
| 2788 | shouldFail: true, |
| 2789 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2790 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2791 | } |
| 2792 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2793 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2794 | const psk = "12345" |
| 2795 | const pskIdentity = "luggage combo" |
| 2796 | |
| 2797 | var prefix string |
| 2798 | if protocol == dtls { |
| 2799 | if !ver.hasDTLS { |
| 2800 | return |
| 2801 | } |
| 2802 | prefix = "D" |
| 2803 | } |
| 2804 | |
| 2805 | var cert Certificate |
| 2806 | var certFile string |
| 2807 | var keyFile string |
| 2808 | if hasComponent(suite.name, "ECDSA") { |
| 2809 | cert = ecdsaP256Certificate |
| 2810 | certFile = ecdsaP256CertificateFile |
| 2811 | keyFile = ecdsaP256KeyFile |
| 2812 | } else { |
| 2813 | cert = rsaCertificate |
| 2814 | certFile = rsaCertificateFile |
| 2815 | keyFile = rsaKeyFile |
| 2816 | } |
| 2817 | |
| 2818 | var flags []string |
| 2819 | if hasComponent(suite.name, "PSK") { |
| 2820 | flags = append(flags, |
| 2821 | "-psk", psk, |
| 2822 | "-psk-identity", pskIdentity) |
| 2823 | } |
| 2824 | if hasComponent(suite.name, "NULL") { |
| 2825 | // NULL ciphers must be explicitly enabled. |
| 2826 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2827 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2828 | |
| 2829 | var shouldServerFail, shouldClientFail bool |
| 2830 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2831 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2832 | // a BoringSSL server will never select it |
| 2833 | // because the extension is missing. |
| 2834 | shouldServerFail = true |
| 2835 | } |
| 2836 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2837 | shouldClientFail = true |
| 2838 | shouldServerFail = true |
| 2839 | } |
| 2840 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2841 | shouldClientFail = true |
| 2842 | shouldServerFail = true |
| 2843 | } |
| 2844 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2845 | shouldClientFail = true |
| 2846 | shouldServerFail = true |
| 2847 | } |
| 2848 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2849 | shouldClientFail = true |
| 2850 | shouldServerFail = true |
| 2851 | } |
| 2852 | |
| 2853 | var sendCipherSuite uint16 |
| 2854 | var expectedServerError, expectedClientError string |
| 2855 | serverCipherSuites := []uint16{suite.id} |
| 2856 | if shouldServerFail { |
| 2857 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2858 | } |
| 2859 | if shouldClientFail { |
| 2860 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2861 | // Configure the server to select ciphers as normal but |
| 2862 | // select an incompatible cipher in ServerHello. |
| 2863 | serverCipherSuites = nil |
| 2864 | sendCipherSuite = suite.id |
| 2865 | } |
| 2866 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2867 | // For cipher suites and versions where exporters are defined, verify |
| 2868 | // that they interoperate. |
| 2869 | var exportKeyingMaterial int |
| 2870 | if ver.version > VersionSSL30 { |
| 2871 | exportKeyingMaterial = 1024 |
| 2872 | } |
| 2873 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2874 | testCases = append(testCases, testCase{ |
| 2875 | testType: serverTest, |
| 2876 | protocol: protocol, |
| 2877 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2878 | config: Config{ |
| 2879 | MinVersion: ver.version, |
| 2880 | MaxVersion: ver.version, |
| 2881 | CipherSuites: []uint16{suite.id}, |
| 2882 | Certificates: []Certificate{cert}, |
| 2883 | PreSharedKey: []byte(psk), |
| 2884 | PreSharedKeyIdentity: pskIdentity, |
| 2885 | Bugs: ProtocolBugs{ |
| 2886 | AdvertiseAllConfiguredCiphers: true, |
| 2887 | }, |
| 2888 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2889 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2890 | certFile: certFile, |
| 2891 | keyFile: keyFile, |
| 2892 | flags: flags, |
| 2893 | resumeSession: true, |
| 2894 | shouldFail: shouldServerFail, |
| 2895 | expectedError: expectedServerError, |
| 2896 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2897 | }) |
| 2898 | |
| 2899 | testCases = append(testCases, testCase{ |
| 2900 | testType: clientTest, |
| 2901 | protocol: protocol, |
| 2902 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2903 | config: Config{ |
| 2904 | MinVersion: ver.version, |
| 2905 | MaxVersion: ver.version, |
| 2906 | CipherSuites: serverCipherSuites, |
| 2907 | Certificates: []Certificate{cert}, |
| 2908 | PreSharedKey: []byte(psk), |
| 2909 | PreSharedKeyIdentity: pskIdentity, |
| 2910 | Bugs: ProtocolBugs{ |
| 2911 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2912 | SendCipherSuite: sendCipherSuite, |
| 2913 | }, |
| 2914 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2915 | tls13Variant: ver.tls13Variant, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2916 | flags: flags, |
| 2917 | resumeSession: true, |
| 2918 | shouldFail: shouldClientFail, |
| 2919 | expectedError: expectedClientError, |
| 2920 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2921 | }) |
| 2922 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2923 | if shouldClientFail { |
| 2924 | return |
| 2925 | } |
| 2926 | |
| 2927 | // Ensure the maximum record size is accepted. |
| 2928 | testCases = append(testCases, testCase{ |
| 2929 | protocol: protocol, |
| 2930 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2931 | config: Config{ |
| 2932 | MinVersion: ver.version, |
| 2933 | MaxVersion: ver.version, |
| 2934 | CipherSuites: []uint16{suite.id}, |
| 2935 | Certificates: []Certificate{cert}, |
| 2936 | PreSharedKey: []byte(psk), |
| 2937 | PreSharedKeyIdentity: pskIdentity, |
| 2938 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2939 | tls13Variant: ver.tls13Variant, |
| 2940 | flags: flags, |
| 2941 | messageLen: maxPlaintext, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2942 | }) |
| 2943 | |
| 2944 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2945 | // and ignored in DTLS. |
| 2946 | var shouldFail bool |
| 2947 | var expectedError string |
| 2948 | if protocol == tls { |
| 2949 | shouldFail = true |
| 2950 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2951 | } |
| 2952 | |
| 2953 | testCases = append(testCases, testCase{ |
| 2954 | protocol: protocol, |
| 2955 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2956 | config: Config{ |
| 2957 | MinVersion: ver.version, |
| 2958 | MaxVersion: ver.version, |
| 2959 | CipherSuites: []uint16{suite.id}, |
| 2960 | Certificates: []Certificate{cert}, |
| 2961 | PreSharedKey: []byte(psk), |
| 2962 | PreSharedKeyIdentity: pskIdentity, |
| 2963 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 2964 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2965 | flags: flags, |
| 2966 | damageFirstWrite: true, |
| 2967 | messageLen: maxPlaintext, |
| 2968 | shouldFail: shouldFail, |
| 2969 | expectedError: expectedError, |
| 2970 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2971 | } |
| 2972 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2973 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2974 | const bogusCipher = 0xfe00 |
| 2975 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2976 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2977 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2978 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2979 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2980 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2981 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2982 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2983 | |
| 2984 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2985 | name: "NoSharedCipher", |
| 2986 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2987 | MaxVersion: VersionTLS12, |
| 2988 | CipherSuites: []uint16{}, |
| 2989 | }, |
| 2990 | shouldFail: true, |
| 2991 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2992 | }) |
| 2993 | |
| 2994 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2995 | name: "NoSharedCipher-TLS13", |
| 2996 | config: Config{ |
| 2997 | MaxVersion: VersionTLS13, |
| 2998 | CipherSuites: []uint16{}, |
| 2999 | }, |
| 3000 | shouldFail: true, |
| 3001 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 3002 | }) |
| 3003 | |
| 3004 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3005 | name: "UnsupportedCipherSuite", |
| 3006 | config: Config{ |
| 3007 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3008 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3009 | Bugs: ProtocolBugs{ |
| 3010 | IgnorePeerCipherPreferences: true, |
| 3011 | }, |
| 3012 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 3013 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3014 | shouldFail: true, |
| 3015 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 3016 | }) |
| 3017 | |
| 3018 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 3019 | name: "ServerHelloBogusCipher", |
| 3020 | config: Config{ |
| 3021 | MaxVersion: VersionTLS12, |
| 3022 | Bugs: ProtocolBugs{ |
| 3023 | SendCipherSuite: bogusCipher, |
| 3024 | }, |
| 3025 | }, |
| 3026 | shouldFail: true, |
| 3027 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3028 | }) |
| 3029 | testCases = append(testCases, testCase{ |
| 3030 | name: "ServerHelloBogusCipher-TLS13", |
| 3031 | config: Config{ |
| 3032 | MaxVersion: VersionTLS13, |
| 3033 | Bugs: ProtocolBugs{ |
| 3034 | SendCipherSuite: bogusCipher, |
| 3035 | }, |
| 3036 | }, |
| 3037 | shouldFail: true, |
| 3038 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 3039 | }) |
| 3040 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3041 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3042 | testCases = append(testCases, testCase{ |
| 3043 | testType: serverTest, |
| 3044 | name: "UnknownCipher", |
| 3045 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3046 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3047 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3048 | Bugs: ProtocolBugs{ |
| 3049 | AdvertiseAllConfiguredCiphers: true, |
| 3050 | }, |
| 3051 | }, |
| 3052 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3053 | |
| 3054 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3055 | testCases = append(testCases, testCase{ |
| 3056 | testType: serverTest, |
| 3057 | name: "UnknownCipher-TLS13", |
| 3058 | config: Config{ |
| 3059 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3060 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 3061 | Bugs: ProtocolBugs{ |
| 3062 | AdvertiseAllConfiguredCiphers: true, |
| 3063 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 3064 | }, |
| 3065 | }) |
| 3066 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 3067 | // Test empty ECDHE_PSK identity hints work as expected. |
| 3068 | testCases = append(testCases, testCase{ |
| 3069 | name: "EmptyECDHEPSKHint", |
| 3070 | config: Config{ |
| 3071 | MaxVersion: VersionTLS12, |
| 3072 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3073 | PreSharedKey: []byte("secret"), |
| 3074 | }, |
| 3075 | flags: []string{"-psk", "secret"}, |
| 3076 | }) |
| 3077 | |
| 3078 | // Test empty PSK identity hints work as expected, even if an explicit |
| 3079 | // ServerKeyExchange is sent. |
| 3080 | testCases = append(testCases, testCase{ |
| 3081 | name: "ExplicitEmptyPSKHint", |
| 3082 | config: Config{ |
| 3083 | MaxVersion: VersionTLS12, |
| 3084 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3085 | PreSharedKey: []byte("secret"), |
| 3086 | Bugs: ProtocolBugs{ |
| 3087 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 3088 | }, |
| 3089 | }, |
| 3090 | flags: []string{"-psk", "secret"}, |
| 3091 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 3092 | |
| 3093 | // Test that clients enforce that the server-sent certificate and cipher |
| 3094 | // suite match in TLS 1.2. |
| 3095 | testCases = append(testCases, testCase{ |
| 3096 | name: "CertificateCipherMismatch-RSA", |
| 3097 | config: Config{ |
| 3098 | MaxVersion: VersionTLS12, |
| 3099 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3100 | Certificates: []Certificate{rsaCertificate}, |
| 3101 | Bugs: ProtocolBugs{ |
| 3102 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 3103 | }, |
| 3104 | }, |
| 3105 | shouldFail: true, |
| 3106 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3107 | }) |
| 3108 | testCases = append(testCases, testCase{ |
| 3109 | name: "CertificateCipherMismatch-ECDSA", |
| 3110 | config: Config{ |
| 3111 | MaxVersion: VersionTLS12, |
| 3112 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3113 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3114 | Bugs: ProtocolBugs{ |
| 3115 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3116 | }, |
| 3117 | }, |
| 3118 | shouldFail: true, |
| 3119 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3120 | }) |
| 3121 | testCases = append(testCases, testCase{ |
| 3122 | name: "CertificateCipherMismatch-Ed25519", |
| 3123 | config: Config{ |
| 3124 | MaxVersion: VersionTLS12, |
| 3125 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3126 | Certificates: []Certificate{ed25519Certificate}, |
| 3127 | Bugs: ProtocolBugs{ |
| 3128 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3129 | }, |
| 3130 | }, |
| 3131 | shouldFail: true, |
| 3132 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 3133 | }) |
| 3134 | |
| 3135 | // Test that servers decline to select a cipher suite which is |
| 3136 | // inconsistent with their configured certificate. |
| 3137 | testCases = append(testCases, testCase{ |
| 3138 | testType: serverTest, |
| 3139 | name: "ServerCipherFilter-RSA", |
| 3140 | config: Config{ |
| 3141 | MaxVersion: VersionTLS12, |
| 3142 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 3143 | }, |
| 3144 | flags: []string{ |
| 3145 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3146 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3147 | }, |
| 3148 | shouldFail: true, |
| 3149 | expectedError: ":NO_SHARED_CIPHER:", |
| 3150 | }) |
| 3151 | testCases = append(testCases, testCase{ |
| 3152 | testType: serverTest, |
| 3153 | name: "ServerCipherFilter-ECDSA", |
| 3154 | config: Config{ |
| 3155 | MaxVersion: VersionTLS12, |
| 3156 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3157 | }, |
| 3158 | flags: []string{ |
| 3159 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3160 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3161 | }, |
| 3162 | shouldFail: true, |
| 3163 | expectedError: ":NO_SHARED_CIPHER:", |
| 3164 | }) |
| 3165 | testCases = append(testCases, testCase{ |
| 3166 | testType: serverTest, |
| 3167 | name: "ServerCipherFilter-Ed25519", |
| 3168 | config: Config{ |
| 3169 | MaxVersion: VersionTLS12, |
| 3170 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 3171 | }, |
| 3172 | flags: []string{ |
| 3173 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 3174 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 3175 | }, |
| 3176 | shouldFail: true, |
| 3177 | expectedError: ":NO_SHARED_CIPHER:", |
| 3178 | }) |
David Benjamin | 364af78 | 2017-07-01 10:35:27 -0400 | [diff] [blame] | 3179 | |
| 3180 | // Test cipher suite negotiation works as expected. Configure a |
| 3181 | // complicated cipher suite configuration. |
| 3182 | const negotiationTestCiphers = "" + |
| 3183 | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3184 | "[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]:" + |
| 3185 | "TLS_RSA_WITH_AES_128_GCM_SHA256:" + |
| 3186 | "TLS_RSA_WITH_AES_128_CBC_SHA:" + |
| 3187 | "[TLS_RSA_WITH_AES_256_GCM_SHA384|TLS_RSA_WITH_AES_256_CBC_SHA]" |
| 3188 | negotiationTests := []struct { |
| 3189 | ciphers []uint16 |
| 3190 | expected uint16 |
| 3191 | }{ |
| 3192 | // Server preferences are honored, including when |
| 3193 | // equipreference groups are involved. |
| 3194 | { |
| 3195 | []uint16{ |
| 3196 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3197 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3198 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3199 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3200 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3201 | }, |
| 3202 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 3203 | }, |
| 3204 | { |
| 3205 | []uint16{ |
| 3206 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3207 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3208 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3209 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3210 | }, |
| 3211 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3212 | }, |
| 3213 | { |
| 3214 | []uint16{ |
| 3215 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3216 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3217 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3218 | }, |
| 3219 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 3220 | }, |
| 3221 | { |
| 3222 | []uint16{ |
| 3223 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3224 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3225 | }, |
| 3226 | TLS_RSA_WITH_AES_128_CBC_SHA, |
| 3227 | }, |
| 3228 | // Equipreference groups use the client preference. |
| 3229 | { |
| 3230 | []uint16{ |
| 3231 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3232 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3233 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3234 | }, |
| 3235 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 3236 | }, |
| 3237 | { |
| 3238 | []uint16{ |
| 3239 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3240 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3241 | }, |
| 3242 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3243 | }, |
| 3244 | { |
| 3245 | []uint16{ |
| 3246 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3247 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3248 | }, |
| 3249 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3250 | }, |
| 3251 | { |
| 3252 | []uint16{ |
| 3253 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3254 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3255 | }, |
| 3256 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3257 | }, |
| 3258 | { |
| 3259 | []uint16{ |
| 3260 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3261 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3262 | }, |
| 3263 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3264 | }, |
| 3265 | // If there are two equipreference groups, the preferred one |
| 3266 | // takes precedence. |
| 3267 | { |
| 3268 | []uint16{ |
| 3269 | TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 3270 | TLS_RSA_WITH_AES_256_CBC_SHA, |
| 3271 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3272 | TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, |
| 3273 | }, |
| 3274 | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 3275 | }, |
| 3276 | } |
| 3277 | for i, t := range negotiationTests { |
| 3278 | testCases = append(testCases, testCase{ |
| 3279 | testType: serverTest, |
| 3280 | name: "CipherNegotiation-" + strconv.Itoa(i), |
| 3281 | config: Config{ |
| 3282 | MaxVersion: VersionTLS12, |
| 3283 | CipherSuites: t.ciphers, |
| 3284 | }, |
| 3285 | flags: []string{"-cipher", negotiationTestCiphers}, |
| 3286 | expectedCipher: t.expected, |
| 3287 | }) |
| 3288 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3289 | } |
| 3290 | |
| 3291 | func addBadECDSASignatureTests() { |
| 3292 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 3293 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3294 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3295 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 3296 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3297 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3298 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3299 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3300 | Bugs: ProtocolBugs{ |
| 3301 | BadECDSAR: badR, |
| 3302 | BadECDSAS: badS, |
| 3303 | }, |
| 3304 | }, |
| 3305 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3306 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3307 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 3308 | testCases = append(testCases, testCase{ |
| 3309 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 3310 | config: Config{ |
| 3311 | MaxVersion: VersionTLS13, |
| 3312 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 3313 | Bugs: ProtocolBugs{ |
| 3314 | BadECDSAR: badR, |
| 3315 | BadECDSAS: badS, |
| 3316 | }, |
| 3317 | }, |
| 3318 | shouldFail: true, |
| 3319 | expectedError: ":BAD_SIGNATURE:", |
| 3320 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3321 | } |
| 3322 | } |
| 3323 | } |
| 3324 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3325 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3326 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3327 | name: "MaxCBCPadding", |
| 3328 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3329 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3330 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3331 | Bugs: ProtocolBugs{ |
| 3332 | MaxPadding: true, |
| 3333 | }, |
| 3334 | }, |
| 3335 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3336 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3337 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3338 | name: "BadCBCPadding", |
| 3339 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3340 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3341 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3342 | Bugs: ProtocolBugs{ |
| 3343 | PaddingFirstByteBad: true, |
| 3344 | }, |
| 3345 | }, |
| 3346 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3347 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3348 | }) |
| 3349 | // OpenSSL previously had an issue where the first byte of padding in |
| 3350 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3351 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3352 | name: "BadCBCPadding255", |
| 3353 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3354 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3355 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3356 | Bugs: ProtocolBugs{ |
| 3357 | MaxPadding: true, |
| 3358 | PaddingFirstByteBadIf255: true, |
| 3359 | }, |
| 3360 | }, |
| 3361 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3362 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3363 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3364 | }) |
| 3365 | } |
| 3366 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3367 | func addCBCSplittingTests() { |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3368 | var cbcCiphers = []struct { |
| 3369 | name string |
| 3370 | cipher uint16 |
| 3371 | }{ |
| 3372 | {"3DES", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
| 3373 | {"AES128", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3374 | {"AES256", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
| 3375 | } |
| 3376 | for _, t := range cbcCiphers { |
| 3377 | testCases = append(testCases, testCase{ |
| 3378 | name: "CBCRecordSplitting-" + t.name, |
| 3379 | config: Config{ |
| 3380 | MaxVersion: VersionTLS10, |
| 3381 | MinVersion: VersionTLS10, |
| 3382 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3383 | Bugs: ProtocolBugs{ |
| 3384 | ExpectRecordSplitting: true, |
| 3385 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3386 | }, |
| 3387 | messageLen: -1, // read until EOF |
| 3388 | resumeSession: true, |
| 3389 | flags: []string{ |
| 3390 | "-async", |
| 3391 | "-write-different-record-sizes", |
| 3392 | "-cbc-record-splitting", |
| 3393 | }, |
| 3394 | }) |
| 3395 | testCases = append(testCases, testCase{ |
| 3396 | name: "CBCRecordSplittingPartialWrite-" + t.name, |
| 3397 | config: Config{ |
| 3398 | MaxVersion: VersionTLS10, |
| 3399 | MinVersion: VersionTLS10, |
| 3400 | CipherSuites: []uint16{t.cipher}, |
David Benjamin | 09ed119 | 2017-07-14 20:11:07 -0400 | [diff] [blame] | 3401 | Bugs: ProtocolBugs{ |
| 3402 | ExpectRecordSplitting: true, |
| 3403 | }, |
David Benjamin | a1ce856 | 2017-07-01 11:46:57 -0400 | [diff] [blame] | 3404 | }, |
| 3405 | messageLen: -1, // read until EOF |
| 3406 | flags: []string{ |
| 3407 | "-async", |
| 3408 | "-write-different-record-sizes", |
| 3409 | "-cbc-record-splitting", |
| 3410 | "-partial-write", |
| 3411 | }, |
| 3412 | }) |
| 3413 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3414 | } |
| 3415 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3416 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3417 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3418 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3419 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3420 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3421 | if err != nil { |
| 3422 | panic(err) |
| 3423 | } |
| 3424 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3425 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3426 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3427 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3428 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3429 | testCases = append(testCases, testCase{ |
| 3430 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3431 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3432 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3433 | MinVersion: ver.version, |
| 3434 | MaxVersion: ver.version, |
| 3435 | ClientAuth: RequireAnyClientCert, |
| 3436 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3437 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3438 | tls13Variant: ver.tls13Variant, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3439 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3440 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3441 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3442 | }, |
| 3443 | }) |
| 3444 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3445 | testType: serverTest, |
| 3446 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3447 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3448 | MinVersion: ver.version, |
| 3449 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3450 | Certificates: []Certificate{rsaCertificate}, |
| 3451 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3452 | tls13Variant: ver.tls13Variant, |
| 3453 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3454 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3455 | if ver.version != VersionSSL30 { |
| 3456 | testCases = append(testCases, testCase{ |
| 3457 | testType: serverTest, |
| 3458 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3459 | config: Config{ |
| 3460 | MinVersion: ver.version, |
| 3461 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3462 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3463 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3464 | tls13Variant: ver.tls13Variant, |
| 3465 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3466 | }) |
| 3467 | testCases = append(testCases, testCase{ |
| 3468 | testType: clientTest, |
| 3469 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3470 | config: Config{ |
| 3471 | MinVersion: ver.version, |
| 3472 | MaxVersion: ver.version, |
| 3473 | ClientAuth: RequireAnyClientCert, |
| 3474 | ClientCAs: certPool, |
| 3475 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3476 | tls13Variant: ver.tls13Variant, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3477 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3478 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3479 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3480 | }, |
| 3481 | }) |
| 3482 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3483 | |
| 3484 | testCases = append(testCases, testCase{ |
| 3485 | name: "NoClientCertificate-" + ver.name, |
| 3486 | config: Config{ |
| 3487 | MinVersion: ver.version, |
| 3488 | MaxVersion: ver.version, |
| 3489 | ClientAuth: RequireAnyClientCert, |
| 3490 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3491 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3492 | shouldFail: true, |
| 3493 | expectedLocalError: "client didn't provide a certificate", |
| 3494 | }) |
| 3495 | |
| 3496 | testCases = append(testCases, testCase{ |
| 3497 | // Even if not configured to expect a certificate, OpenSSL will |
| 3498 | // return X509_V_OK as the verify_result. |
| 3499 | testType: serverTest, |
| 3500 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3501 | config: Config{ |
| 3502 | MinVersion: ver.version, |
| 3503 | MaxVersion: ver.version, |
| 3504 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3505 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3506 | flags: []string{ |
| 3507 | "-expect-verify-result", |
| 3508 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3509 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3510 | }) |
| 3511 | |
| 3512 | testCases = append(testCases, testCase{ |
| 3513 | // If a client certificate is not provided, OpenSSL will still |
| 3514 | // return X509_V_OK as the verify_result. |
| 3515 | testType: serverTest, |
| 3516 | name: "NoClientCertificate-Server-" + ver.name, |
| 3517 | config: Config{ |
| 3518 | MinVersion: ver.version, |
| 3519 | MaxVersion: ver.version, |
| 3520 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3521 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3522 | flags: []string{ |
| 3523 | "-expect-verify-result", |
| 3524 | "-verify-peer", |
| 3525 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3526 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3527 | }) |
| 3528 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3529 | certificateRequired := "remote error: certificate required" |
| 3530 | if ver.version < VersionTLS13 { |
| 3531 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3532 | // was used. |
| 3533 | certificateRequired = "remote error: handshake failure" |
| 3534 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3535 | testCases = append(testCases, testCase{ |
| 3536 | testType: serverTest, |
| 3537 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3538 | config: Config{ |
| 3539 | MinVersion: ver.version, |
| 3540 | MaxVersion: ver.version, |
| 3541 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3542 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3543 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3544 | shouldFail: true, |
| 3545 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3546 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3547 | }) |
| 3548 | |
| 3549 | if ver.version != VersionSSL30 { |
| 3550 | testCases = append(testCases, testCase{ |
| 3551 | testType: serverTest, |
| 3552 | name: "SkipClientCertificate-" + ver.name, |
| 3553 | config: Config{ |
| 3554 | MinVersion: ver.version, |
| 3555 | MaxVersion: ver.version, |
| 3556 | Bugs: ProtocolBugs{ |
| 3557 | SkipClientCertificate: true, |
| 3558 | }, |
| 3559 | }, |
| 3560 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3561 | flags: []string{"-verify-peer"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3562 | tls13Variant: ver.tls13Variant, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3563 | shouldFail: true, |
| 3564 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3565 | }) |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3566 | |
| 3567 | testCases = append(testCases, testCase{ |
| 3568 | testType: serverTest, |
| 3569 | name: "VerifyPeerIfNoOBC-NoChannelID-" + ver.name, |
| 3570 | config: Config{ |
| 3571 | MinVersion: ver.version, |
| 3572 | MaxVersion: ver.version, |
| 3573 | }, |
| 3574 | flags: []string{ |
| 3575 | "-enable-channel-id", |
| 3576 | "-verify-peer-if-no-obc", |
| 3577 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3578 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3579 | shouldFail: true, |
| 3580 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3581 | expectedLocalError: certificateRequired, |
| 3582 | }) |
| 3583 | |
| 3584 | testCases = append(testCases, testCase{ |
| 3585 | testType: serverTest, |
| 3586 | name: "VerifyPeerIfNoOBC-ChannelID-" + ver.name, |
| 3587 | config: Config{ |
| 3588 | MinVersion: ver.version, |
| 3589 | MaxVersion: ver.version, |
| 3590 | ChannelID: channelIDKey, |
| 3591 | }, |
| 3592 | expectChannelID: true, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3593 | tls13Variant: ver.tls13Variant, |
David Benjamin | c3648fa | 2017-07-01 10:50:56 -0400 | [diff] [blame] | 3594 | flags: []string{ |
| 3595 | "-enable-channel-id", |
| 3596 | "-verify-peer-if-no-obc", |
| 3597 | }, |
| 3598 | }) |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3599 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3600 | |
| 3601 | testCases = append(testCases, testCase{ |
| 3602 | testType: serverTest, |
| 3603 | name: ver.name + "-Server-CertReq-CA-List", |
| 3604 | config: Config{ |
| 3605 | MinVersion: ver.version, |
| 3606 | MaxVersion: ver.version, |
| 3607 | Certificates: []Certificate{rsaCertificate}, |
| 3608 | Bugs: ProtocolBugs{ |
| 3609 | ExpectCertificateReqNames: caNames, |
| 3610 | }, |
| 3611 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3612 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3613 | flags: []string{ |
| 3614 | "-require-any-client-certificate", |
| 3615 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3616 | }, |
| 3617 | }) |
| 3618 | |
| 3619 | testCases = append(testCases, testCase{ |
| 3620 | testType: clientTest, |
| 3621 | name: ver.name + "-Client-CertReq-CA-List", |
| 3622 | config: Config{ |
| 3623 | MinVersion: ver.version, |
| 3624 | MaxVersion: ver.version, |
| 3625 | Certificates: []Certificate{rsaCertificate}, |
| 3626 | ClientAuth: RequireAnyClientCert, |
| 3627 | ClientCAs: certPool, |
| 3628 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3629 | tls13Variant: ver.tls13Variant, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3630 | flags: []string{ |
| 3631 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3632 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3633 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3634 | }, |
| 3635 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3636 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3637 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3638 | // Client auth is only legal in certificate-based ciphers. |
| 3639 | testCases = append(testCases, testCase{ |
| 3640 | testType: clientTest, |
| 3641 | name: "ClientAuth-PSK", |
| 3642 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3643 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3644 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3645 | PreSharedKey: []byte("secret"), |
| 3646 | ClientAuth: RequireAnyClientCert, |
| 3647 | }, |
| 3648 | flags: []string{ |
| 3649 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3650 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3651 | "-psk", "secret", |
| 3652 | }, |
| 3653 | shouldFail: true, |
| 3654 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3655 | }) |
| 3656 | testCases = append(testCases, testCase{ |
| 3657 | testType: clientTest, |
| 3658 | name: "ClientAuth-ECDHE_PSK", |
| 3659 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3660 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3661 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3662 | PreSharedKey: []byte("secret"), |
| 3663 | ClientAuth: RequireAnyClientCert, |
| 3664 | }, |
| 3665 | flags: []string{ |
| 3666 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3667 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3668 | "-psk", "secret", |
| 3669 | }, |
| 3670 | shouldFail: true, |
| 3671 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3672 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3673 | |
| 3674 | // Regression test for a bug where the client CA list, if explicitly |
| 3675 | // set to NULL, was mis-encoded. |
| 3676 | testCases = append(testCases, testCase{ |
| 3677 | testType: serverTest, |
| 3678 | name: "Null-Client-CA-List", |
| 3679 | config: Config{ |
| 3680 | MaxVersion: VersionTLS12, |
| 3681 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3682 | Bugs: ProtocolBugs{ |
| 3683 | ExpectCertificateReqNames: [][]byte{}, |
| 3684 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3685 | }, |
| 3686 | flags: []string{ |
| 3687 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3688 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3689 | }, |
| 3690 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3691 | } |
| 3692 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3693 | func addExtendedMasterSecretTests() { |
| 3694 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3695 | |
| 3696 | for _, with := range []bool{false, true} { |
| 3697 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3698 | if with { |
| 3699 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3700 | } |
| 3701 | |
| 3702 | for _, isClient := range []bool{false, true} { |
| 3703 | suffix := "-Server" |
| 3704 | testType := serverTest |
| 3705 | if isClient { |
| 3706 | suffix = "-Client" |
| 3707 | testType = clientTest |
| 3708 | } |
| 3709 | |
| 3710 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3711 | // In TLS 1.3, the extension is irrelevant and |
| 3712 | // always reports as enabled. |
| 3713 | var flags []string |
| 3714 | if with || ver.version >= VersionTLS13 { |
| 3715 | flags = []string{expectEMSFlag} |
| 3716 | } |
| 3717 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3718 | test := testCase{ |
| 3719 | testType: testType, |
| 3720 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3721 | config: Config{ |
| 3722 | MinVersion: ver.version, |
| 3723 | MaxVersion: ver.version, |
| 3724 | Bugs: ProtocolBugs{ |
| 3725 | NoExtendedMasterSecret: !with, |
| 3726 | RequireExtendedMasterSecret: with, |
| 3727 | }, |
| 3728 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 3729 | tls13Variant: ver.tls13Variant, |
| 3730 | flags: flags, |
| 3731 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3732 | } |
| 3733 | if test.shouldFail { |
| 3734 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3735 | } |
| 3736 | testCases = append(testCases, test) |
| 3737 | } |
| 3738 | } |
| 3739 | } |
| 3740 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3741 | for _, isClient := range []bool{false, true} { |
| 3742 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3743 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3744 | boolToWord := func(b bool) string { |
| 3745 | if b { |
| 3746 | return "Yes" |
| 3747 | } |
| 3748 | return "No" |
| 3749 | } |
| 3750 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3751 | if isClient { |
| 3752 | suffix += "Client" |
| 3753 | } else { |
| 3754 | suffix += "Server" |
| 3755 | } |
| 3756 | |
| 3757 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3758 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3759 | Bugs: ProtocolBugs{ |
| 3760 | RequireExtendedMasterSecret: true, |
| 3761 | }, |
| 3762 | } |
| 3763 | |
| 3764 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3765 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3766 | Bugs: ProtocolBugs{ |
| 3767 | NoExtendedMasterSecret: true, |
| 3768 | }, |
| 3769 | } |
| 3770 | |
| 3771 | test := testCase{ |
| 3772 | name: "ExtendedMasterSecret-" + suffix, |
| 3773 | resumeSession: true, |
| 3774 | } |
| 3775 | |
| 3776 | if !isClient { |
| 3777 | test.testType = serverTest |
| 3778 | } |
| 3779 | |
| 3780 | if supportedInFirstConnection { |
| 3781 | test.config = supportedConfig |
| 3782 | } else { |
| 3783 | test.config = noSupportConfig |
| 3784 | } |
| 3785 | |
| 3786 | if supportedInResumeConnection { |
| 3787 | test.resumeConfig = &supportedConfig |
| 3788 | } else { |
| 3789 | test.resumeConfig = &noSupportConfig |
| 3790 | } |
| 3791 | |
| 3792 | switch suffix { |
| 3793 | case "YesToYes-Client", "YesToYes-Server": |
| 3794 | // When a session is resumed, it should |
| 3795 | // still be aware that its master |
| 3796 | // secret was generated via EMS and |
| 3797 | // thus it's safe to use tls-unique. |
| 3798 | test.flags = []string{expectEMSFlag} |
| 3799 | case "NoToYes-Server": |
| 3800 | // If an original connection did not |
| 3801 | // contain EMS, but a resumption |
| 3802 | // handshake does, then a server should |
| 3803 | // not resume the session. |
| 3804 | test.expectResumeRejected = true |
| 3805 | case "YesToNo-Server": |
| 3806 | // Resuming an EMS session without the |
| 3807 | // EMS extension should cause the |
| 3808 | // server to abort the connection. |
| 3809 | test.shouldFail = true |
| 3810 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3811 | case "NoToYes-Client": |
| 3812 | // A client should abort a connection |
| 3813 | // where the server resumed a non-EMS |
| 3814 | // session but echoed the EMS |
| 3815 | // extension. |
| 3816 | test.shouldFail = true |
| 3817 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3818 | case "YesToNo-Client": |
| 3819 | // A client should abort a connection |
| 3820 | // where the server didn't echo EMS |
| 3821 | // when the session used it. |
| 3822 | test.shouldFail = true |
| 3823 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3824 | } |
| 3825 | |
| 3826 | testCases = append(testCases, test) |
| 3827 | } |
| 3828 | } |
| 3829 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3830 | |
| 3831 | // Switching EMS on renegotiation is forbidden. |
| 3832 | testCases = append(testCases, testCase{ |
| 3833 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3834 | config: Config{ |
| 3835 | MaxVersion: VersionTLS12, |
| 3836 | Bugs: ProtocolBugs{ |
| 3837 | NoExtendedMasterSecret: true, |
| 3838 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3839 | }, |
| 3840 | }, |
| 3841 | renegotiate: 1, |
| 3842 | flags: []string{ |
| 3843 | "-renegotiate-freely", |
| 3844 | "-expect-total-renegotiations", "1", |
| 3845 | }, |
| 3846 | }) |
| 3847 | |
| 3848 | testCases = append(testCases, testCase{ |
| 3849 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3850 | config: Config{ |
| 3851 | MaxVersion: VersionTLS12, |
| 3852 | Bugs: ProtocolBugs{ |
| 3853 | NoExtendedMasterSecret: true, |
| 3854 | }, |
| 3855 | }, |
| 3856 | renegotiate: 1, |
| 3857 | flags: []string{ |
| 3858 | "-renegotiate-freely", |
| 3859 | "-expect-total-renegotiations", "1", |
| 3860 | }, |
| 3861 | shouldFail: true, |
| 3862 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3863 | }) |
| 3864 | |
| 3865 | testCases = append(testCases, testCase{ |
| 3866 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3867 | config: Config{ |
| 3868 | MaxVersion: VersionTLS12, |
| 3869 | Bugs: ProtocolBugs{ |
| 3870 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3871 | }, |
| 3872 | }, |
| 3873 | renegotiate: 1, |
| 3874 | flags: []string{ |
| 3875 | "-renegotiate-freely", |
| 3876 | "-expect-total-renegotiations", "1", |
| 3877 | }, |
| 3878 | shouldFail: true, |
| 3879 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3880 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3881 | } |
| 3882 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3883 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3884 | protocol protocol |
| 3885 | async bool |
| 3886 | splitHandshake bool |
| 3887 | packHandshakeFlight bool |
| 3888 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3889 | } |
| 3890 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3891 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3892 | // various conditions. Some of these are redundant with other tests, but they |
| 3893 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3894 | func addAllStateMachineCoverageTests() { |
| 3895 | for _, async := range []bool{false, true} { |
| 3896 | for _, protocol := range []protocol{tls, dtls} { |
| 3897 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3898 | protocol: protocol, |
| 3899 | async: async, |
| 3900 | }) |
| 3901 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3902 | protocol: protocol, |
| 3903 | async: async, |
| 3904 | implicitHandshake: true, |
| 3905 | }) |
| 3906 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3907 | protocol: protocol, |
| 3908 | async: async, |
| 3909 | splitHandshake: true, |
| 3910 | }) |
| 3911 | if protocol == tls { |
| 3912 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3913 | protocol: protocol, |
| 3914 | async: async, |
| 3915 | packHandshakeFlight: true, |
| 3916 | }) |
| 3917 | } |
| 3918 | } |
| 3919 | } |
| 3920 | } |
| 3921 | |
| 3922 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3923 | var tests []testCase |
| 3924 | |
| 3925 | // Basic handshake, with resumption. Client and server, |
| 3926 | // session ID and session ticket. |
| 3927 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3928 | name: "Basic-Client", |
| 3929 | config: Config{ |
| 3930 | MaxVersion: VersionTLS12, |
| 3931 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3932 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3933 | // Ensure session tickets are used, not session IDs. |
| 3934 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3935 | }) |
| 3936 | tests = append(tests, testCase{ |
| 3937 | name: "Basic-Client-RenewTicket", |
| 3938 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3939 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3940 | Bugs: ProtocolBugs{ |
| 3941 | RenewTicketOnResume: true, |
| 3942 | }, |
| 3943 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3944 | flags: []string{"-expect-ticket-renewal"}, |
| 3945 | resumeSession: true, |
| 3946 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3947 | }) |
| 3948 | tests = append(tests, testCase{ |
| 3949 | name: "Basic-Client-NoTicket", |
| 3950 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3951 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3952 | SessionTicketsDisabled: true, |
| 3953 | }, |
| 3954 | resumeSession: true, |
| 3955 | }) |
| 3956 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3957 | testType: serverTest, |
| 3958 | name: "Basic-Server", |
| 3959 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3960 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3961 | Bugs: ProtocolBugs{ |
| 3962 | RequireSessionTickets: true, |
| 3963 | }, |
| 3964 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3965 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3966 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3967 | }) |
| 3968 | tests = append(tests, testCase{ |
| 3969 | testType: serverTest, |
| 3970 | name: "Basic-Server-NoTickets", |
| 3971 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3972 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3973 | SessionTicketsDisabled: true, |
| 3974 | }, |
| 3975 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3976 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3977 | }) |
| 3978 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3979 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3980 | name: "Basic-Server-EarlyCallback", |
| 3981 | config: Config{ |
| 3982 | MaxVersion: VersionTLS12, |
| 3983 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3984 | flags: []string{"-use-early-callback"}, |
| 3985 | resumeSession: true, |
| 3986 | }) |
| 3987 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3988 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3989 | if config.protocol == tls { |
| 3990 | tests = append(tests, testCase{ |
| 3991 | name: "TLS13-1RTT-Client", |
| 3992 | config: Config{ |
| 3993 | MaxVersion: VersionTLS13, |
| 3994 | MinVersion: VersionTLS13, |
| 3995 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3996 | resumeSession: true, |
| 3997 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3998 | }) |
| 3999 | |
| 4000 | tests = append(tests, testCase{ |
| 4001 | testType: serverTest, |
| 4002 | name: "TLS13-1RTT-Server", |
| 4003 | config: Config{ |
| 4004 | MaxVersion: VersionTLS13, |
| 4005 | MinVersion: VersionTLS13, |
| 4006 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 4007 | resumeSession: true, |
| 4008 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 4009 | // TLS 1.3 uses tickets, so the session should not be |
| 4010 | // cached statefully. |
| 4011 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4012 | }) |
| 4013 | |
| 4014 | tests = append(tests, testCase{ |
| 4015 | name: "TLS13-HelloRetryRequest-Client", |
| 4016 | config: Config{ |
| 4017 | MaxVersion: VersionTLS13, |
| 4018 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 4019 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 4020 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4021 | CurvePreferences: []CurveID{CurveP384}, |
| 4022 | Bugs: ProtocolBugs{ |
| 4023 | ExpectMissingKeyShare: true, |
| 4024 | }, |
| 4025 | }, |
| 4026 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4027 | resumeSession: true, |
| 4028 | }) |
| 4029 | |
| 4030 | tests = append(tests, testCase{ |
| 4031 | testType: serverTest, |
| 4032 | name: "TLS13-HelloRetryRequest-Server", |
| 4033 | config: Config{ |
| 4034 | MaxVersion: VersionTLS13, |
| 4035 | MinVersion: VersionTLS13, |
| 4036 | // Require a HelloRetryRequest for every curve. |
| 4037 | DefaultCurves: []CurveID{}, |
| 4038 | }, |
| 4039 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 4040 | resumeSession: true, |
| 4041 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4042 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4043 | tests = append(tests, testCase{ |
| 4044 | testType: clientTest, |
| 4045 | name: "TLS13-EarlyData-Client", |
| 4046 | config: Config{ |
| 4047 | MaxVersion: VersionTLS13, |
| 4048 | MinVersion: VersionTLS13, |
| 4049 | MaxEarlyDataSize: 16384, |
| 4050 | }, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4051 | resumeConfig: &Config{ |
| 4052 | MaxVersion: VersionTLS13, |
| 4053 | MinVersion: VersionTLS13, |
| 4054 | MaxEarlyDataSize: 16384, |
| 4055 | Bugs: ProtocolBugs{ |
| 4056 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4057 | }, |
| 4058 | }, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4059 | resumeSession: true, |
| 4060 | flags: []string{ |
| 4061 | "-enable-early-data", |
| 4062 | "-expect-early-data-info", |
| 4063 | "-expect-accept-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4064 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4065 | }, |
| 4066 | }) |
| 4067 | |
| 4068 | tests = append(tests, testCase{ |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4069 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4070 | name: "TLS13Experiment-EarlyData-Client", |
| 4071 | config: Config{ |
| 4072 | MaxVersion: VersionTLS13, |
| 4073 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4074 | MaxEarlyDataSize: 16384, |
| 4075 | }, |
| 4076 | resumeConfig: &Config{ |
| 4077 | MaxVersion: VersionTLS13, |
| 4078 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4079 | MaxEarlyDataSize: 16384, |
| 4080 | Bugs: ProtocolBugs{ |
| 4081 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4082 | }, |
| 4083 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4084 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 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", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4091 | }, |
| 4092 | }) |
| 4093 | |
| 4094 | tests = append(tests, testCase{ |
| 4095 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4096 | name: "TLS13RecordTypeExperiment-EarlyData-Client", |
| 4097 | config: Config{ |
| 4098 | MaxVersion: VersionTLS13, |
| 4099 | MinVersion: VersionTLS13, |
| 4100 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4101 | MaxEarlyDataSize: 16384, |
| 4102 | }, |
| 4103 | resumeConfig: &Config{ |
| 4104 | MaxVersion: VersionTLS13, |
| 4105 | MinVersion: VersionTLS13, |
| 4106 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4107 | MaxEarlyDataSize: 16384, |
| 4108 | Bugs: ProtocolBugs{ |
| 4109 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4110 | }, |
| 4111 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 4112 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4113 | resumeSession: true, |
| 4114 | flags: []string{ |
| 4115 | "-enable-early-data", |
| 4116 | "-expect-early-data-info", |
| 4117 | "-expect-accept-early-data", |
| 4118 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4119 | }, |
| 4120 | }) |
| 4121 | |
| 4122 | tests = append(tests, testCase{ |
| 4123 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 4124 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 4125 | config: Config{ |
| 4126 | MaxVersion: VersionTLS13, |
| 4127 | MinVersion: VersionTLS13, |
| 4128 | MaxEarlyDataSize: 2, |
| 4129 | }, |
| 4130 | resumeConfig: &Config{ |
| 4131 | MaxVersion: VersionTLS13, |
| 4132 | MinVersion: VersionTLS13, |
| 4133 | MaxEarlyDataSize: 2, |
| 4134 | Bugs: ProtocolBugs{ |
| 4135 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 4136 | }, |
| 4137 | }, |
| 4138 | resumeShimPrefix: "llo", |
| 4139 | resumeSession: true, |
| 4140 | flags: []string{ |
| 4141 | "-enable-early-data", |
| 4142 | "-expect-early-data-info", |
| 4143 | "-expect-accept-early-data", |
| 4144 | "-on-resume-shim-writes-first", |
| 4145 | }, |
| 4146 | }) |
| 4147 | |
| 4148 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 4149 | // can't be tested as part of an ImplicitHandshake in this case since |
| 4150 | // otherwise the early data will be sent as normal data. |
| 4151 | if config.async && !config.implicitHandshake { |
| 4152 | tests = append(tests, testCase{ |
| 4153 | testType: clientTest, |
| 4154 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 4155 | config: Config{ |
| 4156 | MaxVersion: VersionTLS13, |
| 4157 | MinVersion: VersionTLS13, |
| 4158 | MaxEarlyDataSize: 16384, |
| 4159 | }, |
| 4160 | resumeConfig: &Config{ |
| 4161 | MaxVersion: VersionTLS13, |
| 4162 | MinVersion: VersionTLS13, |
| 4163 | MaxEarlyDataSize: 16384, |
| 4164 | Bugs: ProtocolBugs{ |
| 4165 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 4166 | }, |
| 4167 | }, |
| 4168 | resumeSession: true, |
| 4169 | flags: []string{ |
| 4170 | "-enable-early-data", |
| 4171 | "-expect-early-data-info", |
| 4172 | "-expect-accept-early-data", |
| 4173 | "-on-resume-read-with-unfinished-write", |
| 4174 | "-on-resume-shim-writes-first", |
| 4175 | }, |
| 4176 | }) |
| 4177 | |
| 4178 | // Rejected unfinished writes are discarded (from the |
| 4179 | // perspective of the calling application) on 0-RTT |
| 4180 | // reject. |
| 4181 | tests = append(tests, testCase{ |
| 4182 | testType: clientTest, |
| 4183 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 4184 | config: Config{ |
| 4185 | MaxVersion: VersionTLS13, |
| 4186 | MinVersion: VersionTLS13, |
| 4187 | MaxEarlyDataSize: 16384, |
| 4188 | }, |
| 4189 | resumeConfig: &Config{ |
| 4190 | MaxVersion: VersionTLS13, |
| 4191 | MinVersion: VersionTLS13, |
| 4192 | MaxEarlyDataSize: 16384, |
| 4193 | Bugs: ProtocolBugs{ |
| 4194 | AlwaysRejectEarlyData: true, |
| 4195 | }, |
| 4196 | }, |
| 4197 | resumeSession: true, |
| 4198 | flags: []string{ |
| 4199 | "-enable-early-data", |
| 4200 | "-expect-early-data-info", |
| 4201 | "-expect-reject-early-data", |
| 4202 | "-on-resume-read-with-unfinished-write", |
| 4203 | "-on-resume-shim-writes-first", |
| 4204 | }, |
| 4205 | }) |
| 4206 | } |
| 4207 | |
| 4208 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4209 | testType: serverTest, |
| 4210 | name: "TLS13-EarlyData-Server", |
| 4211 | config: Config{ |
| 4212 | MaxVersion: VersionTLS13, |
| 4213 | MinVersion: VersionTLS13, |
| 4214 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4215 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4216 | ExpectEarlyDataAccepted: true, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4217 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4218 | }, |
| 4219 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4220 | messageCount: 2, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4221 | resumeSession: true, |
| 4222 | flags: []string{ |
| 4223 | "-enable-early-data", |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 4224 | "-expect-accept-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 4225 | }, |
| 4226 | }) |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4227 | |
| 4228 | tests = append(tests, testCase{ |
| 4229 | testType: serverTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4230 | name: "TLS13Experiment-EarlyData-Server", |
| 4231 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4232 | MaxVersion: VersionTLS13, |
| 4233 | MinVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4234 | Bugs: ProtocolBugs{ |
| 4235 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4236 | ExpectEarlyDataAccepted: true, |
| 4237 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4238 | }, |
| 4239 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4240 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4241 | messageCount: 2, |
| 4242 | resumeSession: true, |
| 4243 | flags: []string{ |
| 4244 | "-enable-early-data", |
| 4245 | "-expect-accept-early-data", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 4246 | }, |
| 4247 | }) |
| 4248 | |
| 4249 | tests = append(tests, testCase{ |
| 4250 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4251 | name: "TLS13RecordTypeExperiment-EarlyData-Server", |
| 4252 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4253 | MaxVersion: VersionTLS13, |
| 4254 | MinVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4255 | Bugs: ProtocolBugs{ |
| 4256 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4257 | ExpectEarlyDataAccepted: true, |
| 4258 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4259 | }, |
| 4260 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 4261 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4262 | messageCount: 2, |
| 4263 | resumeSession: true, |
| 4264 | flags: []string{ |
| 4265 | "-enable-early-data", |
| 4266 | "-expect-accept-early-data", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4267 | }, |
| 4268 | }) |
| 4269 | |
| 4270 | tests = append(tests, testCase{ |
| 4271 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4272 | name: "TLS13-MaxEarlyData-Server", |
| 4273 | config: Config{ |
| 4274 | MaxVersion: VersionTLS13, |
| 4275 | MinVersion: VersionTLS13, |
| 4276 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4277 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4278 | ExpectEarlyDataAccepted: true, |
| 4279 | }, |
| 4280 | }, |
| 4281 | messageCount: 2, |
| 4282 | resumeSession: true, |
| 4283 | flags: []string{ |
| 4284 | "-enable-early-data", |
| 4285 | "-expect-accept-early-data", |
| 4286 | }, |
| 4287 | shouldFail: true, |
| 4288 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4289 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4290 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4291 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4292 | // TLS client auth. |
| 4293 | tests = append(tests, testCase{ |
| 4294 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4295 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4296 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4297 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4298 | ClientAuth: RequestClientCert, |
| 4299 | }, |
| 4300 | }) |
| 4301 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4302 | testType: serverTest, |
| 4303 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4304 | config: Config{ |
| 4305 | MaxVersion: VersionTLS12, |
| 4306 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4307 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4308 | flags: []string{"-verify-peer"}, |
| 4309 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4310 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4311 | tests = append(tests, testCase{ |
| 4312 | testType: clientTest, |
| 4313 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4314 | config: Config{ |
| 4315 | MaxVersion: VersionSSL30, |
| 4316 | ClientAuth: RequestClientCert, |
| 4317 | }, |
| 4318 | }) |
| 4319 | tests = append(tests, testCase{ |
| 4320 | testType: serverTest, |
| 4321 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4322 | config: Config{ |
| 4323 | MaxVersion: VersionSSL30, |
| 4324 | }, |
| 4325 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4326 | flags: []string{"-verify-peer"}, |
| 4327 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4328 | tests = append(tests, testCase{ |
| 4329 | testType: clientTest, |
| 4330 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4331 | config: Config{ |
| 4332 | MaxVersion: VersionTLS13, |
| 4333 | ClientAuth: RequestClientCert, |
| 4334 | }, |
| 4335 | }) |
| 4336 | tests = append(tests, testCase{ |
| 4337 | testType: serverTest, |
| 4338 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4339 | config: Config{ |
| 4340 | MaxVersion: VersionTLS13, |
| 4341 | }, |
| 4342 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4343 | flags: []string{"-verify-peer"}, |
| 4344 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4345 | } |
| 4346 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4347 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4348 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4349 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4350 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4351 | ClientAuth: RequireAnyClientCert, |
| 4352 | }, |
| 4353 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4354 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4355 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4356 | }, |
| 4357 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4358 | tests = append(tests, testCase{ |
| 4359 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4360 | name: "ClientAuth-RSA-Client-TLS13", |
| 4361 | config: Config{ |
| 4362 | MaxVersion: VersionTLS13, |
| 4363 | ClientAuth: RequireAnyClientCert, |
| 4364 | }, |
| 4365 | flags: []string{ |
| 4366 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4367 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4368 | }, |
| 4369 | }) |
| 4370 | tests = append(tests, testCase{ |
| 4371 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4372 | name: "ClientAuth-ECDSA-Client", |
| 4373 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4374 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4375 | ClientAuth: RequireAnyClientCert, |
| 4376 | }, |
| 4377 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4378 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4379 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4380 | }, |
| 4381 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4382 | tests = append(tests, testCase{ |
| 4383 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4384 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4385 | config: Config{ |
| 4386 | MaxVersion: VersionTLS13, |
| 4387 | ClientAuth: RequireAnyClientCert, |
| 4388 | }, |
| 4389 | flags: []string{ |
| 4390 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4391 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4392 | }, |
| 4393 | }) |
| 4394 | tests = append(tests, testCase{ |
| 4395 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4396 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4397 | config: Config{ |
| 4398 | MaxVersion: VersionTLS12, |
| 4399 | ClientAuth: RequestClientCert, |
| 4400 | }, |
| 4401 | flags: []string{"-use-old-client-cert-callback"}, |
| 4402 | }) |
| 4403 | tests = append(tests, testCase{ |
| 4404 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4405 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4406 | config: Config{ |
| 4407 | MaxVersion: VersionTLS13, |
| 4408 | ClientAuth: RequestClientCert, |
| 4409 | }, |
| 4410 | flags: []string{"-use-old-client-cert-callback"}, |
| 4411 | }) |
| 4412 | tests = append(tests, testCase{ |
| 4413 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4414 | name: "ClientAuth-OldCallback", |
| 4415 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4416 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4417 | ClientAuth: RequireAnyClientCert, |
| 4418 | }, |
| 4419 | flags: []string{ |
| 4420 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4421 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4422 | "-use-old-client-cert-callback", |
| 4423 | }, |
| 4424 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4425 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4426 | testType: clientTest, |
| 4427 | name: "ClientAuth-OldCallback-TLS13", |
| 4428 | config: Config{ |
| 4429 | MaxVersion: VersionTLS13, |
| 4430 | ClientAuth: RequireAnyClientCert, |
| 4431 | }, |
| 4432 | flags: []string{ |
| 4433 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4434 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4435 | "-use-old-client-cert-callback", |
| 4436 | }, |
| 4437 | }) |
| 4438 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4439 | testType: serverTest, |
| 4440 | name: "ClientAuth-Server", |
| 4441 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4442 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4443 | Certificates: []Certificate{rsaCertificate}, |
| 4444 | }, |
| 4445 | flags: []string{"-require-any-client-certificate"}, |
| 4446 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4447 | tests = append(tests, testCase{ |
| 4448 | testType: serverTest, |
| 4449 | name: "ClientAuth-Server-TLS13", |
| 4450 | config: Config{ |
| 4451 | MaxVersion: VersionTLS13, |
| 4452 | Certificates: []Certificate{rsaCertificate}, |
| 4453 | }, |
| 4454 | flags: []string{"-require-any-client-certificate"}, |
| 4455 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4456 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4457 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4458 | tests = append(tests, testCase{ |
| 4459 | testType: serverTest, |
| 4460 | name: "Basic-Server-RSA", |
| 4461 | config: Config{ |
| 4462 | MaxVersion: VersionTLS12, |
| 4463 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4464 | }, |
| 4465 | flags: []string{ |
| 4466 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4467 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4468 | }, |
| 4469 | }) |
| 4470 | tests = append(tests, testCase{ |
| 4471 | testType: serverTest, |
| 4472 | name: "Basic-Server-ECDHE-RSA", |
| 4473 | config: Config{ |
| 4474 | MaxVersion: VersionTLS12, |
| 4475 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4476 | }, |
| 4477 | flags: []string{ |
| 4478 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4479 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4480 | }, |
| 4481 | }) |
| 4482 | tests = append(tests, testCase{ |
| 4483 | testType: serverTest, |
| 4484 | name: "Basic-Server-ECDHE-ECDSA", |
| 4485 | config: Config{ |
| 4486 | MaxVersion: VersionTLS12, |
| 4487 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4488 | }, |
| 4489 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4490 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4491 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4492 | }, |
| 4493 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4494 | tests = append(tests, testCase{ |
| 4495 | testType: serverTest, |
| 4496 | name: "Basic-Server-Ed25519", |
| 4497 | config: Config{ |
| 4498 | MaxVersion: VersionTLS12, |
| 4499 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4500 | }, |
| 4501 | flags: []string{ |
| 4502 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4503 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4504 | "-enable-ed25519", |
| 4505 | }, |
| 4506 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4507 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4508 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4509 | tests = append(tests, testCase{ |
| 4510 | name: "SessionTicketsDisabled-Client", |
| 4511 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4512 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4513 | SessionTicketsDisabled: true, |
| 4514 | }, |
| 4515 | }) |
| 4516 | tests = append(tests, testCase{ |
| 4517 | testType: serverTest, |
| 4518 | name: "SessionTicketsDisabled-Server", |
| 4519 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4520 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4521 | SessionTicketsDisabled: true, |
| 4522 | }, |
| 4523 | }) |
| 4524 | |
| 4525 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4526 | // identity hint. |
| 4527 | tests = append(tests, testCase{ |
| 4528 | name: "EmptyPSKHint-Client", |
| 4529 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4530 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4531 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4532 | PreSharedKey: []byte("secret"), |
| 4533 | }, |
| 4534 | flags: []string{"-psk", "secret"}, |
| 4535 | }) |
| 4536 | tests = append(tests, testCase{ |
| 4537 | testType: serverTest, |
| 4538 | name: "EmptyPSKHint-Server", |
| 4539 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4540 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4541 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4542 | PreSharedKey: []byte("secret"), |
| 4543 | }, |
| 4544 | flags: []string{"-psk", "secret"}, |
| 4545 | }) |
| 4546 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4547 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4548 | tests = append(tests, testCase{ |
| 4549 | testType: clientTest, |
| 4550 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4551 | config: Config{ |
| 4552 | MaxVersion: VersionTLS12, |
| 4553 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4554 | flags: []string{ |
| 4555 | "-enable-ocsp-stapling", |
| 4556 | "-expect-ocsp-response", |
| 4557 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4558 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4559 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4560 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4561 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4562 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4563 | testType: serverTest, |
| 4564 | name: "OCSPStapling-Server", |
| 4565 | config: Config{ |
| 4566 | MaxVersion: VersionTLS12, |
| 4567 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4568 | expectedOCSPResponse: testOCSPResponse, |
| 4569 | flags: []string{ |
| 4570 | "-ocsp-response", |
| 4571 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4572 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4573 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4574 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4575 | tests = append(tests, testCase{ |
| 4576 | testType: clientTest, |
| 4577 | name: "OCSPStapling-Client-TLS13", |
| 4578 | config: Config{ |
| 4579 | MaxVersion: VersionTLS13, |
| 4580 | }, |
| 4581 | flags: []string{ |
| 4582 | "-enable-ocsp-stapling", |
| 4583 | "-expect-ocsp-response", |
| 4584 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4585 | "-verify-peer", |
| 4586 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4587 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4588 | }) |
| 4589 | tests = append(tests, testCase{ |
| 4590 | testType: serverTest, |
| 4591 | name: "OCSPStapling-Server-TLS13", |
| 4592 | config: Config{ |
| 4593 | MaxVersion: VersionTLS13, |
| 4594 | }, |
| 4595 | expectedOCSPResponse: testOCSPResponse, |
| 4596 | flags: []string{ |
| 4597 | "-ocsp-response", |
| 4598 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4599 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4600 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4601 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4602 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4603 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4604 | for _, vers := range tlsVersions { |
| 4605 | if config.protocol == dtls && !vers.hasDTLS { |
| 4606 | continue |
| 4607 | } |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4608 | for _, useCustomCallback := range []bool{false, true} { |
| 4609 | for _, testType := range []testType{clientTest, serverTest} { |
| 4610 | suffix := "-Client" |
| 4611 | if testType == serverTest { |
| 4612 | suffix = "-Server" |
| 4613 | } |
| 4614 | suffix += "-" + vers.name |
| 4615 | if useCustomCallback { |
| 4616 | suffix += "-CustomCallback" |
| 4617 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4618 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4619 | flags := []string{"-verify-peer"} |
| 4620 | if testType == serverTest { |
| 4621 | flags = append(flags, "-require-any-client-certificate") |
| 4622 | } |
| 4623 | if useCustomCallback { |
| 4624 | flags = append(flags, "-use-custom-verify-callback") |
| 4625 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4626 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4627 | tests = append(tests, testCase{ |
| 4628 | testType: testType, |
| 4629 | name: "CertificateVerificationSucceed" + suffix, |
| 4630 | config: Config{ |
| 4631 | MaxVersion: vers.version, |
| 4632 | Certificates: []Certificate{rsaCertificate}, |
| 4633 | }, |
| 4634 | tls13Variant: vers.tls13Variant, |
| 4635 | flags: append([]string{"-expect-verify-result"}, flags...), |
| 4636 | resumeSession: true, |
| 4637 | }) |
| 4638 | tests = append(tests, testCase{ |
| 4639 | testType: testType, |
| 4640 | name: "CertificateVerificationFail" + suffix, |
| 4641 | config: Config{ |
| 4642 | MaxVersion: vers.version, |
| 4643 | Certificates: []Certificate{rsaCertificate}, |
| 4644 | }, |
| 4645 | tls13Variant: vers.tls13Variant, |
| 4646 | flags: append([]string{"-verify-fail"}, flags...), |
| 4647 | shouldFail: true, |
| 4648 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4649 | }) |
| 4650 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4651 | } |
| 4652 | |
| 4653 | // By default, the client is in a soft fail mode where the peer |
| 4654 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4655 | tests = append(tests, testCase{ |
| 4656 | testType: clientTest, |
| 4657 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4658 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4659 | MaxVersion: vers.version, |
| 4660 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4661 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4662 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4663 | flags: []string{ |
| 4664 | "-verify-fail", |
| 4665 | "-expect-verify-result", |
| 4666 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4667 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4668 | }) |
| 4669 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4670 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4671 | tests = append(tests, testCase{ |
| 4672 | name: "ShimSendAlert", |
| 4673 | flags: []string{"-send-alert"}, |
| 4674 | shimWritesFirst: true, |
| 4675 | shouldFail: true, |
| 4676 | expectedLocalError: "remote error: decompression failure", |
| 4677 | }) |
| 4678 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4679 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4680 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4681 | name: "Renegotiate-Client", |
| 4682 | config: Config{ |
| 4683 | MaxVersion: VersionTLS12, |
| 4684 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4685 | renegotiate: 1, |
| 4686 | flags: []string{ |
| 4687 | "-renegotiate-freely", |
| 4688 | "-expect-total-renegotiations", "1", |
| 4689 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4690 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4691 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4692 | tests = append(tests, testCase{ |
| 4693 | name: "SendHalfHelloRequest", |
| 4694 | config: Config{ |
| 4695 | MaxVersion: VersionTLS12, |
| 4696 | Bugs: ProtocolBugs{ |
| 4697 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4698 | }, |
| 4699 | }, |
| 4700 | sendHalfHelloRequest: true, |
| 4701 | flags: []string{"-renegotiate-ignore"}, |
| 4702 | shouldFail: true, |
| 4703 | expectedError: ":UNEXPECTED_RECORD:", |
| 4704 | }) |
| 4705 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4706 | // NPN on client and server; results in post-handshake message. |
| 4707 | tests = append(tests, testCase{ |
| 4708 | name: "NPN-Client", |
| 4709 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4710 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4711 | NextProtos: []string{"foo"}, |
| 4712 | }, |
| 4713 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4714 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4715 | expectedNextProto: "foo", |
| 4716 | expectedNextProtoType: npn, |
| 4717 | }) |
| 4718 | tests = append(tests, testCase{ |
| 4719 | testType: serverTest, |
| 4720 | name: "NPN-Server", |
| 4721 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4722 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4723 | NextProtos: []string{"bar"}, |
| 4724 | }, |
| 4725 | flags: []string{ |
| 4726 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4727 | "-expect-next-proto", "bar", |
| 4728 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4729 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4730 | expectedNextProto: "bar", |
| 4731 | expectedNextProtoType: npn, |
| 4732 | }) |
| 4733 | |
| 4734 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4735 | |
| 4736 | // Client does False Start and negotiates NPN. |
| 4737 | tests = append(tests, testCase{ |
| 4738 | name: "FalseStart", |
| 4739 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4740 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4741 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4742 | NextProtos: []string{"foo"}, |
| 4743 | Bugs: ProtocolBugs{ |
| 4744 | ExpectFalseStart: true, |
| 4745 | }, |
| 4746 | }, |
| 4747 | flags: []string{ |
| 4748 | "-false-start", |
| 4749 | "-select-next-proto", "foo", |
| 4750 | }, |
| 4751 | shimWritesFirst: true, |
| 4752 | resumeSession: true, |
| 4753 | }) |
| 4754 | |
| 4755 | // Client does False Start and negotiates ALPN. |
| 4756 | tests = append(tests, testCase{ |
| 4757 | name: "FalseStart-ALPN", |
| 4758 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4759 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4760 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4761 | NextProtos: []string{"foo"}, |
| 4762 | Bugs: ProtocolBugs{ |
| 4763 | ExpectFalseStart: true, |
| 4764 | }, |
| 4765 | }, |
| 4766 | flags: []string{ |
| 4767 | "-false-start", |
| 4768 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4769 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4770 | }, |
| 4771 | shimWritesFirst: true, |
| 4772 | resumeSession: true, |
| 4773 | }) |
| 4774 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4775 | // False Start without session tickets. |
| 4776 | tests = append(tests, testCase{ |
| 4777 | name: "FalseStart-SessionTicketsDisabled", |
| 4778 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4779 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4780 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4781 | NextProtos: []string{"foo"}, |
| 4782 | SessionTicketsDisabled: true, |
| 4783 | Bugs: ProtocolBugs{ |
| 4784 | ExpectFalseStart: true, |
| 4785 | }, |
| 4786 | }, |
| 4787 | flags: []string{ |
| 4788 | "-false-start", |
| 4789 | "-select-next-proto", "foo", |
| 4790 | }, |
| 4791 | shimWritesFirst: true, |
| 4792 | }) |
| 4793 | |
| 4794 | // Server parses a V2ClientHello. |
| 4795 | tests = append(tests, testCase{ |
| 4796 | testType: serverTest, |
| 4797 | name: "SendV2ClientHello", |
| 4798 | config: Config{ |
| 4799 | // Choose a cipher suite that does not involve |
| 4800 | // elliptic curves, so no extensions are |
| 4801 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4802 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4803 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4804 | Bugs: ProtocolBugs{ |
| 4805 | SendV2ClientHello: true, |
| 4806 | }, |
| 4807 | }, |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 4808 | flags: []string{ |
| 4809 | "-expect-msg-callback", |
| 4810 | `read v2clienthello |
| 4811 | write hs 2 |
| 4812 | write hs 11 |
| 4813 | write hs 14 |
| 4814 | read hs 16 |
| 4815 | read ccs |
| 4816 | read hs 20 |
| 4817 | write ccs |
| 4818 | write hs 20 |
| 4819 | read alert 1 0 |
| 4820 | `, |
| 4821 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4822 | }) |
| 4823 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4824 | // Test Channel ID |
| 4825 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4826 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4827 | continue |
| 4828 | } |
| 4829 | // Client sends a Channel ID. |
| 4830 | tests = append(tests, testCase{ |
| 4831 | name: "ChannelID-Client-" + ver.name, |
| 4832 | config: Config{ |
| 4833 | MaxVersion: ver.version, |
| 4834 | RequestChannelID: true, |
| 4835 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4836 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4837 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4838 | resumeSession: true, |
| 4839 | expectChannelID: true, |
| 4840 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4841 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4842 | // Server accepts a Channel ID. |
| 4843 | tests = append(tests, testCase{ |
| 4844 | testType: serverTest, |
| 4845 | name: "ChannelID-Server-" + ver.name, |
| 4846 | config: Config{ |
| 4847 | MaxVersion: ver.version, |
| 4848 | ChannelID: channelIDKey, |
| 4849 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4850 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4851 | flags: []string{ |
| 4852 | "-expect-channel-id", |
| 4853 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4854 | }, |
| 4855 | resumeSession: true, |
| 4856 | expectChannelID: true, |
| 4857 | }) |
| 4858 | |
| 4859 | tests = append(tests, testCase{ |
| 4860 | testType: serverTest, |
| 4861 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4862 | config: Config{ |
| 4863 | MaxVersion: ver.version, |
| 4864 | ChannelID: channelIDKey, |
| 4865 | Bugs: ProtocolBugs{ |
| 4866 | InvalidChannelIDSignature: true, |
| 4867 | }, |
| 4868 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4869 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4870 | flags: []string{"-enable-channel-id"}, |
| 4871 | shouldFail: true, |
| 4872 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4873 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4874 | |
| 4875 | if ver.version < VersionTLS13 { |
| 4876 | // Channel ID requires ECDHE ciphers. |
| 4877 | tests = append(tests, testCase{ |
| 4878 | testType: serverTest, |
| 4879 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4880 | config: Config{ |
| 4881 | MaxVersion: ver.version, |
| 4882 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4883 | ChannelID: channelIDKey, |
| 4884 | }, |
| 4885 | expectChannelID: false, |
| 4886 | flags: []string{"-enable-channel-id"}, |
| 4887 | }) |
| 4888 | |
| 4889 | // Sanity-check setting expectChannelID false works. |
| 4890 | tests = append(tests, testCase{ |
| 4891 | testType: serverTest, |
| 4892 | name: "ChannelID-ECDHE-" + ver.name, |
| 4893 | config: Config{ |
| 4894 | MaxVersion: ver.version, |
| 4895 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4896 | ChannelID: channelIDKey, |
| 4897 | }, |
| 4898 | expectChannelID: false, |
| 4899 | flags: []string{"-enable-channel-id"}, |
| 4900 | shouldFail: true, |
| 4901 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4902 | }) |
| 4903 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4904 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4905 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4906 | // Channel ID and NPN at the same time, to ensure their relative |
| 4907 | // ordering is correct. |
| 4908 | tests = append(tests, testCase{ |
| 4909 | name: "ChannelID-NPN-Client", |
| 4910 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4911 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4912 | RequestChannelID: true, |
| 4913 | NextProtos: []string{"foo"}, |
| 4914 | }, |
| 4915 | flags: []string{ |
| 4916 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4917 | "-select-next-proto", "foo", |
| 4918 | }, |
| 4919 | resumeSession: true, |
| 4920 | expectChannelID: true, |
| 4921 | expectedNextProto: "foo", |
| 4922 | expectedNextProtoType: npn, |
| 4923 | }) |
| 4924 | tests = append(tests, testCase{ |
| 4925 | testType: serverTest, |
| 4926 | name: "ChannelID-NPN-Server", |
| 4927 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4928 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4929 | ChannelID: channelIDKey, |
| 4930 | NextProtos: []string{"bar"}, |
| 4931 | }, |
| 4932 | flags: []string{ |
| 4933 | "-expect-channel-id", |
| 4934 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4935 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4936 | "-expect-next-proto", "bar", |
| 4937 | }, |
| 4938 | resumeSession: true, |
| 4939 | expectChannelID: true, |
| 4940 | expectedNextProto: "bar", |
| 4941 | expectedNextProtoType: npn, |
| 4942 | }) |
| 4943 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4944 | // Bidirectional shutdown with the runner initiating. |
| 4945 | tests = append(tests, testCase{ |
| 4946 | name: "Shutdown-Runner", |
| 4947 | config: Config{ |
| 4948 | Bugs: ProtocolBugs{ |
| 4949 | ExpectCloseNotify: true, |
| 4950 | }, |
| 4951 | }, |
| 4952 | flags: []string{"-check-close-notify"}, |
| 4953 | }) |
| 4954 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4955 | if !config.implicitHandshake { |
| 4956 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4957 | // in the meantime, sends garbage before the close_notify which |
| 4958 | // the shim must ignore. This test is disabled under implicit |
| 4959 | // handshake tests because the shim never reads or writes. |
| 4960 | tests = append(tests, testCase{ |
| 4961 | name: "Shutdown-Shim", |
| 4962 | config: Config{ |
| 4963 | MaxVersion: VersionTLS12, |
| 4964 | Bugs: ProtocolBugs{ |
| 4965 | ExpectCloseNotify: true, |
| 4966 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4967 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4968 | shimShutsDown: true, |
| 4969 | sendEmptyRecords: 1, |
| 4970 | sendWarningAlerts: 1, |
| 4971 | flags: []string{"-check-close-notify"}, |
| 4972 | }) |
| 4973 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4974 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4975 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4976 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4977 | tests = append(tests, testCase{ |
| 4978 | name: "SkipHelloVerifyRequest", |
| 4979 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4980 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4981 | Bugs: ProtocolBugs{ |
| 4982 | SkipHelloVerifyRequest: true, |
| 4983 | }, |
| 4984 | }, |
| 4985 | }) |
| 4986 | } |
| 4987 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4988 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4989 | test.protocol = config.protocol |
| 4990 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4991 | test.name += "-DTLS" |
| 4992 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4993 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4994 | test.name += "-Async" |
| 4995 | test.flags = append(test.flags, "-async") |
| 4996 | } else { |
| 4997 | test.name += "-Sync" |
| 4998 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4999 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5000 | test.name += "-SplitHandshakeRecords" |
| 5001 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5002 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5003 | test.config.Bugs.MaxPacketLength = 256 |
| 5004 | test.flags = append(test.flags, "-mtu", "256") |
| 5005 | } |
| 5006 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5007 | if config.packHandshakeFlight { |
| 5008 | test.name += "-PackHandshakeFlight" |
| 5009 | test.config.Bugs.PackHandshakeFlight = true |
| 5010 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 5011 | if config.implicitHandshake { |
| 5012 | test.name += "-ImplicitHandshake" |
| 5013 | test.flags = append(test.flags, "-implicit-handshake") |
| 5014 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 5015 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 5016 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 5017 | } |
| 5018 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5019 | func addDDoSCallbackTests() { |
| 5020 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5021 | for _, resume := range []bool{false, true} { |
| 5022 | suffix := "Resume" |
| 5023 | if resume { |
| 5024 | suffix = "No" + suffix |
| 5025 | } |
| 5026 | |
| 5027 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5028 | testType: serverTest, |
| 5029 | name: "Server-DDoS-OK-" + suffix, |
| 5030 | config: Config{ |
| 5031 | MaxVersion: VersionTLS12, |
| 5032 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5033 | flags: []string{"-install-ddos-callback"}, |
| 5034 | resumeSession: resume, |
| 5035 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5036 | testCases = append(testCases, testCase{ |
| 5037 | testType: serverTest, |
| 5038 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 5039 | config: Config{ |
| 5040 | MaxVersion: VersionTLS13, |
| 5041 | }, |
| 5042 | flags: []string{"-install-ddos-callback"}, |
| 5043 | resumeSession: resume, |
| 5044 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5045 | |
| 5046 | failFlag := "-fail-ddos-callback" |
| 5047 | if resume { |
| 5048 | failFlag = "-fail-second-ddos-callback" |
| 5049 | } |
| 5050 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5051 | testType: serverTest, |
| 5052 | name: "Server-DDoS-Reject-" + suffix, |
| 5053 | config: Config{ |
| 5054 | MaxVersion: VersionTLS12, |
| 5055 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5056 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5057 | resumeSession: resume, |
| 5058 | shouldFail: true, |
| 5059 | expectedError: ":CONNECTION_REJECTED:", |
| 5060 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5061 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5062 | testCases = append(testCases, testCase{ |
| 5063 | testType: serverTest, |
| 5064 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 5065 | config: Config{ |
| 5066 | MaxVersion: VersionTLS13, |
| 5067 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5068 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5069 | resumeSession: resume, |
| 5070 | shouldFail: true, |
| 5071 | expectedError: ":CONNECTION_REJECTED:", |
| 5072 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5073 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5074 | } |
| 5075 | } |
| 5076 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5077 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5078 | for _, protocol := range []protocol{tls, dtls} { |
| 5079 | for _, shimVers := range allVersions(protocol) { |
| 5080 | // Assemble flags to disable all newer versions on the shim. |
| 5081 | var flags []string |
| 5082 | for _, vers := range allVersions(protocol) { |
| 5083 | if vers.version > shimVers.version { |
| 5084 | flags = append(flags, vers.excludeFlag) |
| 5085 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5086 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5087 | |
| 5088 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 5089 | |
| 5090 | if shimVers.tls13Variant != 0 { |
| 5091 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5092 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5093 | } |
| 5094 | |
| 5095 | // Test configuring the runner's maximum version. |
| 5096 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5097 | expectedVersion := shimVers.version |
| 5098 | if runnerVers.version < shimVers.version { |
| 5099 | expectedVersion = runnerVers.version |
| 5100 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5101 | // When running and shim have different TLS 1.3 variants enabled, |
| 5102 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5103 | // servers support both variants when enabled when the experiment is |
| 5104 | // enabled. |
| 5105 | expectedServerVersion := expectedVersion |
| 5106 | expectedClientVersion := expectedVersion |
| 5107 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5108 | expectedClientVersion = VersionTLS12 |
| 5109 | expectedServerVersion = VersionTLS12 |
| 5110 | if shimVers.tls13Variant != TLS13Default { |
| 5111 | expectedServerVersion = VersionTLS13 |
| 5112 | } |
| 5113 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5114 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5115 | suffix := shimVers.name + "-" + runnerVers.name |
| 5116 | if protocol == dtls { |
| 5117 | suffix += "-DTLS" |
| 5118 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5119 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5120 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5121 | clientVers := shimVers.version |
| 5122 | if clientVers > VersionTLS10 { |
| 5123 | clientVers = VersionTLS10 |
| 5124 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5125 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5126 | serverVers := expectedServerVersion |
| 5127 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5128 | serverVers = VersionTLS10 |
| 5129 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5130 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5131 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5132 | testCases = append(testCases, testCase{ |
| 5133 | protocol: protocol, |
| 5134 | testType: clientTest, |
| 5135 | name: "VersionNegotiation-Client-" + suffix, |
| 5136 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5137 | MaxVersion: runnerVers.version, |
| 5138 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5139 | Bugs: ProtocolBugs{ |
| 5140 | ExpectInitialRecordVersion: clientVers, |
| 5141 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5142 | }, |
| 5143 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5144 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5145 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5146 | testCases = append(testCases, testCase{ |
| 5147 | protocol: protocol, |
| 5148 | testType: clientTest, |
| 5149 | name: "VersionNegotiation-Client2-" + suffix, |
| 5150 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5151 | MaxVersion: runnerVers.version, |
| 5152 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5153 | Bugs: ProtocolBugs{ |
| 5154 | ExpectInitialRecordVersion: clientVers, |
| 5155 | }, |
| 5156 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5157 | flags: flags2, |
| 5158 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5159 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5160 | |
| 5161 | testCases = append(testCases, testCase{ |
| 5162 | protocol: protocol, |
| 5163 | testType: serverTest, |
| 5164 | name: "VersionNegotiation-Server-" + suffix, |
| 5165 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5166 | MaxVersion: runnerVers.version, |
| 5167 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5168 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5169 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5170 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5171 | }, |
| 5172 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5173 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5174 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5175 | testCases = append(testCases, testCase{ |
| 5176 | protocol: protocol, |
| 5177 | testType: serverTest, |
| 5178 | name: "VersionNegotiation-Server2-" + suffix, |
| 5179 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5180 | MaxVersion: runnerVers.version, |
| 5181 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5182 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5183 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5184 | }, |
| 5185 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5186 | flags: flags2, |
| 5187 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5188 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5189 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5190 | } |
| 5191 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5192 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5193 | // Test the version extension at all versions. |
| 5194 | for _, vers := range tlsVersions { |
| 5195 | protocols := []protocol{tls} |
| 5196 | if vers.hasDTLS { |
| 5197 | protocols = append(protocols, dtls) |
| 5198 | } |
| 5199 | for _, protocol := range protocols { |
| 5200 | suffix := vers.name |
| 5201 | if protocol == dtls { |
| 5202 | suffix += "-DTLS" |
| 5203 | } |
| 5204 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5205 | testCases = append(testCases, testCase{ |
| 5206 | protocol: protocol, |
| 5207 | testType: serverTest, |
| 5208 | name: "VersionNegotiationExtension-" + suffix, |
| 5209 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5210 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5211 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5212 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5213 | }, |
| 5214 | }, |
| 5215 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5216 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5217 | }) |
| 5218 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5219 | } |
| 5220 | |
| 5221 | // If all versions are unknown, negotiation fails. |
| 5222 | testCases = append(testCases, testCase{ |
| 5223 | testType: serverTest, |
| 5224 | name: "NoSupportedVersions", |
| 5225 | config: Config{ |
| 5226 | Bugs: ProtocolBugs{ |
| 5227 | SendSupportedVersions: []uint16{0x1111}, |
| 5228 | }, |
| 5229 | }, |
| 5230 | shouldFail: true, |
| 5231 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5232 | }) |
| 5233 | testCases = append(testCases, testCase{ |
| 5234 | protocol: dtls, |
| 5235 | testType: serverTest, |
| 5236 | name: "NoSupportedVersions-DTLS", |
| 5237 | config: Config{ |
| 5238 | Bugs: ProtocolBugs{ |
| 5239 | SendSupportedVersions: []uint16{0x1111}, |
| 5240 | }, |
| 5241 | }, |
| 5242 | shouldFail: true, |
| 5243 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5244 | }) |
| 5245 | |
| 5246 | testCases = append(testCases, testCase{ |
| 5247 | testType: serverTest, |
| 5248 | name: "ClientHelloVersionTooHigh", |
| 5249 | config: Config{ |
| 5250 | MaxVersion: VersionTLS13, |
| 5251 | Bugs: ProtocolBugs{ |
| 5252 | SendClientVersion: 0x0304, |
| 5253 | OmitSupportedVersions: true, |
| 5254 | }, |
| 5255 | }, |
| 5256 | expectedVersion: VersionTLS12, |
| 5257 | }) |
| 5258 | |
| 5259 | testCases = append(testCases, testCase{ |
| 5260 | testType: serverTest, |
| 5261 | name: "ConflictingVersionNegotiation", |
| 5262 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5263 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5264 | SendClientVersion: VersionTLS12, |
| 5265 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5266 | }, |
| 5267 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5268 | // The extension takes precedence over the ClientHello version. |
| 5269 | expectedVersion: VersionTLS11, |
| 5270 | }) |
| 5271 | |
| 5272 | testCases = append(testCases, testCase{ |
| 5273 | testType: serverTest, |
| 5274 | name: "ConflictingVersionNegotiation-2", |
| 5275 | config: Config{ |
| 5276 | Bugs: ProtocolBugs{ |
| 5277 | SendClientVersion: VersionTLS11, |
| 5278 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5279 | }, |
| 5280 | }, |
| 5281 | // The extension takes precedence over the ClientHello version. |
| 5282 | expectedVersion: VersionTLS12, |
| 5283 | }) |
| 5284 | |
| 5285 | testCases = append(testCases, testCase{ |
| 5286 | testType: serverTest, |
| 5287 | name: "RejectFinalTLS13", |
| 5288 | config: Config{ |
| 5289 | Bugs: ProtocolBugs{ |
| 5290 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5291 | }, |
| 5292 | }, |
| 5293 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5294 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5295 | expectedVersion: VersionTLS12, |
| 5296 | }) |
| 5297 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5298 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5299 | // the ServerHello. |
| 5300 | testCases = append(testCases, testCase{ |
| 5301 | testType: clientTest, |
| 5302 | name: "SupportedVersionSelection-TLS12", |
| 5303 | config: Config{ |
| 5304 | MaxVersion: VersionTLS12, |
| 5305 | Bugs: ProtocolBugs{ |
| 5306 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5307 | }, |
| 5308 | }, |
| 5309 | shouldFail: true, |
| 5310 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5311 | }) |
| 5312 | |
| 5313 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5314 | // supported_versions extension in the ServerHello. |
| 5315 | testCases = append(testCases, testCase{ |
| 5316 | testType: clientTest, |
| 5317 | name: "SupportedVersionSelection-TLS13", |
| 5318 | config: Config{ |
| 5319 | MaxVersion: VersionTLS13, |
| 5320 | Bugs: ProtocolBugs{ |
| 5321 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5322 | }, |
| 5323 | }, |
| 5324 | shouldFail: true, |
| 5325 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5326 | }) |
| 5327 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5328 | // Test that the maximum version is selected regardless of the |
| 5329 | // client-sent order. |
| 5330 | testCases = append(testCases, testCase{ |
| 5331 | testType: serverTest, |
| 5332 | name: "IgnoreClientVersionOrder", |
| 5333 | config: Config{ |
| 5334 | Bugs: ProtocolBugs{ |
| 5335 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5336 | }, |
| 5337 | }, |
| 5338 | expectedVersion: VersionTLS13, |
| 5339 | }) |
| 5340 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5341 | // Test for version tolerance. |
| 5342 | testCases = append(testCases, testCase{ |
| 5343 | testType: serverTest, |
| 5344 | name: "MinorVersionTolerance", |
| 5345 | config: Config{ |
| 5346 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5347 | SendClientVersion: 0x03ff, |
| 5348 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5349 | }, |
| 5350 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5351 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5352 | }) |
| 5353 | testCases = append(testCases, testCase{ |
| 5354 | testType: serverTest, |
| 5355 | name: "MajorVersionTolerance", |
| 5356 | config: Config{ |
| 5357 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5358 | SendClientVersion: 0x0400, |
| 5359 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5360 | }, |
| 5361 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5362 | // TLS 1.3 must be negotiated with the supported_versions |
| 5363 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5364 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5365 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5366 | testCases = append(testCases, testCase{ |
| 5367 | testType: serverTest, |
| 5368 | name: "VersionTolerance-TLS13", |
| 5369 | config: Config{ |
| 5370 | Bugs: ProtocolBugs{ |
| 5371 | // Although TLS 1.3 does not use |
| 5372 | // ClientHello.version, it still tolerates high |
| 5373 | // values there. |
| 5374 | SendClientVersion: 0x0400, |
| 5375 | }, |
| 5376 | }, |
| 5377 | expectedVersion: VersionTLS13, |
| 5378 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5379 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5380 | testCases = append(testCases, testCase{ |
| 5381 | protocol: dtls, |
| 5382 | testType: serverTest, |
| 5383 | name: "MinorVersionTolerance-DTLS", |
| 5384 | config: Config{ |
| 5385 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5386 | SendClientVersion: 0xfe00, |
| 5387 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5388 | }, |
| 5389 | }, |
| 5390 | expectedVersion: VersionTLS12, |
| 5391 | }) |
| 5392 | testCases = append(testCases, testCase{ |
| 5393 | protocol: dtls, |
| 5394 | testType: serverTest, |
| 5395 | name: "MajorVersionTolerance-DTLS", |
| 5396 | config: Config{ |
| 5397 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5398 | SendClientVersion: 0xfdff, |
| 5399 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5400 | }, |
| 5401 | }, |
| 5402 | expectedVersion: VersionTLS12, |
| 5403 | }) |
| 5404 | |
| 5405 | // Test that versions below 3.0 are rejected. |
| 5406 | testCases = append(testCases, testCase{ |
| 5407 | testType: serverTest, |
| 5408 | name: "VersionTooLow", |
| 5409 | config: Config{ |
| 5410 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5411 | SendClientVersion: 0x0200, |
| 5412 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5413 | }, |
| 5414 | }, |
| 5415 | shouldFail: true, |
| 5416 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5417 | }) |
| 5418 | testCases = append(testCases, testCase{ |
| 5419 | protocol: dtls, |
| 5420 | testType: serverTest, |
| 5421 | name: "VersionTooLow-DTLS", |
| 5422 | config: Config{ |
| 5423 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5424 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5425 | }, |
| 5426 | }, |
| 5427 | shouldFail: true, |
| 5428 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5429 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5430 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5431 | testCases = append(testCases, testCase{ |
| 5432 | name: "ServerBogusVersion", |
| 5433 | config: Config{ |
| 5434 | Bugs: ProtocolBugs{ |
| 5435 | SendServerHelloVersion: 0x1234, |
| 5436 | }, |
| 5437 | }, |
| 5438 | shouldFail: true, |
| 5439 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5440 | }) |
| 5441 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5442 | // Test TLS 1.3's downgrade signal. |
| 5443 | testCases = append(testCases, testCase{ |
| 5444 | name: "Downgrade-TLS12-Client", |
| 5445 | config: Config{ |
| 5446 | Bugs: ProtocolBugs{ |
| 5447 | NegotiateVersion: VersionTLS12, |
| 5448 | }, |
| 5449 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5450 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5451 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5452 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5453 | }) |
| 5454 | testCases = append(testCases, testCase{ |
| 5455 | testType: serverTest, |
| 5456 | name: "Downgrade-TLS12-Server", |
| 5457 | config: Config{ |
| 5458 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5459 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5460 | }, |
| 5461 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5462 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5463 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5464 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5465 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5466 | } |
| 5467 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5468 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5469 | for _, protocol := range []protocol{tls, dtls} { |
| 5470 | for _, shimVers := range allVersions(protocol) { |
| 5471 | // Assemble flags to disable all older versions on the shim. |
| 5472 | var flags []string |
| 5473 | for _, vers := range allVersions(protocol) { |
| 5474 | if vers.version < shimVers.version { |
| 5475 | flags = append(flags, vers.excludeFlag) |
| 5476 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5477 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5478 | |
| 5479 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5480 | |
| 5481 | if shimVers.tls13Variant != 0 { |
| 5482 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5483 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5484 | } |
| 5485 | |
| 5486 | for _, runnerVers := range allVersions(protocol) { |
| 5487 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5488 | // produce consistent minimum versions. |
| 5489 | // |
| 5490 | // TODO(davidben): Fold these tests (the main value is in the |
| 5491 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5492 | // on intended shim behavior, not the shim + runner combination. |
| 5493 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5494 | continue |
| 5495 | } |
| 5496 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5497 | suffix := shimVers.name + "-" + runnerVers.name |
| 5498 | if protocol == dtls { |
| 5499 | suffix += "-DTLS" |
| 5500 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5501 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5502 | var expectedVersion uint16 |
| 5503 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5504 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5505 | if runnerVers.version >= shimVers.version { |
| 5506 | expectedVersion = runnerVers.version |
| 5507 | } else { |
| 5508 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5509 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5510 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5511 | } |
| 5512 | |
| 5513 | testCases = append(testCases, testCase{ |
| 5514 | protocol: protocol, |
| 5515 | testType: clientTest, |
| 5516 | name: "MinimumVersion-Client-" + suffix, |
| 5517 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5518 | MaxVersion: runnerVers.version, |
| 5519 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5520 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5521 | // Ensure the server does not decline to |
| 5522 | // select a version (versions extension) or |
| 5523 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5524 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5525 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5526 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5527 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5528 | flags: flags, |
| 5529 | expectedVersion: expectedVersion, |
| 5530 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5531 | expectedError: expectedError, |
| 5532 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5533 | }) |
| 5534 | testCases = append(testCases, testCase{ |
| 5535 | protocol: protocol, |
| 5536 | testType: clientTest, |
| 5537 | name: "MinimumVersion-Client2-" + suffix, |
| 5538 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5539 | MaxVersion: runnerVers.version, |
| 5540 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5541 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5542 | // Ensure the server does not decline to |
| 5543 | // select a version (versions extension) or |
| 5544 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5545 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5546 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5547 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5548 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5549 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5550 | expectedVersion: expectedVersion, |
| 5551 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5552 | expectedError: expectedError, |
| 5553 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5554 | }) |
| 5555 | |
| 5556 | testCases = append(testCases, testCase{ |
| 5557 | protocol: protocol, |
| 5558 | testType: serverTest, |
| 5559 | name: "MinimumVersion-Server-" + suffix, |
| 5560 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5561 | MaxVersion: runnerVers.version, |
| 5562 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5563 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5564 | flags: flags, |
| 5565 | expectedVersion: expectedVersion, |
| 5566 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5567 | expectedError: expectedError, |
| 5568 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5569 | }) |
| 5570 | testCases = append(testCases, testCase{ |
| 5571 | protocol: protocol, |
| 5572 | testType: serverTest, |
| 5573 | name: "MinimumVersion-Server2-" + suffix, |
| 5574 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5575 | MaxVersion: runnerVers.version, |
| 5576 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5577 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5578 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5579 | expectedVersion: expectedVersion, |
| 5580 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5581 | expectedError: expectedError, |
| 5582 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5583 | }) |
| 5584 | } |
| 5585 | } |
| 5586 | } |
| 5587 | } |
| 5588 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5589 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5590 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5591 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5592 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5593 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5594 | // Repeat extensions tests all versions except SSL 3.0. |
| 5595 | for _, ver := range tlsVersions { |
| 5596 | if ver.version == VersionSSL30 { |
| 5597 | continue |
| 5598 | } |
| 5599 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5600 | // Test that duplicate extensions are rejected. |
| 5601 | testCases = append(testCases, testCase{ |
| 5602 | testType: clientTest, |
| 5603 | name: "DuplicateExtensionClient-" + ver.name, |
| 5604 | config: Config{ |
| 5605 | MaxVersion: ver.version, |
| 5606 | Bugs: ProtocolBugs{ |
| 5607 | DuplicateExtension: true, |
| 5608 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5609 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5610 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5611 | shouldFail: true, |
| 5612 | expectedLocalError: "remote error: error decoding message", |
| 5613 | }) |
| 5614 | testCases = append(testCases, testCase{ |
| 5615 | testType: serverTest, |
| 5616 | name: "DuplicateExtensionServer-" + ver.name, |
| 5617 | config: Config{ |
| 5618 | MaxVersion: ver.version, |
| 5619 | Bugs: ProtocolBugs{ |
| 5620 | DuplicateExtension: true, |
| 5621 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5622 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5623 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5624 | shouldFail: true, |
| 5625 | expectedLocalError: "remote error: error decoding message", |
| 5626 | }) |
| 5627 | |
| 5628 | // Test SNI. |
| 5629 | testCases = append(testCases, testCase{ |
| 5630 | testType: clientTest, |
| 5631 | name: "ServerNameExtensionClient-" + ver.name, |
| 5632 | config: Config{ |
| 5633 | MaxVersion: ver.version, |
| 5634 | Bugs: ProtocolBugs{ |
| 5635 | ExpectServerName: "example.com", |
| 5636 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5637 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5638 | tls13Variant: ver.tls13Variant, |
| 5639 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5640 | }) |
| 5641 | testCases = append(testCases, testCase{ |
| 5642 | testType: clientTest, |
| 5643 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5644 | config: Config{ |
| 5645 | MaxVersion: ver.version, |
| 5646 | Bugs: ProtocolBugs{ |
| 5647 | ExpectServerName: "mismatch.com", |
| 5648 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5649 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5650 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5651 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5652 | shouldFail: true, |
| 5653 | expectedLocalError: "tls: unexpected server name", |
| 5654 | }) |
| 5655 | testCases = append(testCases, testCase{ |
| 5656 | testType: clientTest, |
| 5657 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5658 | config: Config{ |
| 5659 | MaxVersion: ver.version, |
| 5660 | Bugs: ProtocolBugs{ |
| 5661 | ExpectServerName: "missing.com", |
| 5662 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5663 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5664 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5665 | shouldFail: true, |
| 5666 | expectedLocalError: "tls: unexpected server name", |
| 5667 | }) |
| 5668 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5669 | testType: clientTest, |
| 5670 | name: "TolerateServerNameAck-" + ver.name, |
| 5671 | config: Config{ |
| 5672 | MaxVersion: ver.version, |
| 5673 | Bugs: ProtocolBugs{ |
| 5674 | SendServerNameAck: true, |
| 5675 | }, |
| 5676 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5677 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5678 | flags: []string{"-host-name", "example.com"}, |
| 5679 | resumeSession: true, |
| 5680 | }) |
| 5681 | testCases = append(testCases, testCase{ |
| 5682 | testType: clientTest, |
| 5683 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5684 | config: Config{ |
| 5685 | MaxVersion: ver.version, |
| 5686 | Bugs: ProtocolBugs{ |
| 5687 | SendServerNameAck: true, |
| 5688 | }, |
| 5689 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5690 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5691 | shouldFail: true, |
| 5692 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5693 | expectedLocalError: "remote error: unsupported extension", |
| 5694 | }) |
| 5695 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5696 | testType: serverTest, |
| 5697 | name: "ServerNameExtensionServer-" + ver.name, |
| 5698 | config: Config{ |
| 5699 | MaxVersion: ver.version, |
| 5700 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 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 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5704 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5705 | }) |
| 5706 | |
| 5707 | // Test ALPN. |
| 5708 | testCases = append(testCases, testCase{ |
| 5709 | testType: clientTest, |
| 5710 | name: "ALPNClient-" + ver.name, |
| 5711 | config: Config{ |
| 5712 | MaxVersion: ver.version, |
| 5713 | NextProtos: []string{"foo"}, |
| 5714 | }, |
| 5715 | flags: []string{ |
| 5716 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5717 | "-expect-alpn", "foo", |
| 5718 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5719 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5720 | expectedNextProto: "foo", |
| 5721 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5722 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5723 | }) |
| 5724 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5725 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5726 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5727 | config: Config{ |
| 5728 | MaxVersion: ver.version, |
| 5729 | Bugs: ProtocolBugs{ |
| 5730 | SendALPN: "baz", |
| 5731 | }, |
| 5732 | }, |
| 5733 | flags: []string{ |
| 5734 | "-advertise-alpn", "\x03foo\x03bar", |
| 5735 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5736 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5737 | shouldFail: true, |
| 5738 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5739 | expectedLocalError: "remote error: illegal parameter", |
| 5740 | }) |
| 5741 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5742 | testType: clientTest, |
| 5743 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5744 | config: Config{ |
| 5745 | MaxVersion: ver.version, |
| 5746 | Bugs: ProtocolBugs{ |
| 5747 | SendALPN: "baz", |
| 5748 | }, |
| 5749 | }, |
| 5750 | flags: []string{ |
| 5751 | "-advertise-alpn", "\x03foo\x03bar", |
| 5752 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5753 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5754 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5755 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5756 | }) |
| 5757 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5758 | testType: serverTest, |
| 5759 | name: "ALPNServer-" + ver.name, |
| 5760 | config: Config{ |
| 5761 | MaxVersion: ver.version, |
| 5762 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5763 | }, |
| 5764 | flags: []string{ |
| 5765 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5766 | "-select-alpn", "foo", |
| 5767 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5768 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5769 | expectedNextProto: "foo", |
| 5770 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5771 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5772 | }) |
| 5773 | testCases = append(testCases, testCase{ |
| 5774 | testType: serverTest, |
| 5775 | name: "ALPNServer-Decline-" + ver.name, |
| 5776 | config: Config{ |
| 5777 | MaxVersion: ver.version, |
| 5778 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5779 | }, |
| 5780 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5781 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5782 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5783 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5784 | }) |
| 5785 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5786 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5787 | // called once. |
| 5788 | testCases = append(testCases, testCase{ |
| 5789 | testType: serverTest, |
| 5790 | name: "ALPNServer-Async-" + ver.name, |
| 5791 | config: Config{ |
| 5792 | MaxVersion: ver.version, |
| 5793 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5794 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5795 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5796 | }, |
| 5797 | flags: []string{ |
| 5798 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5799 | "-select-alpn", "foo", |
| 5800 | "-async", |
| 5801 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5802 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5803 | expectedNextProto: "foo", |
| 5804 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5805 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5806 | }) |
| 5807 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5808 | var emptyString string |
| 5809 | testCases = append(testCases, testCase{ |
| 5810 | testType: clientTest, |
| 5811 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5812 | config: Config{ |
| 5813 | MaxVersion: ver.version, |
| 5814 | NextProtos: []string{""}, |
| 5815 | Bugs: ProtocolBugs{ |
| 5816 | // A server returning an empty ALPN protocol |
| 5817 | // should be rejected. |
| 5818 | ALPNProtocol: &emptyString, |
| 5819 | }, |
| 5820 | }, |
| 5821 | flags: []string{ |
| 5822 | "-advertise-alpn", "\x03foo", |
| 5823 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5824 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5825 | shouldFail: true, |
| 5826 | expectedError: ":PARSE_TLSEXT:", |
| 5827 | }) |
| 5828 | testCases = append(testCases, testCase{ |
| 5829 | testType: serverTest, |
| 5830 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5831 | config: Config{ |
| 5832 | MaxVersion: ver.version, |
| 5833 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5834 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5835 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5836 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5837 | flags: []string{ |
| 5838 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5839 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5840 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5841 | shouldFail: true, |
| 5842 | expectedError: ":PARSE_TLSEXT:", |
| 5843 | }) |
| 5844 | |
| 5845 | // Test NPN and the interaction with ALPN. |
| 5846 | if ver.version < VersionTLS13 { |
| 5847 | // Test that the server prefers ALPN over NPN. |
| 5848 | testCases = append(testCases, testCase{ |
| 5849 | testType: serverTest, |
| 5850 | name: "ALPNServer-Preferred-" + ver.name, |
| 5851 | config: Config{ |
| 5852 | MaxVersion: ver.version, |
| 5853 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5854 | }, |
| 5855 | flags: []string{ |
| 5856 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5857 | "-select-alpn", "foo", |
| 5858 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5859 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5860 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5861 | expectedNextProto: "foo", |
| 5862 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5863 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5864 | }) |
| 5865 | testCases = append(testCases, testCase{ |
| 5866 | testType: serverTest, |
| 5867 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5868 | config: Config{ |
| 5869 | MaxVersion: ver.version, |
| 5870 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5871 | Bugs: ProtocolBugs{ |
| 5872 | SwapNPNAndALPN: true, |
| 5873 | }, |
| 5874 | }, |
| 5875 | flags: []string{ |
| 5876 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5877 | "-select-alpn", "foo", |
| 5878 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5879 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5880 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5881 | expectedNextProto: "foo", |
| 5882 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5883 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5884 | }) |
| 5885 | |
| 5886 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5887 | testCases = append(testCases, testCase{ |
| 5888 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5889 | config: Config{ |
| 5890 | MaxVersion: ver.version, |
| 5891 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5892 | Bugs: ProtocolBugs{ |
| 5893 | NegotiateALPNAndNPN: true, |
| 5894 | }, |
| 5895 | }, |
| 5896 | flags: []string{ |
| 5897 | "-advertise-alpn", "\x03foo", |
| 5898 | "-select-next-proto", "foo", |
| 5899 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5900 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5901 | shouldFail: true, |
| 5902 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5903 | }) |
| 5904 | testCases = append(testCases, testCase{ |
| 5905 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5906 | config: Config{ |
| 5907 | MaxVersion: ver.version, |
| 5908 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5909 | Bugs: ProtocolBugs{ |
| 5910 | NegotiateALPNAndNPN: true, |
| 5911 | SwapNPNAndALPN: true, |
| 5912 | }, |
| 5913 | }, |
| 5914 | flags: []string{ |
| 5915 | "-advertise-alpn", "\x03foo", |
| 5916 | "-select-next-proto", "foo", |
| 5917 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5918 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5919 | shouldFail: true, |
| 5920 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5921 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5922 | } |
| 5923 | |
| 5924 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5925 | |
| 5926 | // Resume with a corrupt ticket. |
| 5927 | testCases = append(testCases, testCase{ |
| 5928 | testType: serverTest, |
| 5929 | name: "CorruptTicket-" + ver.name, |
| 5930 | config: Config{ |
| 5931 | MaxVersion: ver.version, |
| 5932 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5933 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5934 | in[len(in)-1] ^= 1 |
| 5935 | return in, nil |
| 5936 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5937 | }, |
| 5938 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5939 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5940 | resumeSession: true, |
| 5941 | expectResumeRejected: true, |
| 5942 | }) |
| 5943 | // Test the ticket callback, with and without renewal. |
| 5944 | testCases = append(testCases, testCase{ |
| 5945 | testType: serverTest, |
| 5946 | name: "TicketCallback-" + ver.name, |
| 5947 | config: Config{ |
| 5948 | MaxVersion: ver.version, |
| 5949 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5950 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5951 | resumeSession: true, |
| 5952 | flags: []string{"-use-ticket-callback"}, |
| 5953 | }) |
| 5954 | testCases = append(testCases, testCase{ |
| 5955 | testType: serverTest, |
| 5956 | name: "TicketCallback-Renew-" + ver.name, |
| 5957 | config: Config{ |
| 5958 | MaxVersion: ver.version, |
| 5959 | Bugs: ProtocolBugs{ |
| 5960 | ExpectNewTicket: true, |
| 5961 | }, |
| 5962 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5963 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5964 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5965 | resumeSession: true, |
| 5966 | }) |
| 5967 | |
| 5968 | // Test that the ticket callback is only called once when everything before |
| 5969 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5970 | // certificate selection callbacks run. |
| 5971 | testCases = append(testCases, testCase{ |
| 5972 | testType: serverTest, |
| 5973 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5974 | config: Config{ |
| 5975 | MaxVersion: ver.version, |
| 5976 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5977 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5978 | in[len(in)-1] ^= 1 |
| 5979 | return in, nil |
| 5980 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5981 | }, |
| 5982 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5983 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5984 | resumeSession: true, |
| 5985 | expectResumeRejected: true, |
| 5986 | flags: []string{ |
| 5987 | "-use-ticket-callback", |
| 5988 | "-async", |
| 5989 | }, |
| 5990 | }) |
| 5991 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5992 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5993 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5994 | testCases = append(testCases, testCase{ |
| 5995 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5996 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5997 | config: Config{ |
| 5998 | MaxVersion: ver.version, |
| 5999 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6000 | EmptyTicketSessionID: true, |
| 6001 | }, |
| 6002 | }, |
| 6003 | resumeSession: true, |
| 6004 | }) |
| 6005 | testCases = append(testCases, testCase{ |
| 6006 | testType: serverTest, |
| 6007 | name: "TicketSessionIDLength-16-" + ver.name, |
| 6008 | config: Config{ |
| 6009 | MaxVersion: ver.version, |
| 6010 | Bugs: ProtocolBugs{ |
| 6011 | TicketSessionIDLength: 16, |
| 6012 | }, |
| 6013 | }, |
| 6014 | resumeSession: true, |
| 6015 | }) |
| 6016 | testCases = append(testCases, testCase{ |
| 6017 | testType: serverTest, |
| 6018 | name: "TicketSessionIDLength-32-" + ver.name, |
| 6019 | config: Config{ |
| 6020 | MaxVersion: ver.version, |
| 6021 | Bugs: ProtocolBugs{ |
| 6022 | TicketSessionIDLength: 32, |
| 6023 | }, |
| 6024 | }, |
| 6025 | resumeSession: true, |
| 6026 | }) |
| 6027 | testCases = append(testCases, testCase{ |
| 6028 | testType: serverTest, |
| 6029 | name: "TicketSessionIDLength-33-" + ver.name, |
| 6030 | config: Config{ |
| 6031 | MaxVersion: ver.version, |
| 6032 | Bugs: ProtocolBugs{ |
| 6033 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6034 | }, |
| 6035 | }, |
| 6036 | resumeSession: true, |
| 6037 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6038 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6039 | expectedError: ":DECODE_ERROR:", |
| 6040 | }) |
| 6041 | } |
| 6042 | |
| 6043 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 6044 | // are ignored. |
| 6045 | if ver.hasDTLS { |
| 6046 | testCases = append(testCases, testCase{ |
| 6047 | protocol: dtls, |
| 6048 | name: "SRTP-Client-" + ver.name, |
| 6049 | config: Config{ |
| 6050 | MaxVersion: ver.version, |
| 6051 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6052 | }, |
| 6053 | flags: []string{ |
| 6054 | "-srtp-profiles", |
| 6055 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6056 | }, |
| 6057 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6058 | }) |
| 6059 | testCases = append(testCases, testCase{ |
| 6060 | protocol: dtls, |
| 6061 | testType: serverTest, |
| 6062 | name: "SRTP-Server-" + ver.name, |
| 6063 | config: Config{ |
| 6064 | MaxVersion: ver.version, |
| 6065 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6066 | }, |
| 6067 | flags: []string{ |
| 6068 | "-srtp-profiles", |
| 6069 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6070 | }, |
| 6071 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6072 | }) |
| 6073 | // Test that the MKI is ignored. |
| 6074 | testCases = append(testCases, testCase{ |
| 6075 | protocol: dtls, |
| 6076 | testType: serverTest, |
| 6077 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 6078 | config: Config{ |
| 6079 | MaxVersion: ver.version, |
| 6080 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 6081 | Bugs: ProtocolBugs{ |
| 6082 | SRTPMasterKeyIdentifer: "bogus", |
| 6083 | }, |
| 6084 | }, |
| 6085 | flags: []string{ |
| 6086 | "-srtp-profiles", |
| 6087 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6088 | }, |
| 6089 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6090 | }) |
| 6091 | // Test that SRTP isn't negotiated on the server if there were |
| 6092 | // no matching profiles. |
| 6093 | testCases = append(testCases, testCase{ |
| 6094 | protocol: dtls, |
| 6095 | testType: serverTest, |
| 6096 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6097 | config: Config{ |
| 6098 | MaxVersion: ver.version, |
| 6099 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6100 | }, |
| 6101 | flags: []string{ |
| 6102 | "-srtp-profiles", |
| 6103 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6104 | }, |
| 6105 | expectedSRTPProtectionProfile: 0, |
| 6106 | }) |
| 6107 | // Test that the server returning an invalid SRTP profile is |
| 6108 | // flagged as an error by the client. |
| 6109 | testCases = append(testCases, testCase{ |
| 6110 | protocol: dtls, |
| 6111 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6112 | config: Config{ |
| 6113 | MaxVersion: ver.version, |
| 6114 | Bugs: ProtocolBugs{ |
| 6115 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6116 | }, |
| 6117 | }, |
| 6118 | flags: []string{ |
| 6119 | "-srtp-profiles", |
| 6120 | "SRTP_AES128_CM_SHA1_80", |
| 6121 | }, |
| 6122 | shouldFail: true, |
| 6123 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6124 | }) |
| 6125 | } |
| 6126 | |
| 6127 | // Test SCT list. |
| 6128 | testCases = append(testCases, testCase{ |
| 6129 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6130 | testType: clientTest, |
| 6131 | config: Config{ |
| 6132 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6133 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6134 | flags: []string{ |
| 6135 | "-enable-signed-cert-timestamps", |
| 6136 | "-expect-signed-cert-timestamps", |
| 6137 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6138 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6139 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6140 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6141 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6142 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6143 | var differentSCTList []byte |
| 6144 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6145 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6146 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6147 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6148 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6149 | testCases = append(testCases, testCase{ |
| 6150 | name: "SendSCTListOnResume-" + ver.name, |
| 6151 | config: Config{ |
| 6152 | MaxVersion: ver.version, |
| 6153 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6154 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6155 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6156 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6157 | flags: []string{ |
| 6158 | "-enable-signed-cert-timestamps", |
| 6159 | "-expect-signed-cert-timestamps", |
| 6160 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6161 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6162 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6163 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6164 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6165 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6166 | testCases = append(testCases, testCase{ |
| 6167 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6168 | testType: serverTest, |
| 6169 | config: Config{ |
| 6170 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6171 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6172 | flags: []string{ |
| 6173 | "-signed-cert-timestamps", |
| 6174 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6175 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6176 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6177 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6178 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6179 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6180 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6181 | emptySCTListCert := *testCerts[0].cert |
| 6182 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6183 | |
| 6184 | // Test empty SCT list. |
| 6185 | testCases = append(testCases, testCase{ |
| 6186 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6187 | testType: clientTest, |
| 6188 | config: Config{ |
| 6189 | MaxVersion: ver.version, |
| 6190 | Certificates: []Certificate{emptySCTListCert}, |
| 6191 | }, |
| 6192 | flags: []string{ |
| 6193 | "-enable-signed-cert-timestamps", |
| 6194 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6195 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6196 | shouldFail: true, |
| 6197 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6198 | }) |
| 6199 | |
| 6200 | emptySCTCert := *testCerts[0].cert |
| 6201 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6202 | |
| 6203 | // Test empty SCT in non-empty list. |
| 6204 | testCases = append(testCases, testCase{ |
| 6205 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6206 | testType: clientTest, |
| 6207 | config: Config{ |
| 6208 | MaxVersion: ver.version, |
| 6209 | Certificates: []Certificate{emptySCTCert}, |
| 6210 | }, |
| 6211 | flags: []string{ |
| 6212 | "-enable-signed-cert-timestamps", |
| 6213 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6214 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6215 | shouldFail: true, |
| 6216 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6217 | }) |
| 6218 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6219 | // Test that certificate-related extensions are not sent unsolicited. |
| 6220 | testCases = append(testCases, testCase{ |
| 6221 | testType: serverTest, |
| 6222 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6223 | config: Config{ |
| 6224 | MaxVersion: ver.version, |
| 6225 | Bugs: ProtocolBugs{ |
| 6226 | NoOCSPStapling: true, |
| 6227 | NoSignedCertificateTimestamps: true, |
| 6228 | }, |
| 6229 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6230 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6231 | flags: []string{ |
| 6232 | "-ocsp-response", |
| 6233 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6234 | "-signed-cert-timestamps", |
| 6235 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6236 | }, |
| 6237 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6238 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6239 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6240 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6241 | testType: clientTest, |
| 6242 | name: "ClientHelloPadding", |
| 6243 | config: Config{ |
| 6244 | Bugs: ProtocolBugs{ |
| 6245 | RequireClientHelloSize: 512, |
| 6246 | }, |
| 6247 | }, |
| 6248 | // This hostname just needs to be long enough to push the |
| 6249 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6250 | // long. |
| 6251 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6252 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6253 | |
| 6254 | // Extensions should not function in SSL 3.0. |
| 6255 | testCases = append(testCases, testCase{ |
| 6256 | testType: serverTest, |
| 6257 | name: "SSLv3Extensions-NoALPN", |
| 6258 | config: Config{ |
| 6259 | MaxVersion: VersionSSL30, |
| 6260 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6261 | }, |
| 6262 | flags: []string{ |
| 6263 | "-select-alpn", "foo", |
| 6264 | }, |
| 6265 | expectNoNextProto: true, |
| 6266 | }) |
| 6267 | |
| 6268 | // Test session tickets separately as they follow a different codepath. |
| 6269 | testCases = append(testCases, testCase{ |
| 6270 | testType: serverTest, |
| 6271 | name: "SSLv3Extensions-NoTickets", |
| 6272 | config: Config{ |
| 6273 | MaxVersion: VersionSSL30, |
| 6274 | Bugs: ProtocolBugs{ |
| 6275 | // Historically, session tickets in SSL 3.0 |
| 6276 | // failed in different ways depending on whether |
| 6277 | // the client supported renegotiation_info. |
| 6278 | NoRenegotiationInfo: true, |
| 6279 | }, |
| 6280 | }, |
| 6281 | resumeSession: true, |
| 6282 | }) |
| 6283 | testCases = append(testCases, testCase{ |
| 6284 | testType: serverTest, |
| 6285 | name: "SSLv3Extensions-NoTickets2", |
| 6286 | config: Config{ |
| 6287 | MaxVersion: VersionSSL30, |
| 6288 | }, |
| 6289 | resumeSession: true, |
| 6290 | }) |
| 6291 | |
| 6292 | // But SSL 3.0 does send and process renegotiation_info. |
| 6293 | testCases = append(testCases, testCase{ |
| 6294 | testType: serverTest, |
| 6295 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6296 | config: Config{ |
| 6297 | MaxVersion: VersionSSL30, |
| 6298 | Bugs: ProtocolBugs{ |
| 6299 | RequireRenegotiationInfo: true, |
| 6300 | }, |
| 6301 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6302 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6303 | }) |
| 6304 | testCases = append(testCases, testCase{ |
| 6305 | testType: serverTest, |
| 6306 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6307 | config: Config{ |
| 6308 | MaxVersion: VersionSSL30, |
| 6309 | Bugs: ProtocolBugs{ |
| 6310 | NoRenegotiationInfo: true, |
| 6311 | SendRenegotiationSCSV: true, |
| 6312 | RequireRenegotiationInfo: true, |
| 6313 | }, |
| 6314 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6315 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6316 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6317 | |
| 6318 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6319 | // in ServerHello. |
| 6320 | testCases = append(testCases, testCase{ |
| 6321 | name: "NPN-Forbidden-TLS13", |
| 6322 | config: Config{ |
| 6323 | MaxVersion: VersionTLS13, |
| 6324 | NextProtos: []string{"foo"}, |
| 6325 | Bugs: ProtocolBugs{ |
| 6326 | NegotiateNPNAtAllVersions: true, |
| 6327 | }, |
| 6328 | }, |
| 6329 | flags: []string{"-select-next-proto", "foo"}, |
| 6330 | shouldFail: true, |
| 6331 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6332 | }) |
| 6333 | testCases = append(testCases, testCase{ |
| 6334 | name: "EMS-Forbidden-TLS13", |
| 6335 | config: Config{ |
| 6336 | MaxVersion: VersionTLS13, |
| 6337 | Bugs: ProtocolBugs{ |
| 6338 | NegotiateEMSAtAllVersions: true, |
| 6339 | }, |
| 6340 | }, |
| 6341 | shouldFail: true, |
| 6342 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6343 | }) |
| 6344 | testCases = append(testCases, testCase{ |
| 6345 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6346 | config: Config{ |
| 6347 | MaxVersion: VersionTLS13, |
| 6348 | Bugs: ProtocolBugs{ |
| 6349 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6350 | }, |
| 6351 | }, |
| 6352 | shouldFail: true, |
| 6353 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6354 | }) |
| 6355 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6356 | name: "Ticket-Forbidden-TLS13", |
| 6357 | config: Config{ |
| 6358 | MaxVersion: VersionTLS12, |
| 6359 | }, |
| 6360 | resumeConfig: &Config{ |
| 6361 | MaxVersion: VersionTLS13, |
| 6362 | Bugs: ProtocolBugs{ |
| 6363 | AdvertiseTicketExtension: true, |
| 6364 | }, |
| 6365 | }, |
| 6366 | resumeSession: true, |
| 6367 | shouldFail: true, |
| 6368 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6369 | }) |
| 6370 | |
| 6371 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6372 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6373 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6374 | // implicit in every test.) |
| 6375 | testCases = append(testCases, testCase{ |
| 6376 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6377 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6378 | config: Config{ |
| 6379 | MaxVersion: VersionTLS13, |
| 6380 | NextProtos: []string{"bar"}, |
| 6381 | }, |
| 6382 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6383 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6384 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6385 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6386 | // tolerated. |
| 6387 | testCases = append(testCases, testCase{ |
| 6388 | name: "SendOCSPResponseOnResume-TLS12", |
| 6389 | config: Config{ |
| 6390 | MaxVersion: VersionTLS12, |
| 6391 | Bugs: ProtocolBugs{ |
| 6392 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6393 | }, |
| 6394 | }, |
| 6395 | flags: []string{ |
| 6396 | "-enable-ocsp-stapling", |
| 6397 | "-expect-ocsp-response", |
| 6398 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6399 | }, |
| 6400 | resumeSession: true, |
| 6401 | }) |
| 6402 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6403 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6404 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6405 | config: Config{ |
| 6406 | MaxVersion: VersionTLS13, |
| 6407 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6408 | SendExtensionOnCertificate: testOCSPExtension, |
| 6409 | }, |
| 6410 | }, |
| 6411 | shouldFail: true, |
| 6412 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6413 | }) |
| 6414 | |
| 6415 | testCases = append(testCases, testCase{ |
| 6416 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6417 | config: Config{ |
| 6418 | MaxVersion: VersionTLS13, |
| 6419 | Bugs: ProtocolBugs{ |
| 6420 | SendExtensionOnCertificate: testSCTExtension, |
| 6421 | }, |
| 6422 | }, |
| 6423 | shouldFail: true, |
| 6424 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6425 | }) |
| 6426 | |
| 6427 | // Test that extensions on client certificates are never accepted. |
| 6428 | testCases = append(testCases, testCase{ |
| 6429 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6430 | testType: serverTest, |
| 6431 | config: Config{ |
| 6432 | MaxVersion: VersionTLS13, |
| 6433 | Certificates: []Certificate{rsaCertificate}, |
| 6434 | Bugs: ProtocolBugs{ |
| 6435 | SendExtensionOnCertificate: testOCSPExtension, |
| 6436 | }, |
| 6437 | }, |
| 6438 | flags: []string{ |
| 6439 | "-enable-ocsp-stapling", |
| 6440 | "-require-any-client-certificate", |
| 6441 | }, |
| 6442 | shouldFail: true, |
| 6443 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6444 | }) |
| 6445 | |
| 6446 | testCases = append(testCases, testCase{ |
| 6447 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6448 | config: Config{ |
| 6449 | MaxVersion: VersionTLS13, |
| 6450 | Bugs: ProtocolBugs{ |
| 6451 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6452 | }, |
| 6453 | }, |
| 6454 | shouldFail: true, |
| 6455 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6456 | }) |
| 6457 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6458 | var differentSCTList []byte |
| 6459 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6460 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6461 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6462 | // Test that extensions on intermediates are allowed but ignored. |
| 6463 | testCases = append(testCases, testCase{ |
| 6464 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6465 | config: Config{ |
| 6466 | MaxVersion: VersionTLS13, |
| 6467 | Certificates: []Certificate{rsaChainCertificate}, |
| 6468 | Bugs: ProtocolBugs{ |
| 6469 | // Send different values on the intermediate. This tests |
| 6470 | // the intermediate's extensions do not override the |
| 6471 | // leaf's. |
| 6472 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6473 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6474 | }, |
| 6475 | }, |
| 6476 | flags: []string{ |
| 6477 | "-enable-ocsp-stapling", |
| 6478 | "-expect-ocsp-response", |
| 6479 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6480 | "-enable-signed-cert-timestamps", |
| 6481 | "-expect-signed-cert-timestamps", |
| 6482 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6483 | }, |
| 6484 | resumeSession: true, |
| 6485 | }) |
| 6486 | |
| 6487 | // Test that extensions are not sent on intermediates when configured |
| 6488 | // only for a leaf. |
| 6489 | testCases = append(testCases, testCase{ |
| 6490 | testType: serverTest, |
| 6491 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6492 | config: Config{ |
| 6493 | MaxVersion: VersionTLS13, |
| 6494 | Bugs: ProtocolBugs{ |
| 6495 | ExpectNoExtensionsOnIntermediate: true, |
| 6496 | }, |
| 6497 | }, |
| 6498 | flags: []string{ |
| 6499 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6500 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6501 | "-ocsp-response", |
| 6502 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6503 | "-signed-cert-timestamps", |
| 6504 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6505 | }, |
| 6506 | }) |
| 6507 | |
| 6508 | // Test that extensions are not sent on client certificates. |
| 6509 | testCases = append(testCases, testCase{ |
| 6510 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6511 | config: Config{ |
| 6512 | MaxVersion: VersionTLS13, |
| 6513 | ClientAuth: RequireAnyClientCert, |
| 6514 | }, |
| 6515 | flags: []string{ |
| 6516 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6517 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6518 | "-ocsp-response", |
| 6519 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6520 | "-signed-cert-timestamps", |
| 6521 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6522 | }, |
| 6523 | }) |
| 6524 | |
| 6525 | testCases = append(testCases, testCase{ |
| 6526 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6527 | config: Config{ |
| 6528 | MaxVersion: VersionTLS13, |
| 6529 | Bugs: ProtocolBugs{ |
| 6530 | SendDuplicateCertExtensions: true, |
| 6531 | }, |
| 6532 | }, |
| 6533 | flags: []string{ |
| 6534 | "-enable-ocsp-stapling", |
| 6535 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6536 | }, |
| 6537 | resumeSession: true, |
| 6538 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6539 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6540 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6541 | |
| 6542 | testCases = append(testCases, testCase{ |
| 6543 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6544 | testType: serverTest, |
| 6545 | flags: []string{ |
| 6546 | "-signed-cert-timestamps", |
| 6547 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6548 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6549 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6550 | expectedError: ":INVALID_SCT_LIST:", |
| 6551 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6552 | } |
| 6553 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6554 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6555 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6556 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6557 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6558 | // have session IDs, so skip their cross-resumption |
| 6559 | // tests. |
| 6560 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6561 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6562 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6563 | } |
| 6564 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6565 | protocols := []protocol{tls} |
| 6566 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6567 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6568 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6569 | for _, protocol := range protocols { |
| 6570 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6571 | if protocol == dtls { |
| 6572 | suffix += "-DTLS" |
| 6573 | } |
| 6574 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6575 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6576 | // session resumption. |
| 6577 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6578 | continue |
| 6579 | } |
| 6580 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6581 | if sessionVers.version == resumeVers.version { |
| 6582 | testCases = append(testCases, testCase{ |
| 6583 | protocol: protocol, |
| 6584 | name: "Resume-Client" + suffix, |
| 6585 | resumeSession: true, |
| 6586 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6587 | MaxVersion: sessionVers.version, |
| 6588 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6589 | Bugs: ProtocolBugs{ |
| 6590 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6591 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6592 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6593 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6594 | expectedVersion: sessionVers.version, |
| 6595 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6596 | flags: []string{ |
| 6597 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6598 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6599 | }) |
| 6600 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6601 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6602 | |
| 6603 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6604 | // there is no way to convince a non-lookahead client the |
| 6605 | // session was resumed. It will appear to the client that a |
| 6606 | // stray ChangeCipherSpec was sent. |
| 6607 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6608 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6609 | } |
| 6610 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6611 | testCases = append(testCases, testCase{ |
| 6612 | protocol: protocol, |
| 6613 | name: "Resume-Client-Mismatch" + suffix, |
| 6614 | resumeSession: true, |
| 6615 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6616 | MaxVersion: sessionVers.version, |
| 6617 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6618 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6619 | expectedVersion: sessionVers.version, |
| 6620 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6621 | MaxVersion: resumeVers.version, |
| 6622 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6623 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6624 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6625 | }, |
| 6626 | }, |
| 6627 | expectedResumeVersion: resumeVers.version, |
| 6628 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6629 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6630 | flags: []string{ |
| 6631 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6632 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6633 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6634 | }) |
| 6635 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6636 | |
| 6637 | testCases = append(testCases, testCase{ |
| 6638 | protocol: protocol, |
| 6639 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6640 | resumeSession: true, |
| 6641 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6642 | MaxVersion: sessionVers.version, |
| 6643 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6644 | }, |
| 6645 | expectedVersion: sessionVers.version, |
| 6646 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6647 | MaxVersion: resumeVers.version, |
| 6648 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6649 | }, |
| 6650 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6651 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6652 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6653 | flags: []string{ |
| 6654 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6655 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6656 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6657 | }) |
| 6658 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6659 | testCases = append(testCases, testCase{ |
| 6660 | protocol: protocol, |
| 6661 | testType: serverTest, |
| 6662 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6663 | resumeSession: true, |
| 6664 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6665 | MaxVersion: sessionVers.version, |
| 6666 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6667 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6668 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6669 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6670 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6671 | MaxVersion: resumeVers.version, |
| 6672 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6673 | Bugs: ProtocolBugs{ |
| 6674 | SendBothTickets: true, |
| 6675 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6676 | }, |
| 6677 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6678 | flags: []string{ |
| 6679 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6680 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6681 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6682 | }) |
| 6683 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6684 | } |
| 6685 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6686 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6687 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6688 | testCases = append(testCases, testCase{ |
| 6689 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6690 | name: "ShimTicketRewritable", |
| 6691 | resumeSession: true, |
| 6692 | config: Config{ |
| 6693 | MaxVersion: VersionTLS12, |
| 6694 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6695 | Bugs: ProtocolBugs{ |
| 6696 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6697 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6698 | if err != nil { |
| 6699 | return nil, err |
| 6700 | } |
| 6701 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6702 | }, |
| 6703 | }, |
| 6704 | }, |
| 6705 | flags: []string{ |
| 6706 | "-ticket-key", |
| 6707 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6708 | }, |
| 6709 | }) |
| 6710 | |
| 6711 | // Resumptions are declined if the version does not match. |
| 6712 | testCases = append(testCases, testCase{ |
| 6713 | testType: serverTest, |
| 6714 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6715 | resumeSession: true, |
| 6716 | config: Config{ |
| 6717 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6718 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6719 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6720 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6721 | return SetShimTicketVersion(in, VersionTLS13) |
| 6722 | }, |
| 6723 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6724 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6725 | flags: []string{ |
| 6726 | "-ticket-key", |
| 6727 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6728 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6729 | expectResumeRejected: true, |
| 6730 | }) |
| 6731 | |
| 6732 | testCases = append(testCases, testCase{ |
| 6733 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6734 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6735 | resumeSession: true, |
| 6736 | config: Config{ |
| 6737 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6738 | Bugs: ProtocolBugs{ |
| 6739 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6740 | return SetShimTicketVersion(in, VersionTLS12) |
| 6741 | }, |
| 6742 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6743 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6744 | flags: []string{ |
| 6745 | "-ticket-key", |
| 6746 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6747 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6748 | expectResumeRejected: true, |
| 6749 | }) |
| 6750 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6751 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6752 | testCases = append(testCases, testCase{ |
| 6753 | testType: serverTest, |
| 6754 | name: "Resume-Server-DeclineBadCipher", |
| 6755 | resumeSession: true, |
| 6756 | config: Config{ |
| 6757 | MaxVersion: VersionTLS12, |
| 6758 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6759 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6760 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6761 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6762 | }, |
| 6763 | }, |
| 6764 | }, |
| 6765 | flags: []string{ |
| 6766 | "-ticket-key", |
| 6767 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6768 | }, |
| 6769 | expectResumeRejected: true, |
| 6770 | }) |
| 6771 | |
| 6772 | testCases = append(testCases, testCase{ |
| 6773 | testType: serverTest, |
| 6774 | name: "Resume-Server-DeclineBadCipher-2", |
| 6775 | resumeSession: true, |
| 6776 | config: Config{ |
| 6777 | MaxVersion: VersionTLS12, |
| 6778 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6779 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6780 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6781 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6782 | }, |
| 6783 | }, |
| 6784 | }, |
| 6785 | flags: []string{ |
| 6786 | "-cipher", "AES128", |
| 6787 | "-ticket-key", |
| 6788 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6789 | }, |
| 6790 | expectResumeRejected: true, |
| 6791 | }) |
| 6792 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6793 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6794 | testCases = append(testCases, testCase{ |
| 6795 | testType: serverTest, |
| 6796 | name: "Resume-Server-CipherNotPreferred", |
| 6797 | resumeSession: true, |
| 6798 | config: Config{ |
| 6799 | MaxVersion: VersionTLS12, |
| 6800 | Bugs: ProtocolBugs{ |
| 6801 | ExpectNewTicket: true, |
| 6802 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6803 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6804 | }, |
| 6805 | }, |
| 6806 | }, |
| 6807 | flags: []string{ |
| 6808 | "-ticket-key", |
| 6809 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6810 | }, |
| 6811 | shouldFail: false, |
| 6812 | expectResumeRejected: true, |
| 6813 | }) |
| 6814 | |
| 6815 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6816 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6817 | testCases = append(testCases, testCase{ |
| 6818 | testType: serverTest, |
| 6819 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6820 | resumeSession: true, |
| 6821 | config: Config{ |
| 6822 | MaxVersion: VersionTLS13, |
| 6823 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6824 | Bugs: ProtocolBugs{ |
| 6825 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6826 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6827 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6828 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6829 | }, |
| 6830 | }, |
| 6831 | }, |
| 6832 | flags: []string{ |
| 6833 | "-ticket-key", |
| 6834 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6835 | }, |
| 6836 | shouldFail: false, |
| 6837 | expectResumeRejected: true, |
| 6838 | }) |
| 6839 | |
| 6840 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6841 | testCases = append(testCases, testCase{ |
| 6842 | testType: serverTest, |
| 6843 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6844 | resumeSession: true, |
| 6845 | config: Config{ |
| 6846 | MaxVersion: VersionTLS13, |
| 6847 | Bugs: ProtocolBugs{ |
| 6848 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6849 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6850 | }, |
| 6851 | }, |
| 6852 | }, |
| 6853 | flags: []string{ |
| 6854 | "-ticket-key", |
| 6855 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6856 | }, |
| 6857 | expectResumeRejected: true, |
| 6858 | }) |
| 6859 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6860 | // If the client does not offer the cipher from the session, decline to |
| 6861 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6862 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6863 | testCases = append(testCases, testCase{ |
| 6864 | testType: serverTest, |
| 6865 | name: "Resume-Server-UnofferedCipher", |
| 6866 | resumeSession: true, |
| 6867 | config: Config{ |
| 6868 | MaxVersion: VersionTLS12, |
| 6869 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6870 | }, |
| 6871 | resumeConfig: &Config{ |
| 6872 | MaxVersion: VersionTLS12, |
| 6873 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6874 | Bugs: ProtocolBugs{ |
| 6875 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6876 | }, |
| 6877 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6878 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6879 | }) |
| 6880 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6881 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6882 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6883 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6884 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6885 | testCases = append(testCases, testCase{ |
| 6886 | testType: serverTest, |
| 6887 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6888 | resumeSession: true, |
| 6889 | config: Config{ |
| 6890 | MaxVersion: VersionTLS13, |
| 6891 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6892 | }, |
| 6893 | resumeConfig: &Config{ |
| 6894 | MaxVersion: VersionTLS13, |
| 6895 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6896 | Bugs: ProtocolBugs{ |
| 6897 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6898 | }, |
| 6899 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6900 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6901 | }) |
| 6902 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6903 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6904 | testCases = append(testCases, testCase{ |
| 6905 | name: "Resume-Client-CipherMismatch", |
| 6906 | resumeSession: true, |
| 6907 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6908 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6909 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6910 | }, |
| 6911 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6912 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6913 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6914 | Bugs: ProtocolBugs{ |
| 6915 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6916 | }, |
| 6917 | }, |
| 6918 | shouldFail: true, |
| 6919 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6920 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6921 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6922 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6923 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6924 | testCases = append(testCases, testCase{ |
| 6925 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6926 | resumeSession: true, |
| 6927 | config: Config{ |
| 6928 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6929 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6930 | }, |
| 6931 | resumeConfig: &Config{ |
| 6932 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6933 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6934 | }, |
| 6935 | }) |
| 6936 | |
| 6937 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6938 | testCases = append(testCases, testCase{ |
| 6939 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6940 | resumeSession: true, |
| 6941 | config: Config{ |
| 6942 | MaxVersion: VersionTLS13, |
| 6943 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6944 | }, |
| 6945 | resumeConfig: &Config{ |
| 6946 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6947 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6948 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6949 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6950 | }, |
| 6951 | }, |
| 6952 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6953 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6954 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6955 | |
| 6956 | testCases = append(testCases, testCase{ |
| 6957 | testType: serverTest, |
| 6958 | name: "Resume-Server-BinderWrongLength", |
| 6959 | resumeSession: true, |
| 6960 | config: Config{ |
| 6961 | MaxVersion: VersionTLS13, |
| 6962 | Bugs: ProtocolBugs{ |
| 6963 | SendShortPSKBinder: true, |
| 6964 | }, |
| 6965 | }, |
| 6966 | shouldFail: true, |
| 6967 | expectedLocalError: "remote error: error decrypting message", |
| 6968 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6969 | }) |
| 6970 | |
| 6971 | testCases = append(testCases, testCase{ |
| 6972 | testType: serverTest, |
| 6973 | name: "Resume-Server-NoPSKBinder", |
| 6974 | resumeSession: true, |
| 6975 | config: Config{ |
| 6976 | MaxVersion: VersionTLS13, |
| 6977 | Bugs: ProtocolBugs{ |
| 6978 | SendNoPSKBinder: true, |
| 6979 | }, |
| 6980 | }, |
| 6981 | shouldFail: true, |
| 6982 | expectedLocalError: "remote error: error decoding message", |
| 6983 | expectedError: ":DECODE_ERROR:", |
| 6984 | }) |
| 6985 | |
| 6986 | testCases = append(testCases, testCase{ |
| 6987 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6988 | name: "Resume-Server-ExtraPSKBinder", |
| 6989 | resumeSession: true, |
| 6990 | config: Config{ |
| 6991 | MaxVersion: VersionTLS13, |
| 6992 | Bugs: ProtocolBugs{ |
| 6993 | SendExtraPSKBinder: true, |
| 6994 | }, |
| 6995 | }, |
| 6996 | shouldFail: true, |
| 6997 | expectedLocalError: "remote error: illegal parameter", |
| 6998 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6999 | }) |
| 7000 | |
| 7001 | testCases = append(testCases, testCase{ |
| 7002 | testType: serverTest, |
| 7003 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 7004 | resumeSession: true, |
| 7005 | config: Config{ |
| 7006 | MaxVersion: VersionTLS13, |
| 7007 | Bugs: ProtocolBugs{ |
| 7008 | ExtraPSKIdentity: true, |
| 7009 | }, |
| 7010 | }, |
| 7011 | shouldFail: true, |
| 7012 | expectedLocalError: "remote error: illegal parameter", |
| 7013 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 7014 | }) |
| 7015 | |
| 7016 | testCases = append(testCases, testCase{ |
| 7017 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 7018 | name: "Resume-Server-InvalidPSKBinder", |
| 7019 | resumeSession: true, |
| 7020 | config: Config{ |
| 7021 | MaxVersion: VersionTLS13, |
| 7022 | Bugs: ProtocolBugs{ |
| 7023 | SendInvalidPSKBinder: true, |
| 7024 | }, |
| 7025 | }, |
| 7026 | shouldFail: true, |
| 7027 | expectedLocalError: "remote error: error decrypting message", |
| 7028 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 7029 | }) |
| 7030 | |
| 7031 | testCases = append(testCases, testCase{ |
| 7032 | testType: serverTest, |
| 7033 | name: "Resume-Server-PSKBinderFirstExtension", |
| 7034 | resumeSession: true, |
| 7035 | config: Config{ |
| 7036 | MaxVersion: VersionTLS13, |
| 7037 | Bugs: ProtocolBugs{ |
| 7038 | PSKBinderFirst: true, |
| 7039 | }, |
| 7040 | }, |
| 7041 | shouldFail: true, |
| 7042 | expectedLocalError: "remote error: illegal parameter", |
| 7043 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 7044 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 7045 | } |
| 7046 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7047 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 7048 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7049 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7050 | testType: serverTest, |
| 7051 | name: "Renegotiate-Server-Forbidden", |
| 7052 | config: Config{ |
| 7053 | MaxVersion: VersionTLS12, |
| 7054 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7055 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7056 | shouldFail: true, |
| 7057 | expectedError: ":NO_RENEGOTIATION:", |
| 7058 | expectedLocalError: "remote error: no renegotiation", |
| 7059 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7060 | // The server shouldn't echo the renegotiation extension unless |
| 7061 | // requested by the client. |
| 7062 | testCases = append(testCases, testCase{ |
| 7063 | testType: serverTest, |
| 7064 | name: "Renegotiate-Server-NoExt", |
| 7065 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7066 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7067 | Bugs: ProtocolBugs{ |
| 7068 | NoRenegotiationInfo: true, |
| 7069 | RequireRenegotiationInfo: true, |
| 7070 | }, |
| 7071 | }, |
| 7072 | shouldFail: true, |
| 7073 | expectedLocalError: "renegotiation extension missing", |
| 7074 | }) |
| 7075 | // The renegotiation SCSV should be sufficient for the server to echo |
| 7076 | // the extension. |
| 7077 | testCases = append(testCases, testCase{ |
| 7078 | testType: serverTest, |
| 7079 | name: "Renegotiate-Server-NoExt-SCSV", |
| 7080 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7081 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7082 | Bugs: ProtocolBugs{ |
| 7083 | NoRenegotiationInfo: true, |
| 7084 | SendRenegotiationSCSV: true, |
| 7085 | RequireRenegotiationInfo: true, |
| 7086 | }, |
| 7087 | }, |
| 7088 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7089 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7090 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7091 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7092 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7093 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7094 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7095 | }, |
| 7096 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7097 | renegotiate: 1, |
| 7098 | flags: []string{ |
| 7099 | "-renegotiate-freely", |
| 7100 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7101 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7102 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7103 | }) |
| 7104 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7105 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7106 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7107 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7108 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7109 | Bugs: ProtocolBugs{ |
| 7110 | EmptyRenegotiationInfo: true, |
| 7111 | }, |
| 7112 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7113 | flags: []string{"-renegotiate-freely"}, |
| 7114 | shouldFail: true, |
| 7115 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7116 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7117 | }) |
| 7118 | testCases = append(testCases, testCase{ |
| 7119 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7120 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7121 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7122 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7123 | Bugs: ProtocolBugs{ |
| 7124 | BadRenegotiationInfo: true, |
| 7125 | }, |
| 7126 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7127 | flags: []string{"-renegotiate-freely"}, |
| 7128 | shouldFail: true, |
| 7129 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7130 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7131 | }) |
| 7132 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7133 | name: "Renegotiate-Client-BadExt2", |
| 7134 | renegotiate: 1, |
| 7135 | config: Config{ |
| 7136 | MaxVersion: VersionTLS12, |
| 7137 | Bugs: ProtocolBugs{ |
| 7138 | BadRenegotiationInfoEnd: true, |
| 7139 | }, |
| 7140 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7141 | flags: []string{"-renegotiate-freely"}, |
| 7142 | shouldFail: true, |
| 7143 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7144 | expectedLocalError: "handshake failure", |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7145 | }) |
| 7146 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7147 | name: "Renegotiate-Client-Downgrade", |
| 7148 | renegotiate: 1, |
| 7149 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7150 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7151 | Bugs: ProtocolBugs{ |
| 7152 | NoRenegotiationInfoAfterInitial: true, |
| 7153 | }, |
| 7154 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7155 | flags: []string{"-renegotiate-freely"}, |
| 7156 | shouldFail: true, |
| 7157 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7158 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7159 | }) |
| 7160 | testCases = append(testCases, testCase{ |
| 7161 | name: "Renegotiate-Client-Upgrade", |
| 7162 | renegotiate: 1, |
| 7163 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7164 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7165 | Bugs: ProtocolBugs{ |
| 7166 | NoRenegotiationInfoInInitial: true, |
| 7167 | }, |
| 7168 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7169 | flags: []string{"-renegotiate-freely"}, |
| 7170 | shouldFail: true, |
| 7171 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7172 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7173 | }) |
| 7174 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7175 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7176 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7177 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7178 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7179 | Bugs: ProtocolBugs{ |
| 7180 | NoRenegotiationInfo: true, |
| 7181 | }, |
| 7182 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7183 | flags: []string{ |
| 7184 | "-renegotiate-freely", |
| 7185 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7186 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7187 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7188 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7189 | |
| 7190 | // Test that the server may switch ciphers on renegotiation without |
| 7191 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7192 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7193 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7194 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7195 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7196 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7197 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7198 | }, |
| 7199 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7200 | flags: []string{ |
| 7201 | "-renegotiate-freely", |
| 7202 | "-expect-total-renegotiations", "1", |
| 7203 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7204 | }) |
| 7205 | testCases = append(testCases, testCase{ |
| 7206 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7207 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7208 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7209 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7210 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7211 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7212 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7213 | flags: []string{ |
| 7214 | "-renegotiate-freely", |
| 7215 | "-expect-total-renegotiations", "1", |
| 7216 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7217 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7218 | |
| 7219 | // Test that the server may not switch versions on renegotiation. |
| 7220 | testCases = append(testCases, testCase{ |
| 7221 | name: "Renegotiate-Client-SwitchVersion", |
| 7222 | config: Config{ |
| 7223 | MaxVersion: VersionTLS12, |
| 7224 | // Pick a cipher which exists at both versions. |
| 7225 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7226 | Bugs: ProtocolBugs{ |
| 7227 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7228 | // Avoid failing early at the record layer. |
| 7229 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7230 | }, |
| 7231 | }, |
| 7232 | renegotiate: 1, |
| 7233 | flags: []string{ |
| 7234 | "-renegotiate-freely", |
| 7235 | "-expect-total-renegotiations", "1", |
| 7236 | }, |
| 7237 | shouldFail: true, |
| 7238 | expectedError: ":WRONG_SSL_VERSION:", |
| 7239 | }) |
| 7240 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7241 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7242 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7243 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7244 | config: Config{ |
| 7245 | MaxVersion: VersionTLS10, |
| 7246 | Bugs: ProtocolBugs{ |
| 7247 | RequireSameRenegoClientVersion: true, |
| 7248 | }, |
| 7249 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7250 | flags: []string{ |
| 7251 | "-renegotiate-freely", |
| 7252 | "-expect-total-renegotiations", "1", |
| 7253 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7254 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7255 | testCases = append(testCases, testCase{ |
| 7256 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7257 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7258 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7259 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7260 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7261 | NextProtos: []string{"foo"}, |
| 7262 | }, |
| 7263 | flags: []string{ |
| 7264 | "-false-start", |
| 7265 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7266 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7267 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7268 | }, |
| 7269 | shimWritesFirst: true, |
| 7270 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7271 | |
| 7272 | // Client-side renegotiation controls. |
| 7273 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7274 | name: "Renegotiate-Client-Forbidden-1", |
| 7275 | config: Config{ |
| 7276 | MaxVersion: VersionTLS12, |
| 7277 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7278 | renegotiate: 1, |
| 7279 | shouldFail: true, |
| 7280 | expectedError: ":NO_RENEGOTIATION:", |
| 7281 | expectedLocalError: "remote error: no renegotiation", |
| 7282 | }) |
| 7283 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7284 | name: "Renegotiate-Client-Once-1", |
| 7285 | config: Config{ |
| 7286 | MaxVersion: VersionTLS12, |
| 7287 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7288 | renegotiate: 1, |
| 7289 | flags: []string{ |
| 7290 | "-renegotiate-once", |
| 7291 | "-expect-total-renegotiations", "1", |
| 7292 | }, |
| 7293 | }) |
| 7294 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7295 | name: "Renegotiate-Client-Freely-1", |
| 7296 | config: Config{ |
| 7297 | MaxVersion: VersionTLS12, |
| 7298 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7299 | renegotiate: 1, |
| 7300 | flags: []string{ |
| 7301 | "-renegotiate-freely", |
| 7302 | "-expect-total-renegotiations", "1", |
| 7303 | }, |
| 7304 | }) |
| 7305 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7306 | name: "Renegotiate-Client-Once-2", |
| 7307 | config: Config{ |
| 7308 | MaxVersion: VersionTLS12, |
| 7309 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7310 | renegotiate: 2, |
| 7311 | flags: []string{"-renegotiate-once"}, |
| 7312 | shouldFail: true, |
| 7313 | expectedError: ":NO_RENEGOTIATION:", |
| 7314 | expectedLocalError: "remote error: no renegotiation", |
| 7315 | }) |
| 7316 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7317 | name: "Renegotiate-Client-Freely-2", |
| 7318 | config: Config{ |
| 7319 | MaxVersion: VersionTLS12, |
| 7320 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7321 | renegotiate: 2, |
| 7322 | flags: []string{ |
| 7323 | "-renegotiate-freely", |
| 7324 | "-expect-total-renegotiations", "2", |
| 7325 | }, |
| 7326 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7327 | testCases = append(testCases, testCase{ |
| 7328 | name: "Renegotiate-Client-NoIgnore", |
| 7329 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7330 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7331 | Bugs: ProtocolBugs{ |
| 7332 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7333 | }, |
| 7334 | }, |
| 7335 | shouldFail: true, |
| 7336 | expectedError: ":NO_RENEGOTIATION:", |
| 7337 | }) |
| 7338 | testCases = append(testCases, testCase{ |
| 7339 | name: "Renegotiate-Client-Ignore", |
| 7340 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7341 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7342 | Bugs: ProtocolBugs{ |
| 7343 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7344 | }, |
| 7345 | }, |
| 7346 | flags: []string{ |
| 7347 | "-renegotiate-ignore", |
| 7348 | "-expect-total-renegotiations", "0", |
| 7349 | }, |
| 7350 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7351 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7352 | // Renegotiation is not allowed at SSL 3.0. |
| 7353 | testCases = append(testCases, testCase{ |
| 7354 | name: "Renegotiate-Client-SSL3", |
| 7355 | config: Config{ |
| 7356 | MaxVersion: VersionSSL30, |
| 7357 | }, |
| 7358 | renegotiate: 1, |
| 7359 | flags: []string{ |
| 7360 | "-renegotiate-freely", |
| 7361 | "-expect-total-renegotiations", "1", |
| 7362 | }, |
| 7363 | shouldFail: true, |
| 7364 | expectedError: ":NO_RENEGOTIATION:", |
| 7365 | expectedLocalError: "remote error: no renegotiation", |
| 7366 | }) |
| 7367 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7368 | // Renegotiation is not allowed when there is an unfinished write. |
| 7369 | testCases = append(testCases, testCase{ |
| 7370 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7371 | config: Config{ |
| 7372 | MaxVersion: VersionTLS12, |
| 7373 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7374 | renegotiate: 1, |
| 7375 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7376 | flags: []string{ |
| 7377 | "-async", |
| 7378 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7379 | }, |
| 7380 | shouldFail: true, |
| 7381 | expectedError: ":NO_RENEGOTIATION:", |
| 7382 | // We do not successfully send the no_renegotiation alert in |
| 7383 | // this case. https://crbug.com/boringssl/130 |
| 7384 | }) |
| 7385 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7386 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7387 | testCases = append(testCases, testCase{ |
| 7388 | name: "StrayHelloRequest", |
| 7389 | config: Config{ |
| 7390 | MaxVersion: VersionTLS12, |
| 7391 | Bugs: ProtocolBugs{ |
| 7392 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7393 | }, |
| 7394 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7395 | shouldFail: true, |
| 7396 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7397 | }) |
| 7398 | testCases = append(testCases, testCase{ |
| 7399 | name: "StrayHelloRequest-Packed", |
| 7400 | config: Config{ |
| 7401 | MaxVersion: VersionTLS12, |
| 7402 | Bugs: ProtocolBugs{ |
| 7403 | PackHandshakeFlight: true, |
| 7404 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7405 | }, |
| 7406 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7407 | shouldFail: true, |
| 7408 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7409 | }) |
| 7410 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7411 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7412 | // the same record. |
| 7413 | testCases = append(testCases, testCase{ |
| 7414 | name: "Renegotiate-Client-Packed", |
| 7415 | config: Config{ |
| 7416 | MaxVersion: VersionTLS12, |
| 7417 | Bugs: ProtocolBugs{ |
| 7418 | PackHandshakeFlight: true, |
| 7419 | PackHelloRequestWithFinished: true, |
| 7420 | }, |
| 7421 | }, |
| 7422 | renegotiate: 1, |
| 7423 | flags: []string{ |
| 7424 | "-renegotiate-freely", |
| 7425 | "-expect-total-renegotiations", "1", |
| 7426 | }, |
| 7427 | }) |
| 7428 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7429 | // Renegotiation is forbidden in TLS 1.3. |
| 7430 | testCases = append(testCases, testCase{ |
| 7431 | name: "Renegotiate-Client-TLS13", |
| 7432 | config: Config{ |
| 7433 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7434 | Bugs: ProtocolBugs{ |
| 7435 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7436 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7437 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7438 | flags: []string{ |
| 7439 | "-renegotiate-freely", |
| 7440 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7441 | shouldFail: true, |
| 7442 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7443 | }) |
| 7444 | |
| 7445 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7446 | testCases = append(testCases, testCase{ |
| 7447 | name: "StrayHelloRequest-TLS13", |
| 7448 | config: Config{ |
| 7449 | MaxVersion: VersionTLS13, |
| 7450 | Bugs: ProtocolBugs{ |
| 7451 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7452 | }, |
| 7453 | }, |
| 7454 | shouldFail: true, |
| 7455 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7456 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7457 | |
| 7458 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7459 | // always reads as supporting it, regardless of whether it was |
| 7460 | // negotiated. |
| 7461 | testCases = append(testCases, testCase{ |
| 7462 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7463 | config: Config{ |
| 7464 | MaxVersion: VersionTLS13, |
| 7465 | Bugs: ProtocolBugs{ |
| 7466 | NoRenegotiationInfo: true, |
| 7467 | }, |
| 7468 | }, |
| 7469 | flags: []string{ |
| 7470 | "-expect-secure-renegotiation", |
| 7471 | }, |
| 7472 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7473 | |
| 7474 | // Certificates may not change on renegotiation. |
| 7475 | testCases = append(testCases, testCase{ |
| 7476 | name: "Renegotiation-CertificateChange", |
| 7477 | config: Config{ |
| 7478 | MaxVersion: VersionTLS12, |
| 7479 | Certificates: []Certificate{rsaCertificate}, |
| 7480 | Bugs: ProtocolBugs{ |
| 7481 | RenegotiationCertificate: &rsaChainCertificate, |
| 7482 | }, |
| 7483 | }, |
| 7484 | renegotiate: 1, |
| 7485 | flags: []string{"-renegotiate-freely"}, |
| 7486 | shouldFail: true, |
| 7487 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7488 | }) |
| 7489 | testCases = append(testCases, testCase{ |
| 7490 | name: "Renegotiation-CertificateChange-2", |
| 7491 | config: Config{ |
| 7492 | MaxVersion: VersionTLS12, |
| 7493 | Certificates: []Certificate{rsaCertificate}, |
| 7494 | Bugs: ProtocolBugs{ |
| 7495 | RenegotiationCertificate: &rsa1024Certificate, |
| 7496 | }, |
| 7497 | }, |
| 7498 | renegotiate: 1, |
| 7499 | flags: []string{"-renegotiate-freely"}, |
| 7500 | shouldFail: true, |
| 7501 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7502 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7503 | |
| 7504 | // We do not negotiate ALPN after the initial handshake. This is |
| 7505 | // error-prone and only risks bugs in consumers. |
| 7506 | testCases = append(testCases, testCase{ |
| 7507 | testType: clientTest, |
| 7508 | name: "Renegotiation-ForbidALPN", |
| 7509 | config: Config{ |
| 7510 | MaxVersion: VersionTLS12, |
| 7511 | Bugs: ProtocolBugs{ |
| 7512 | // Forcibly negotiate ALPN on both initial and |
| 7513 | // renegotiation handshakes. The test stack will |
| 7514 | // internally check the client does not offer |
| 7515 | // it. |
| 7516 | SendALPN: "foo", |
| 7517 | }, |
| 7518 | }, |
| 7519 | flags: []string{ |
| 7520 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7521 | "-expect-alpn", "foo", |
| 7522 | "-renegotiate-freely", |
| 7523 | }, |
| 7524 | renegotiate: 1, |
| 7525 | shouldFail: true, |
| 7526 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7527 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7528 | } |
| 7529 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7530 | func addDTLSReplayTests() { |
| 7531 | // Test that sequence number replays are detected. |
| 7532 | testCases = append(testCases, testCase{ |
| 7533 | protocol: dtls, |
| 7534 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7535 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7536 | replayWrites: true, |
| 7537 | }) |
| 7538 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7539 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7540 | // than the retransmit window. |
| 7541 | testCases = append(testCases, testCase{ |
| 7542 | protocol: dtls, |
| 7543 | name: "DTLS-Replay-LargeGaps", |
| 7544 | config: Config{ |
| 7545 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7546 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7547 | return in * 127 |
| 7548 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7549 | }, |
| 7550 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7551 | messageCount: 200, |
| 7552 | replayWrites: true, |
| 7553 | }) |
| 7554 | |
| 7555 | // Test the incoming sequence number changing non-monotonically. |
| 7556 | testCases = append(testCases, testCase{ |
| 7557 | protocol: dtls, |
| 7558 | name: "DTLS-Replay-NonMonotonic", |
| 7559 | config: Config{ |
| 7560 | Bugs: ProtocolBugs{ |
| 7561 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7562 | return in ^ 31 |
| 7563 | }, |
| 7564 | }, |
| 7565 | }, |
| 7566 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7567 | replayWrites: true, |
| 7568 | }) |
| 7569 | } |
| 7570 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7571 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7572 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7573 | id signatureAlgorithm |
| 7574 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7575 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7576 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7577 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7578 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7579 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7580 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7581 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7582 | // hash function doesn't have to match the curve and so the same |
| 7583 | // signature algorithm works with P-224. |
| 7584 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7585 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7586 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7587 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7588 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7589 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7590 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7591 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7592 | // Tests for key types prior to TLS 1.2. |
| 7593 | {"RSA", 0, testCertRSA}, |
| 7594 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7595 | } |
| 7596 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7597 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7598 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7599 | |
| 7600 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7601 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7602 | // versions a signing cipher. |
| 7603 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7604 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7605 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7606 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7607 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7608 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7609 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7610 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7611 | var allAlgorithms []signatureAlgorithm |
| 7612 | for _, alg := range testSignatureAlgorithms { |
| 7613 | if alg.id != 0 { |
| 7614 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7615 | } |
| 7616 | } |
| 7617 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7618 | // Make sure each signature algorithm works. Include some fake values in |
| 7619 | // the list and ensure they're ignored. |
| 7620 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7621 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7622 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7623 | continue |
| 7624 | } |
| 7625 | |
| 7626 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7627 | // or remove it in C. |
| 7628 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7629 | continue |
| 7630 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7631 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7632 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7633 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7634 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7635 | shouldSignFail = true |
| 7636 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7637 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7638 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7639 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7640 | shouldSignFail = true |
| 7641 | shouldVerifyFail = true |
| 7642 | } |
| 7643 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7644 | // the curve has to match the hash size. |
| 7645 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7646 | shouldSignFail = true |
| 7647 | shouldVerifyFail = true |
| 7648 | } |
| 7649 | |
| 7650 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7651 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7652 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7653 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7654 | |
| 7655 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7656 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7657 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7658 | } |
| 7659 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7660 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7661 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7662 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7663 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7664 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7665 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7666 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7667 | config: Config{ |
| 7668 | MaxVersion: ver.version, |
| 7669 | ClientAuth: RequireAnyClientCert, |
| 7670 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7671 | fakeSigAlg1, |
| 7672 | alg.id, |
| 7673 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7674 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7675 | }, |
| 7676 | flags: []string{ |
| 7677 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7678 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7679 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7680 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7681 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7682 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7683 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7684 | expectedError: signError, |
| 7685 | expectedPeerSignatureAlgorithm: alg.id, |
| 7686 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7687 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7688 | testCases = append(testCases, testCase{ |
| 7689 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7690 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7691 | config: Config{ |
| 7692 | MaxVersion: ver.version, |
| 7693 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7694 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7695 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7696 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7697 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7698 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7699 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7700 | // Some signature algorithms may not be advertised. |
| 7701 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7702 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7703 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7704 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7705 | flags: []string{ |
| 7706 | "-require-any-client-certificate", |
| 7707 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7708 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7709 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7710 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7711 | // Resume the session to assert the peer signature |
| 7712 | // algorithm is reported on both handshakes. |
| 7713 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7714 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7715 | expectedError: verifyError, |
| 7716 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7717 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7718 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7719 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7720 | testCases = append(testCases, testCase{ |
| 7721 | testType: serverTest, |
| 7722 | name: "ServerAuth-Sign" + suffix, |
| 7723 | config: Config{ |
| 7724 | MaxVersion: ver.version, |
| 7725 | CipherSuites: signingCiphers, |
| 7726 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7727 | fakeSigAlg1, |
| 7728 | alg.id, |
| 7729 | fakeSigAlg2, |
| 7730 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7731 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7732 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7733 | flags: []string{ |
| 7734 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7735 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7736 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7737 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7738 | }, |
| 7739 | shouldFail: shouldSignFail, |
| 7740 | expectedError: signError, |
| 7741 | expectedPeerSignatureAlgorithm: alg.id, |
| 7742 | }) |
| 7743 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7744 | |
| 7745 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7746 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7747 | config: Config{ |
| 7748 | MaxVersion: ver.version, |
| 7749 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7750 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7751 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7752 | alg.id, |
| 7753 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7754 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7755 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7756 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7757 | // Some signature algorithms may not be advertised. |
| 7758 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7759 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7760 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7761 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7762 | flags: []string{ |
| 7763 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7764 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7765 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7766 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7767 | // Resume the session to assert the peer signature |
| 7768 | // algorithm is reported on both handshakes. |
| 7769 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7770 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7771 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7772 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7773 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7774 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7775 | testCases = append(testCases, testCase{ |
| 7776 | testType: serverTest, |
| 7777 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7778 | config: Config{ |
| 7779 | MaxVersion: ver.version, |
| 7780 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7781 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7782 | alg.id, |
| 7783 | }, |
| 7784 | Bugs: ProtocolBugs{ |
| 7785 | InvalidSignature: true, |
| 7786 | }, |
| 7787 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7788 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7789 | flags: []string{ |
| 7790 | "-require-any-client-certificate", |
| 7791 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7792 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7793 | }, |
| 7794 | shouldFail: true, |
| 7795 | expectedError: ":BAD_SIGNATURE:", |
| 7796 | }) |
| 7797 | |
| 7798 | testCases = append(testCases, testCase{ |
| 7799 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7800 | config: Config{ |
| 7801 | MaxVersion: ver.version, |
| 7802 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7803 | CipherSuites: signingCiphers, |
| 7804 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7805 | alg.id, |
| 7806 | }, |
| 7807 | Bugs: ProtocolBugs{ |
| 7808 | InvalidSignature: true, |
| 7809 | }, |
| 7810 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7811 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7812 | flags: []string{ |
| 7813 | "-enable-all-curves", |
| 7814 | "-enable-ed25519", |
| 7815 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7816 | shouldFail: true, |
| 7817 | expectedError: ":BAD_SIGNATURE:", |
| 7818 | }) |
| 7819 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7820 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7821 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7822 | testCases = append(testCases, testCase{ |
| 7823 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7824 | config: Config{ |
| 7825 | MaxVersion: ver.version, |
| 7826 | ClientAuth: RequireAnyClientCert, |
| 7827 | VerifySignatureAlgorithms: allAlgorithms, |
| 7828 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7829 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7830 | flags: []string{ |
| 7831 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7832 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7833 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7834 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7835 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7836 | }, |
| 7837 | expectedPeerSignatureAlgorithm: alg.id, |
| 7838 | }) |
| 7839 | |
| 7840 | testCases = append(testCases, testCase{ |
| 7841 | testType: serverTest, |
| 7842 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7843 | config: Config{ |
| 7844 | MaxVersion: ver.version, |
| 7845 | CipherSuites: signingCiphers, |
| 7846 | VerifySignatureAlgorithms: allAlgorithms, |
| 7847 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7848 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7849 | flags: []string{ |
| 7850 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7851 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7852 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7853 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7854 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7855 | }, |
| 7856 | expectedPeerSignatureAlgorithm: alg.id, |
| 7857 | }) |
| 7858 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7859 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7860 | } |
| 7861 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7862 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7863 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7864 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7865 | config: Config{ |
| 7866 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7867 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7868 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7869 | signatureECDSAWithP521AndSHA512, |
| 7870 | signatureRSAPKCS1WithSHA384, |
| 7871 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7872 | }, |
| 7873 | }, |
| 7874 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7875 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7876 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7877 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7878 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7879 | }) |
| 7880 | |
| 7881 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7882 | name: "ClientAuth-SignatureType-TLS13", |
| 7883 | config: Config{ |
| 7884 | ClientAuth: RequireAnyClientCert, |
| 7885 | MaxVersion: VersionTLS13, |
| 7886 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7887 | signatureECDSAWithP521AndSHA512, |
| 7888 | signatureRSAPKCS1WithSHA384, |
| 7889 | signatureRSAPSSWithSHA384, |
| 7890 | signatureECDSAWithSHA1, |
| 7891 | }, |
| 7892 | }, |
| 7893 | flags: []string{ |
| 7894 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7895 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7896 | }, |
| 7897 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7898 | }) |
| 7899 | |
| 7900 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7901 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7902 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7903 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7904 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7905 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7906 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7907 | signatureECDSAWithP521AndSHA512, |
| 7908 | signatureRSAPKCS1WithSHA384, |
| 7909 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7910 | }, |
| 7911 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7912 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7913 | }) |
| 7914 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7915 | testCases = append(testCases, testCase{ |
| 7916 | testType: serverTest, |
| 7917 | name: "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 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7921 | signatureECDSAWithP521AndSHA512, |
| 7922 | signatureRSAPKCS1WithSHA384, |
| 7923 | signatureRSAPSSWithSHA384, |
| 7924 | signatureECDSAWithSHA1, |
| 7925 | }, |
| 7926 | }, |
| 7927 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7928 | }) |
| 7929 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7930 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7931 | testCases = append(testCases, testCase{ |
| 7932 | testType: serverTest, |
| 7933 | name: "Verify-ClientAuth-SignatureType", |
| 7934 | config: Config{ |
| 7935 | MaxVersion: VersionTLS12, |
| 7936 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7937 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7938 | signatureRSAPKCS1WithSHA256, |
| 7939 | }, |
| 7940 | Bugs: ProtocolBugs{ |
| 7941 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7942 | }, |
| 7943 | }, |
| 7944 | flags: []string{ |
| 7945 | "-require-any-client-certificate", |
| 7946 | }, |
| 7947 | shouldFail: true, |
| 7948 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7949 | }) |
| 7950 | |
| 7951 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7952 | testType: serverTest, |
| 7953 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7954 | config: Config{ |
| 7955 | MaxVersion: VersionTLS13, |
| 7956 | Certificates: []Certificate{rsaCertificate}, |
| 7957 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7958 | signatureRSAPSSWithSHA256, |
| 7959 | }, |
| 7960 | Bugs: ProtocolBugs{ |
| 7961 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7962 | }, |
| 7963 | }, |
| 7964 | flags: []string{ |
| 7965 | "-require-any-client-certificate", |
| 7966 | }, |
| 7967 | shouldFail: true, |
| 7968 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7969 | }) |
| 7970 | |
| 7971 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7972 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7973 | config: Config{ |
| 7974 | MaxVersion: VersionTLS12, |
| 7975 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7976 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7977 | signatureRSAPKCS1WithSHA256, |
| 7978 | }, |
| 7979 | Bugs: ProtocolBugs{ |
| 7980 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7981 | }, |
| 7982 | }, |
| 7983 | shouldFail: true, |
| 7984 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7985 | }) |
| 7986 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7987 | testCases = append(testCases, testCase{ |
| 7988 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7989 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7990 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7991 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7992 | signatureRSAPSSWithSHA256, |
| 7993 | }, |
| 7994 | Bugs: ProtocolBugs{ |
| 7995 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7996 | }, |
| 7997 | }, |
| 7998 | shouldFail: true, |
| 7999 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8000 | }) |
| 8001 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8002 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 8003 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8004 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8005 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8006 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8007 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8008 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8009 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8010 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8011 | }, |
| 8012 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8013 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8014 | }, |
| 8015 | }, |
| 8016 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8017 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8018 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8019 | }, |
| 8020 | }) |
| 8021 | |
| 8022 | testCases = append(testCases, testCase{ |
| 8023 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8024 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8025 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8026 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8027 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8028 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8029 | }, |
| 8030 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8031 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8032 | }, |
| 8033 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8034 | flags: []string{ |
| 8035 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8036 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8037 | }, |
| 8038 | }) |
| 8039 | |
| 8040 | testCases = append(testCases, testCase{ |
| 8041 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 8042 | config: Config{ |
| 8043 | MaxVersion: VersionTLS12, |
| 8044 | ClientAuth: RequireAnyClientCert, |
| 8045 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8046 | signatureECDSAWithSHA1, |
| 8047 | }, |
| 8048 | Bugs: ProtocolBugs{ |
| 8049 | NoSignatureAlgorithms: true, |
| 8050 | }, |
| 8051 | }, |
| 8052 | flags: []string{ |
| 8053 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8054 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8055 | }, |
| 8056 | }) |
| 8057 | |
| 8058 | testCases = append(testCases, testCase{ |
| 8059 | testType: serverTest, |
| 8060 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 8061 | config: Config{ |
| 8062 | MaxVersion: VersionTLS12, |
| 8063 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8064 | signatureECDSAWithSHA1, |
| 8065 | }, |
| 8066 | Bugs: ProtocolBugs{ |
| 8067 | NoSignatureAlgorithms: true, |
| 8068 | }, |
| 8069 | }, |
| 8070 | flags: []string{ |
| 8071 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8072 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8073 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8074 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8075 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8076 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8077 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8078 | config: Config{ |
| 8079 | MaxVersion: VersionTLS13, |
| 8080 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8081 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8082 | signatureRSAPKCS1WithSHA1, |
| 8083 | }, |
| 8084 | Bugs: ProtocolBugs{ |
| 8085 | NoSignatureAlgorithms: true, |
| 8086 | }, |
| 8087 | }, |
| 8088 | flags: []string{ |
| 8089 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8090 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8091 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8092 | shouldFail: true, |
| 8093 | // An empty CertificateRequest signature algorithm list is a |
| 8094 | // syntax error in TLS 1.3. |
| 8095 | expectedError: ":DECODE_ERROR:", |
| 8096 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8097 | }) |
| 8098 | |
| 8099 | testCases = append(testCases, testCase{ |
| 8100 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8101 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8102 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8103 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8104 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8105 | signatureRSAPKCS1WithSHA1, |
| 8106 | }, |
| 8107 | Bugs: ProtocolBugs{ |
| 8108 | NoSignatureAlgorithms: true, |
| 8109 | }, |
| 8110 | }, |
| 8111 | shouldFail: true, |
| 8112 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8113 | }) |
| 8114 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8115 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8116 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8117 | testCases = append(testCases, testCase{ |
| 8118 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8119 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8120 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8121 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8122 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8123 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8124 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8125 | }, |
| 8126 | Bugs: ProtocolBugs{ |
| 8127 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8128 | }, |
| 8129 | }, |
| 8130 | flags: []string{"-require-any-client-certificate"}, |
| 8131 | shouldFail: true, |
| 8132 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8133 | }) |
| 8134 | |
| 8135 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8136 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8137 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8138 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8139 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8140 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8141 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8142 | }, |
| 8143 | Bugs: ProtocolBugs{ |
| 8144 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8145 | }, |
| 8146 | }, |
| 8147 | shouldFail: true, |
| 8148 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8149 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8150 | testCases = append(testCases, testCase{ |
| 8151 | testType: serverTest, |
| 8152 | name: "ClientAuth-Enforced-TLS13", |
| 8153 | config: Config{ |
| 8154 | MaxVersion: VersionTLS13, |
| 8155 | Certificates: []Certificate{rsaCertificate}, |
| 8156 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8157 | signatureRSAPKCS1WithMD5, |
| 8158 | }, |
| 8159 | Bugs: ProtocolBugs{ |
| 8160 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8161 | IgnoreSignatureVersionChecks: true, |
| 8162 | }, |
| 8163 | }, |
| 8164 | flags: []string{"-require-any-client-certificate"}, |
| 8165 | shouldFail: true, |
| 8166 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8167 | }) |
| 8168 | |
| 8169 | testCases = append(testCases, testCase{ |
| 8170 | name: "ServerAuth-Enforced-TLS13", |
| 8171 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8172 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8173 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8174 | signatureRSAPKCS1WithMD5, |
| 8175 | }, |
| 8176 | Bugs: ProtocolBugs{ |
| 8177 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8178 | IgnoreSignatureVersionChecks: true, |
| 8179 | }, |
| 8180 | }, |
| 8181 | shouldFail: true, |
| 8182 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8183 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8184 | |
| 8185 | // Test that the agreed upon digest respects the client preferences and |
| 8186 | // the server digests. |
| 8187 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8188 | name: "NoCommonAlgorithms-Digests", |
| 8189 | config: Config{ |
| 8190 | MaxVersion: VersionTLS12, |
| 8191 | ClientAuth: RequireAnyClientCert, |
| 8192 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8193 | signatureRSAPKCS1WithSHA512, |
| 8194 | signatureRSAPKCS1WithSHA1, |
| 8195 | }, |
| 8196 | }, |
| 8197 | flags: []string{ |
| 8198 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8199 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8200 | "-digest-prefs", "SHA256", |
| 8201 | }, |
| 8202 | shouldFail: true, |
| 8203 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8204 | }) |
| 8205 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8206 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8207 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8208 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8209 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8210 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8211 | signatureRSAPKCS1WithSHA512, |
| 8212 | signatureRSAPKCS1WithSHA1, |
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), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8218 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8219 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8220 | shouldFail: true, |
| 8221 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8222 | }) |
| 8223 | testCases = append(testCases, testCase{ |
| 8224 | name: "NoCommonAlgorithms-TLS13", |
| 8225 | config: Config{ |
| 8226 | MaxVersion: VersionTLS13, |
| 8227 | ClientAuth: RequireAnyClientCert, |
| 8228 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8229 | signatureRSAPSSWithSHA512, |
| 8230 | signatureRSAPSSWithSHA384, |
| 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(signatureRSAPSSWithSHA256)), |
| 8237 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8238 | shouldFail: true, |
| 8239 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8240 | }) |
| 8241 | testCases = append(testCases, testCase{ |
| 8242 | name: "Agree-Digest-SHA256", |
| 8243 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8244 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8245 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8246 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8247 | signatureRSAPKCS1WithSHA1, |
| 8248 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8249 | }, |
| 8250 | }, |
| 8251 | flags: []string{ |
| 8252 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8253 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8254 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8255 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8256 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8257 | }) |
| 8258 | testCases = append(testCases, testCase{ |
| 8259 | name: "Agree-Digest-SHA1", |
| 8260 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8261 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8262 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8263 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8264 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8265 | }, |
| 8266 | }, |
| 8267 | flags: []string{ |
| 8268 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8269 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8270 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8271 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8272 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8273 | }) |
| 8274 | testCases = append(testCases, testCase{ |
| 8275 | name: "Agree-Digest-Default", |
| 8276 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8277 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8278 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8279 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8280 | signatureRSAPKCS1WithSHA256, |
| 8281 | signatureECDSAWithP256AndSHA256, |
| 8282 | signatureRSAPKCS1WithSHA1, |
| 8283 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8284 | }, |
| 8285 | }, |
| 8286 | flags: []string{ |
| 8287 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8288 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8289 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8290 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8291 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8292 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8293 | // Test that the signing preference list may include extra algorithms |
| 8294 | // without negotiation problems. |
| 8295 | testCases = append(testCases, testCase{ |
| 8296 | testType: serverTest, |
| 8297 | name: "FilterExtraAlgorithms", |
| 8298 | config: Config{ |
| 8299 | MaxVersion: VersionTLS12, |
| 8300 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8301 | signatureRSAPKCS1WithSHA256, |
| 8302 | }, |
| 8303 | }, |
| 8304 | flags: []string{ |
| 8305 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8306 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8307 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8308 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8309 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8310 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8311 | }, |
| 8312 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8313 | }) |
| 8314 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8315 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8316 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8317 | testCases = append(testCases, testCase{ |
| 8318 | name: "CheckLeafCurve", |
| 8319 | config: Config{ |
| 8320 | MaxVersion: VersionTLS12, |
| 8321 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8322 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8323 | }, |
| 8324 | flags: []string{"-p384-only"}, |
| 8325 | shouldFail: true, |
| 8326 | expectedError: ":BAD_ECC_CERT:", |
| 8327 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8328 | |
| 8329 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8330 | testCases = append(testCases, testCase{ |
| 8331 | name: "CheckLeafCurve-TLS13", |
| 8332 | config: Config{ |
| 8333 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8334 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8335 | }, |
| 8336 | flags: []string{"-p384-only"}, |
| 8337 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8338 | |
| 8339 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8340 | testCases = append(testCases, testCase{ |
| 8341 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8342 | config: Config{ |
| 8343 | MaxVersion: VersionTLS12, |
| 8344 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8345 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8346 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8347 | signatureECDSAWithP384AndSHA384, |
| 8348 | }, |
| 8349 | }, |
| 8350 | }) |
| 8351 | |
| 8352 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8353 | testCases = append(testCases, testCase{ |
| 8354 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8355 | config: Config{ |
| 8356 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8357 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8358 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8359 | signatureECDSAWithP384AndSHA384, |
| 8360 | }, |
| 8361 | Bugs: ProtocolBugs{ |
| 8362 | SkipECDSACurveCheck: true, |
| 8363 | }, |
| 8364 | }, |
| 8365 | shouldFail: true, |
| 8366 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8367 | }) |
| 8368 | |
| 8369 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8370 | // account. |
| 8371 | testCases = append(testCases, testCase{ |
| 8372 | testType: serverTest, |
| 8373 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8374 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8375 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8376 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8377 | signatureECDSAWithP384AndSHA384, |
| 8378 | signatureECDSAWithP256AndSHA256, |
| 8379 | }, |
| 8380 | }, |
| 8381 | flags: []string{ |
| 8382 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8383 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8384 | }, |
| 8385 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8386 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8387 | |
| 8388 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8389 | // server does not attempt to sign in that case. |
| 8390 | testCases = append(testCases, testCase{ |
| 8391 | testType: serverTest, |
| 8392 | name: "RSA-PSS-Large", |
| 8393 | config: Config{ |
| 8394 | MaxVersion: VersionTLS13, |
| 8395 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8396 | signatureRSAPSSWithSHA512, |
| 8397 | }, |
| 8398 | }, |
| 8399 | flags: []string{ |
| 8400 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8401 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8402 | }, |
| 8403 | shouldFail: true, |
| 8404 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8405 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8406 | |
| 8407 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8408 | testCases = append(testCases, testCase{ |
| 8409 | testType: clientTest, |
| 8410 | name: "RSA-PSS-Default-Verify", |
| 8411 | config: Config{ |
| 8412 | MaxVersion: VersionTLS12, |
| 8413 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8414 | signatureRSAPSSWithSHA256, |
| 8415 | }, |
| 8416 | }, |
| 8417 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8418 | }) |
| 8419 | |
| 8420 | testCases = append(testCases, testCase{ |
| 8421 | testType: serverTest, |
| 8422 | name: "RSA-PSS-Default-Sign", |
| 8423 | config: Config{ |
| 8424 | MaxVersion: VersionTLS12, |
| 8425 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8426 | signatureRSAPSSWithSHA256, |
| 8427 | }, |
| 8428 | }, |
| 8429 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8430 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8431 | |
| 8432 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8433 | // Ed25519's signature algorithm. |
| 8434 | testCases = append(testCases, testCase{ |
| 8435 | testType: clientTest, |
| 8436 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8437 | config: Config{ |
| 8438 | MaxVersion: VersionTLS11, |
| 8439 | Certificates: []Certificate{ed25519Certificate}, |
| 8440 | Bugs: ProtocolBugs{ |
| 8441 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8442 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8443 | }, |
| 8444 | }, |
| 8445 | flags: []string{"-enable-ed25519"}, |
| 8446 | shouldFail: true, |
| 8447 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8448 | }) |
| 8449 | testCases = append(testCases, testCase{ |
| 8450 | testType: serverTest, |
| 8451 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8452 | config: Config{ |
| 8453 | MaxVersion: VersionTLS11, |
| 8454 | }, |
| 8455 | flags: []string{ |
| 8456 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8457 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8458 | }, |
| 8459 | shouldFail: true, |
| 8460 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8461 | }) |
| 8462 | testCases = append(testCases, testCase{ |
| 8463 | testType: serverTest, |
| 8464 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8465 | config: Config{ |
| 8466 | MaxVersion: VersionTLS11, |
| 8467 | Certificates: []Certificate{ed25519Certificate}, |
| 8468 | Bugs: ProtocolBugs{ |
| 8469 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8470 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8471 | }, |
| 8472 | }, |
| 8473 | flags: []string{ |
| 8474 | "-enable-ed25519", |
| 8475 | "-require-any-client-certificate", |
| 8476 | }, |
| 8477 | shouldFail: true, |
| 8478 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8479 | }) |
| 8480 | testCases = append(testCases, testCase{ |
| 8481 | testType: clientTest, |
| 8482 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8483 | config: Config{ |
| 8484 | MaxVersion: VersionTLS11, |
| 8485 | ClientAuth: RequireAnyClientCert, |
| 8486 | }, |
| 8487 | flags: []string{ |
| 8488 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8489 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8490 | }, |
| 8491 | shouldFail: true, |
| 8492 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8493 | }) |
| 8494 | |
| 8495 | // Test Ed25519 is not advertised by default. |
| 8496 | testCases = append(testCases, testCase{ |
| 8497 | testType: clientTest, |
| 8498 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8499 | config: Config{ |
| 8500 | Certificates: []Certificate{ed25519Certificate}, |
| 8501 | }, |
| 8502 | shouldFail: true, |
| 8503 | expectedLocalError: "tls: no common signature algorithms", |
| 8504 | }) |
| 8505 | |
| 8506 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8507 | // preferences. |
| 8508 | testCases = append(testCases, testCase{ |
| 8509 | testType: clientTest, |
| 8510 | name: "Ed25519DefaultDisable-NoAccept", |
| 8511 | config: Config{ |
| 8512 | Certificates: []Certificate{ed25519Certificate}, |
| 8513 | Bugs: ProtocolBugs{ |
| 8514 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8515 | }, |
| 8516 | }, |
| 8517 | shouldFail: true, |
| 8518 | expectedLocalError: "remote error: illegal parameter", |
| 8519 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8520 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8521 | |
| 8522 | // Test that configuring verify preferences changes what the client |
| 8523 | // advertises. |
| 8524 | testCases = append(testCases, testCase{ |
| 8525 | name: "VerifyPreferences-Advertised", |
| 8526 | config: Config{ |
| 8527 | Certificates: []Certificate{rsaCertificate}, |
| 8528 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8529 | signatureRSAPSSWithSHA256, |
| 8530 | signatureRSAPSSWithSHA384, |
| 8531 | signatureRSAPSSWithSHA512, |
| 8532 | }, |
| 8533 | }, |
| 8534 | flags: []string{ |
| 8535 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8536 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8537 | }, |
| 8538 | }) |
| 8539 | |
| 8540 | // Test that the client advertises a set which the runner can find |
| 8541 | // nothing in common with. |
| 8542 | testCases = append(testCases, testCase{ |
| 8543 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8544 | config: Config{ |
| 8545 | Certificates: []Certificate{rsaCertificate}, |
| 8546 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8547 | signatureRSAPSSWithSHA256, |
| 8548 | signatureRSAPSSWithSHA512, |
| 8549 | }, |
| 8550 | }, |
| 8551 | flags: []string{ |
| 8552 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8553 | }, |
| 8554 | shouldFail: true, |
| 8555 | expectedLocalError: "tls: no common signature algorithms", |
| 8556 | }) |
| 8557 | |
| 8558 | // Test that the client enforces its preferences when configured. |
| 8559 | testCases = append(testCases, testCase{ |
| 8560 | name: "VerifyPreferences-Enforced", |
| 8561 | config: Config{ |
| 8562 | Certificates: []Certificate{rsaCertificate}, |
| 8563 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8564 | signatureRSAPSSWithSHA256, |
| 8565 | signatureRSAPSSWithSHA512, |
| 8566 | }, |
| 8567 | Bugs: ProtocolBugs{ |
| 8568 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8569 | }, |
| 8570 | }, |
| 8571 | flags: []string{ |
| 8572 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8573 | }, |
| 8574 | shouldFail: true, |
| 8575 | expectedLocalError: "remote error: illegal parameter", |
| 8576 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8577 | }) |
| 8578 | |
| 8579 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8580 | // boolean toggle. |
| 8581 | testCases = append(testCases, testCase{ |
| 8582 | name: "VerifyPreferences-Ed25519", |
| 8583 | config: Config{ |
| 8584 | Certificates: []Certificate{ed25519Certificate}, |
| 8585 | }, |
| 8586 | flags: []string{ |
| 8587 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8588 | }, |
| 8589 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8590 | } |
| 8591 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8592 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8593 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8594 | var timeouts = []time.Duration{ |
| 8595 | 1 * time.Second, |
| 8596 | 2 * time.Second, |
| 8597 | 4 * time.Second, |
| 8598 | 8 * time.Second, |
| 8599 | 16 * time.Second, |
| 8600 | 32 * time.Second, |
| 8601 | 60 * time.Second, |
| 8602 | 60 * time.Second, |
| 8603 | 60 * time.Second, |
| 8604 | 60 * time.Second, |
| 8605 | 60 * time.Second, |
| 8606 | 60 * time.Second, |
| 8607 | 60 * time.Second, |
| 8608 | } |
| 8609 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8610 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8611 | // initial timeout duration was set to 250ms. |
| 8612 | var shortTimeouts = []time.Duration{ |
| 8613 | 250 * time.Millisecond, |
| 8614 | 500 * time.Millisecond, |
| 8615 | 1 * time.Second, |
| 8616 | 2 * time.Second, |
| 8617 | 4 * time.Second, |
| 8618 | 8 * time.Second, |
| 8619 | 16 * time.Second, |
| 8620 | 32 * time.Second, |
| 8621 | 60 * time.Second, |
| 8622 | 60 * time.Second, |
| 8623 | 60 * time.Second, |
| 8624 | 60 * time.Second, |
| 8625 | 60 * time.Second, |
| 8626 | } |
| 8627 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8628 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8629 | // These tests work by coordinating some behavior on both the shim and |
| 8630 | // the runner. |
| 8631 | // |
| 8632 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8633 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8634 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8635 | // timeout in the shim and acts as a synchronization point to help the |
| 8636 | // runner bracket each handshake flight. |
| 8637 | // |
| 8638 | // We assume the shim does not read from the channel eagerly. It must |
| 8639 | // first wait until it has sent flight N and is ready to receive |
| 8640 | // handshake flight N+1. At this point, it will process the timeout |
| 8641 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8642 | // as if the shim was idle for the specified amount of time. |
| 8643 | // |
| 8644 | // The runner then drops all packets received before the ACK and |
| 8645 | // continues waiting for flight N. This ordering results in one attempt |
| 8646 | // at sending flight N to be dropped. For the test to complete, the |
| 8647 | // shim must send flight N again, testing that the shim implements DTLS |
| 8648 | // retransmit on a timeout. |
| 8649 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8650 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8651 | // likely be more epochs to cross and the final message's retransmit may |
| 8652 | // be more complex. |
| 8653 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8654 | // Test that this is indeed the timeout schedule. Stress all |
| 8655 | // four patterns of handshake. |
| 8656 | for i := 1; i < len(timeouts); i++ { |
| 8657 | number := strconv.Itoa(i) |
| 8658 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8659 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8660 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8661 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8662 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8663 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8664 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8665 | }, |
| 8666 | }, |
| 8667 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8668 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8669 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8670 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8671 | protocol: dtls, |
| 8672 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8673 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8674 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8675 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8676 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8677 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8678 | }, |
| 8679 | }, |
| 8680 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8681 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8682 | }) |
| 8683 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8684 | |
| 8685 | // Test that exceeding the timeout schedule hits a read |
| 8686 | // timeout. |
| 8687 | testCases = append(testCases, testCase{ |
| 8688 | protocol: dtls, |
| 8689 | name: "DTLS-Retransmit-Timeout", |
| 8690 | config: Config{ |
| 8691 | MaxVersion: VersionTLS12, |
| 8692 | Bugs: ProtocolBugs{ |
| 8693 | TimeoutSchedule: timeouts, |
| 8694 | }, |
| 8695 | }, |
| 8696 | resumeSession: true, |
| 8697 | flags: []string{"-async"}, |
| 8698 | shouldFail: true, |
| 8699 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8700 | }) |
| 8701 | |
| 8702 | // Test that timeout handling has a fudge factor, due to API |
| 8703 | // problems. |
| 8704 | testCases = append(testCases, testCase{ |
| 8705 | protocol: dtls, |
| 8706 | name: "DTLS-Retransmit-Fudge", |
| 8707 | config: Config{ |
| 8708 | MaxVersion: VersionTLS12, |
| 8709 | Bugs: ProtocolBugs{ |
| 8710 | TimeoutSchedule: []time.Duration{ |
| 8711 | timeouts[0] - 10*time.Millisecond, |
| 8712 | }, |
| 8713 | }, |
| 8714 | }, |
| 8715 | resumeSession: true, |
| 8716 | flags: []string{"-async"}, |
| 8717 | }) |
| 8718 | |
| 8719 | // Test that the final Finished retransmitting isn't |
| 8720 | // duplicated if the peer badly fragments everything. |
| 8721 | testCases = append(testCases, testCase{ |
| 8722 | testType: serverTest, |
| 8723 | protocol: dtls, |
| 8724 | name: "DTLS-Retransmit-Fragmented", |
| 8725 | config: Config{ |
| 8726 | MaxVersion: VersionTLS12, |
| 8727 | Bugs: ProtocolBugs{ |
| 8728 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8729 | MaxHandshakeRecordLength: 2, |
| 8730 | }, |
| 8731 | }, |
| 8732 | flags: []string{"-async"}, |
| 8733 | }) |
| 8734 | |
| 8735 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8736 | testCases = append(testCases, testCase{ |
| 8737 | protocol: dtls, |
| 8738 | name: "DTLS-Retransmit-Short-Client", |
| 8739 | config: Config{ |
| 8740 | MaxVersion: VersionTLS12, |
| 8741 | Bugs: ProtocolBugs{ |
| 8742 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8743 | }, |
| 8744 | }, |
| 8745 | resumeSession: true, |
| 8746 | flags: []string{ |
| 8747 | "-async", |
| 8748 | "-initial-timeout-duration-ms", "250", |
| 8749 | }, |
| 8750 | }) |
| 8751 | testCases = append(testCases, testCase{ |
| 8752 | protocol: dtls, |
| 8753 | testType: serverTest, |
| 8754 | name: "DTLS-Retransmit-Short-Server", |
| 8755 | config: Config{ |
| 8756 | MaxVersion: VersionTLS12, |
| 8757 | Bugs: ProtocolBugs{ |
| 8758 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8759 | }, |
| 8760 | }, |
| 8761 | resumeSession: true, |
| 8762 | flags: []string{ |
| 8763 | "-async", |
| 8764 | "-initial-timeout-duration-ms", "250", |
| 8765 | }, |
| 8766 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8767 | } |
| 8768 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8769 | func addExportKeyingMaterialTests() { |
| 8770 | for _, vers := range tlsVersions { |
| 8771 | if vers.version == VersionSSL30 { |
| 8772 | continue |
| 8773 | } |
| 8774 | testCases = append(testCases, testCase{ |
| 8775 | name: "ExportKeyingMaterial-" + vers.name, |
| 8776 | config: Config{ |
| 8777 | MaxVersion: vers.version, |
| 8778 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8779 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8780 | exportKeyingMaterial: 1024, |
| 8781 | exportLabel: "label", |
| 8782 | exportContext: "context", |
| 8783 | useExportContext: true, |
| 8784 | }) |
| 8785 | testCases = append(testCases, testCase{ |
| 8786 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8787 | config: Config{ |
| 8788 | MaxVersion: vers.version, |
| 8789 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8790 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8791 | exportKeyingMaterial: 1024, |
| 8792 | }) |
| 8793 | testCases = append(testCases, testCase{ |
| 8794 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8795 | config: Config{ |
| 8796 | MaxVersion: vers.version, |
| 8797 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8798 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8799 | exportKeyingMaterial: 1024, |
| 8800 | useExportContext: true, |
| 8801 | }) |
| 8802 | testCases = append(testCases, testCase{ |
| 8803 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8804 | config: Config{ |
| 8805 | MaxVersion: vers.version, |
| 8806 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8807 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8808 | exportKeyingMaterial: 1, |
| 8809 | exportLabel: "label", |
| 8810 | exportContext: "context", |
| 8811 | useExportContext: true, |
| 8812 | }) |
| 8813 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8814 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8815 | testCases = append(testCases, testCase{ |
| 8816 | name: "ExportKeyingMaterial-SSL3", |
| 8817 | config: Config{ |
| 8818 | MaxVersion: VersionSSL30, |
| 8819 | }, |
| 8820 | exportKeyingMaterial: 1024, |
| 8821 | exportLabel: "label", |
| 8822 | exportContext: "context", |
| 8823 | useExportContext: true, |
| 8824 | shouldFail: true, |
| 8825 | expectedError: "failed to export keying material", |
| 8826 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8827 | |
| 8828 | // Exporters work during a False Start. |
| 8829 | testCases = append(testCases, testCase{ |
| 8830 | name: "ExportKeyingMaterial-FalseStart", |
| 8831 | config: Config{ |
| 8832 | MaxVersion: VersionTLS12, |
| 8833 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8834 | NextProtos: []string{"foo"}, |
| 8835 | Bugs: ProtocolBugs{ |
| 8836 | ExpectFalseStart: true, |
| 8837 | }, |
| 8838 | }, |
| 8839 | flags: []string{ |
| 8840 | "-false-start", |
| 8841 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8842 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8843 | }, |
| 8844 | shimWritesFirst: true, |
| 8845 | exportKeyingMaterial: 1024, |
| 8846 | exportLabel: "label", |
| 8847 | exportContext: "context", |
| 8848 | useExportContext: true, |
| 8849 | }) |
| 8850 | |
| 8851 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8852 | // triggering the exporter after every SSL_read call and configuring the |
| 8853 | // shim to run asynchronously. |
| 8854 | testCases = append(testCases, testCase{ |
| 8855 | name: "ExportKeyingMaterial-Renegotiate", |
| 8856 | config: Config{ |
| 8857 | MaxVersion: VersionTLS12, |
| 8858 | }, |
| 8859 | renegotiate: 1, |
| 8860 | flags: []string{ |
| 8861 | "-async", |
| 8862 | "-use-exporter-between-reads", |
| 8863 | "-renegotiate-freely", |
| 8864 | "-expect-total-renegotiations", "1", |
| 8865 | }, |
| 8866 | shouldFail: true, |
| 8867 | expectedError: "failed to export keying material", |
| 8868 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8869 | } |
| 8870 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8871 | func addTLSUniqueTests() { |
| 8872 | for _, isClient := range []bool{false, true} { |
| 8873 | for _, isResumption := range []bool{false, true} { |
| 8874 | for _, hasEMS := range []bool{false, true} { |
| 8875 | var suffix string |
| 8876 | if isResumption { |
| 8877 | suffix = "Resume-" |
| 8878 | } else { |
| 8879 | suffix = "Full-" |
| 8880 | } |
| 8881 | |
| 8882 | if hasEMS { |
| 8883 | suffix += "EMS-" |
| 8884 | } else { |
| 8885 | suffix += "NoEMS-" |
| 8886 | } |
| 8887 | |
| 8888 | if isClient { |
| 8889 | suffix += "Client" |
| 8890 | } else { |
| 8891 | suffix += "Server" |
| 8892 | } |
| 8893 | |
| 8894 | test := testCase{ |
| 8895 | name: "TLSUnique-" + suffix, |
| 8896 | testTLSUnique: true, |
| 8897 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8898 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8899 | Bugs: ProtocolBugs{ |
| 8900 | NoExtendedMasterSecret: !hasEMS, |
| 8901 | }, |
| 8902 | }, |
| 8903 | } |
| 8904 | |
| 8905 | if isResumption { |
| 8906 | test.resumeSession = true |
| 8907 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8908 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8909 | Bugs: ProtocolBugs{ |
| 8910 | NoExtendedMasterSecret: !hasEMS, |
| 8911 | }, |
| 8912 | } |
| 8913 | } |
| 8914 | |
| 8915 | if isResumption && !hasEMS { |
| 8916 | test.shouldFail = true |
| 8917 | test.expectedError = "failed to get tls-unique" |
| 8918 | } |
| 8919 | |
| 8920 | testCases = append(testCases, test) |
| 8921 | } |
| 8922 | } |
| 8923 | } |
| 8924 | } |
| 8925 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8926 | func addCustomExtensionTests() { |
| 8927 | expectedContents := "custom extension" |
| 8928 | emptyString := "" |
| 8929 | |
| 8930 | for _, isClient := range []bool{false, true} { |
| 8931 | suffix := "Server" |
| 8932 | flag := "-enable-server-custom-extension" |
| 8933 | testType := serverTest |
| 8934 | if isClient { |
| 8935 | suffix = "Client" |
| 8936 | flag = "-enable-client-custom-extension" |
| 8937 | testType = clientTest |
| 8938 | } |
| 8939 | |
| 8940 | testCases = append(testCases, testCase{ |
| 8941 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8942 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8943 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8944 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8945 | Bugs: ProtocolBugs{ |
| 8946 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8947 | ExpectedCustomExtension: &expectedContents, |
| 8948 | }, |
| 8949 | }, |
| 8950 | flags: []string{flag}, |
| 8951 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8952 | testCases = append(testCases, testCase{ |
| 8953 | testType: testType, |
| 8954 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8955 | config: Config{ |
| 8956 | MaxVersion: VersionTLS13, |
| 8957 | Bugs: ProtocolBugs{ |
| 8958 | CustomExtension: expectedContents, |
| 8959 | ExpectedCustomExtension: &expectedContents, |
| 8960 | }, |
| 8961 | }, |
| 8962 | flags: []string{flag}, |
| 8963 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8964 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 8965 | // 0-RTT is not currently supported with Custom Extensions. |
| 8966 | testCases = append(testCases, testCase{ |
| 8967 | testType: testType, |
| 8968 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 8969 | config: Config{ |
| 8970 | MaxVersion: VersionTLS13, |
| 8971 | Bugs: ProtocolBugs{ |
| 8972 | CustomExtension: expectedContents, |
| 8973 | ExpectedCustomExtension: &expectedContents, |
| 8974 | }, |
| 8975 | }, |
| 8976 | shouldFail: true, |
| 8977 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8978 | flags: []string{flag, "-enable-early-data"}, |
| 8979 | }) |
| 8980 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8981 | // If the parse callback fails, the handshake should also fail. |
| 8982 | testCases = append(testCases, testCase{ |
| 8983 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8984 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8985 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8986 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8987 | Bugs: ProtocolBugs{ |
| 8988 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8989 | ExpectedCustomExtension: &expectedContents, |
| 8990 | }, |
| 8991 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8992 | flags: []string{flag}, |
| 8993 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8994 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8995 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8996 | testCases = append(testCases, testCase{ |
| 8997 | testType: testType, |
| 8998 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 8999 | config: Config{ |
| 9000 | MaxVersion: VersionTLS13, |
| 9001 | Bugs: ProtocolBugs{ |
| 9002 | CustomExtension: expectedContents + "foo", |
| 9003 | ExpectedCustomExtension: &expectedContents, |
| 9004 | }, |
| 9005 | }, |
| 9006 | flags: []string{flag}, |
| 9007 | shouldFail: true, |
| 9008 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9009 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9010 | |
| 9011 | // If the add callback fails, the handshake should also fail. |
| 9012 | testCases = append(testCases, testCase{ |
| 9013 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9014 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9015 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9016 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9017 | Bugs: ProtocolBugs{ |
| 9018 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9019 | ExpectedCustomExtension: &expectedContents, |
| 9020 | }, |
| 9021 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9022 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9023 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9024 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9025 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9026 | testCases = append(testCases, testCase{ |
| 9027 | testType: testType, |
| 9028 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 9029 | config: Config{ |
| 9030 | MaxVersion: VersionTLS13, |
| 9031 | Bugs: ProtocolBugs{ |
| 9032 | CustomExtension: expectedContents, |
| 9033 | ExpectedCustomExtension: &expectedContents, |
| 9034 | }, |
| 9035 | }, |
| 9036 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9037 | shouldFail: true, |
| 9038 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9039 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9040 | |
| 9041 | // If the add callback returns zero, no extension should be |
| 9042 | // added. |
| 9043 | skipCustomExtension := expectedContents |
| 9044 | if isClient { |
| 9045 | // For the case where the client skips sending the |
| 9046 | // custom extension, the server must not “echo” it. |
| 9047 | skipCustomExtension = "" |
| 9048 | } |
| 9049 | testCases = append(testCases, testCase{ |
| 9050 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9051 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9052 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9053 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9054 | Bugs: ProtocolBugs{ |
| 9055 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9056 | ExpectedCustomExtension: &emptyString, |
| 9057 | }, |
| 9058 | }, |
| 9059 | flags: []string{flag, "-custom-extension-skip"}, |
| 9060 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9061 | testCases = append(testCases, testCase{ |
| 9062 | testType: testType, |
| 9063 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 9064 | config: Config{ |
| 9065 | MaxVersion: VersionTLS13, |
| 9066 | Bugs: ProtocolBugs{ |
| 9067 | CustomExtension: skipCustomExtension, |
| 9068 | ExpectedCustomExtension: &emptyString, |
| 9069 | }, |
| 9070 | }, |
| 9071 | flags: []string{flag, "-custom-extension-skip"}, |
| 9072 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9073 | } |
| 9074 | |
| 9075 | // The custom extension add callback should not be called if the client |
| 9076 | // doesn't send the extension. |
| 9077 | testCases = append(testCases, testCase{ |
| 9078 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9079 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9080 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9081 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9082 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9083 | ExpectedCustomExtension: &emptyString, |
| 9084 | }, |
| 9085 | }, |
| 9086 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9087 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9088 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9089 | testCases = append(testCases, testCase{ |
| 9090 | testType: serverTest, |
| 9091 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9092 | config: Config{ |
| 9093 | MaxVersion: VersionTLS13, |
| 9094 | Bugs: ProtocolBugs{ |
| 9095 | ExpectedCustomExtension: &emptyString, |
| 9096 | }, |
| 9097 | }, |
| 9098 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9099 | }) |
| 9100 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9101 | // Test an unknown extension from the server. |
| 9102 | testCases = append(testCases, testCase{ |
| 9103 | testType: clientTest, |
| 9104 | name: "UnknownExtension-Client", |
| 9105 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9106 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9107 | Bugs: ProtocolBugs{ |
| 9108 | CustomExtension: expectedContents, |
| 9109 | }, |
| 9110 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9111 | shouldFail: true, |
| 9112 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9113 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9114 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9115 | testCases = append(testCases, testCase{ |
| 9116 | testType: clientTest, |
| 9117 | name: "UnknownExtension-Client-TLS13", |
| 9118 | config: Config{ |
| 9119 | MaxVersion: VersionTLS13, |
| 9120 | Bugs: ProtocolBugs{ |
| 9121 | CustomExtension: expectedContents, |
| 9122 | }, |
| 9123 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9124 | shouldFail: true, |
| 9125 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9126 | expectedLocalError: "remote error: unsupported extension", |
| 9127 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9128 | testCases = append(testCases, testCase{ |
| 9129 | testType: clientTest, |
| 9130 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9131 | config: Config{ |
| 9132 | MaxVersion: VersionTLS13, |
| 9133 | Bugs: ProtocolBugs{ |
| 9134 | CustomUnencryptedExtension: expectedContents, |
| 9135 | }, |
| 9136 | }, |
| 9137 | shouldFail: true, |
| 9138 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9139 | // The shim must send an alert, but alerts at this point do not |
| 9140 | // get successfully decrypted by the runner. |
| 9141 | expectedLocalError: "local error: bad record MAC", |
| 9142 | }) |
| 9143 | testCases = append(testCases, testCase{ |
| 9144 | testType: clientTest, |
| 9145 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9146 | config: Config{ |
| 9147 | MaxVersion: VersionTLS13, |
| 9148 | Bugs: ProtocolBugs{ |
| 9149 | SendUnencryptedALPN: "foo", |
| 9150 | }, |
| 9151 | }, |
| 9152 | flags: []string{ |
| 9153 | "-advertise-alpn", "\x03foo\x03bar", |
| 9154 | }, |
| 9155 | shouldFail: true, |
| 9156 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9157 | // The shim must send an alert, but alerts at this point do not |
| 9158 | // get successfully decrypted by the runner. |
| 9159 | expectedLocalError: "local error: bad record MAC", |
| 9160 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9161 | |
| 9162 | // Test a known but unoffered extension from the server. |
| 9163 | testCases = append(testCases, testCase{ |
| 9164 | testType: clientTest, |
| 9165 | name: "UnofferedExtension-Client", |
| 9166 | config: Config{ |
| 9167 | MaxVersion: VersionTLS12, |
| 9168 | Bugs: ProtocolBugs{ |
| 9169 | SendALPN: "alpn", |
| 9170 | }, |
| 9171 | }, |
| 9172 | shouldFail: true, |
| 9173 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9174 | expectedLocalError: "remote error: unsupported extension", |
| 9175 | }) |
| 9176 | testCases = append(testCases, testCase{ |
| 9177 | testType: clientTest, |
| 9178 | name: "UnofferedExtension-Client-TLS13", |
| 9179 | config: Config{ |
| 9180 | MaxVersion: VersionTLS13, |
| 9181 | Bugs: ProtocolBugs{ |
| 9182 | SendALPN: "alpn", |
| 9183 | }, |
| 9184 | }, |
| 9185 | shouldFail: true, |
| 9186 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9187 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9188 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9189 | } |
| 9190 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9191 | func addRSAClientKeyExchangeTests() { |
| 9192 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9193 | testCases = append(testCases, testCase{ |
| 9194 | testType: serverTest, |
| 9195 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9196 | config: Config{ |
| 9197 | // Ensure the ClientHello version and final |
| 9198 | // version are different, to detect if the |
| 9199 | // server uses the wrong one. |
| 9200 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9201 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9202 | Bugs: ProtocolBugs{ |
| 9203 | BadRSAClientKeyExchange: bad, |
| 9204 | }, |
| 9205 | }, |
| 9206 | shouldFail: true, |
| 9207 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9208 | }) |
| 9209 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9210 | |
| 9211 | // The server must compare whatever was in ClientHello.version for the |
| 9212 | // RSA premaster. |
| 9213 | testCases = append(testCases, testCase{ |
| 9214 | testType: serverTest, |
| 9215 | name: "SendClientVersion-RSA", |
| 9216 | config: Config{ |
| 9217 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9218 | Bugs: ProtocolBugs{ |
| 9219 | SendClientVersion: 0x1234, |
| 9220 | }, |
| 9221 | }, |
| 9222 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9223 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9224 | } |
| 9225 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9226 | var testCurves = []struct { |
| 9227 | name string |
| 9228 | id CurveID |
| 9229 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9230 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9231 | {"P-256", CurveP256}, |
| 9232 | {"P-384", CurveP384}, |
| 9233 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9234 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9235 | } |
| 9236 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9237 | const bogusCurve = 0x1234 |
| 9238 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9239 | func addCurveTests() { |
| 9240 | for _, curve := range testCurves { |
| 9241 | testCases = append(testCases, testCase{ |
| 9242 | name: "CurveTest-Client-" + curve.name, |
| 9243 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9244 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9245 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9246 | CurvePreferences: []CurveID{curve.id}, |
| 9247 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9248 | flags: []string{ |
| 9249 | "-enable-all-curves", |
| 9250 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9251 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9252 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9253 | }) |
| 9254 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9255 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9256 | config: Config{ |
| 9257 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9258 | CurvePreferences: []CurveID{curve.id}, |
| 9259 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9260 | flags: []string{ |
| 9261 | "-enable-all-curves", |
| 9262 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9263 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9264 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9265 | }) |
| 9266 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9267 | testType: serverTest, |
| 9268 | name: "CurveTest-Server-" + curve.name, |
| 9269 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9270 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9271 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9272 | CurvePreferences: []CurveID{curve.id}, |
| 9273 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9274 | flags: []string{ |
| 9275 | "-enable-all-curves", |
| 9276 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9277 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9278 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9279 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9280 | testCases = append(testCases, testCase{ |
| 9281 | testType: serverTest, |
| 9282 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9283 | config: Config{ |
| 9284 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9285 | CurvePreferences: []CurveID{curve.id}, |
| 9286 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9287 | flags: []string{ |
| 9288 | "-enable-all-curves", |
| 9289 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9290 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9291 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9292 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9293 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9294 | |
| 9295 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9296 | testCases = append(testCases, testCase{ |
| 9297 | testType: serverTest, |
| 9298 | name: "UnknownCurve", |
| 9299 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9300 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9301 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9302 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9303 | }, |
| 9304 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9305 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9306 | // The server must be tolerant to bogus curves. |
| 9307 | testCases = append(testCases, testCase{ |
| 9308 | testType: serverTest, |
| 9309 | name: "UnknownCurve-TLS13", |
| 9310 | config: Config{ |
| 9311 | MaxVersion: VersionTLS13, |
| 9312 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9313 | }, |
| 9314 | }) |
| 9315 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9316 | // The server must not consider ECDHE ciphers when there are no |
| 9317 | // supported curves. |
| 9318 | testCases = append(testCases, testCase{ |
| 9319 | testType: serverTest, |
| 9320 | name: "NoSupportedCurves", |
| 9321 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9322 | MaxVersion: VersionTLS12, |
| 9323 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9324 | Bugs: ProtocolBugs{ |
| 9325 | NoSupportedCurves: true, |
| 9326 | }, |
| 9327 | }, |
| 9328 | shouldFail: true, |
| 9329 | expectedError: ":NO_SHARED_CIPHER:", |
| 9330 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9331 | testCases = append(testCases, testCase{ |
| 9332 | testType: serverTest, |
| 9333 | name: "NoSupportedCurves-TLS13", |
| 9334 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9335 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9336 | Bugs: ProtocolBugs{ |
| 9337 | NoSupportedCurves: true, |
| 9338 | }, |
| 9339 | }, |
| 9340 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9341 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9342 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9343 | |
| 9344 | // The server must fall back to another cipher when there are no |
| 9345 | // supported curves. |
| 9346 | testCases = append(testCases, testCase{ |
| 9347 | testType: serverTest, |
| 9348 | name: "NoCommonCurves", |
| 9349 | config: Config{ |
| 9350 | MaxVersion: VersionTLS12, |
| 9351 | CipherSuites: []uint16{ |
| 9352 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9353 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9354 | }, |
| 9355 | CurvePreferences: []CurveID{CurveP224}, |
| 9356 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9357 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9358 | }) |
| 9359 | |
| 9360 | // The client must reject bogus curves and disabled curves. |
| 9361 | testCases = append(testCases, testCase{ |
| 9362 | name: "BadECDHECurve", |
| 9363 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9364 | MaxVersion: VersionTLS12, |
| 9365 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9366 | Bugs: ProtocolBugs{ |
| 9367 | SendCurve: bogusCurve, |
| 9368 | }, |
| 9369 | }, |
| 9370 | shouldFail: true, |
| 9371 | expectedError: ":WRONG_CURVE:", |
| 9372 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9373 | testCases = append(testCases, testCase{ |
| 9374 | name: "BadECDHECurve-TLS13", |
| 9375 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9376 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9377 | Bugs: ProtocolBugs{ |
| 9378 | SendCurve: bogusCurve, |
| 9379 | }, |
| 9380 | }, |
| 9381 | shouldFail: true, |
| 9382 | expectedError: ":WRONG_CURVE:", |
| 9383 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9384 | |
| 9385 | testCases = append(testCases, testCase{ |
| 9386 | name: "UnsupportedCurve", |
| 9387 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9388 | MaxVersion: VersionTLS12, |
| 9389 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9390 | CurvePreferences: []CurveID{CurveP256}, |
| 9391 | Bugs: ProtocolBugs{ |
| 9392 | IgnorePeerCurvePreferences: true, |
| 9393 | }, |
| 9394 | }, |
| 9395 | flags: []string{"-p384-only"}, |
| 9396 | shouldFail: true, |
| 9397 | expectedError: ":WRONG_CURVE:", |
| 9398 | }) |
| 9399 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9400 | testCases = append(testCases, testCase{ |
| 9401 | // TODO(davidben): Add a TLS 1.3 version where |
| 9402 | // HelloRetryRequest requests an unsupported curve. |
| 9403 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9404 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9405 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9406 | CurvePreferences: []CurveID{CurveP384}, |
| 9407 | Bugs: ProtocolBugs{ |
| 9408 | SendCurve: CurveP256, |
| 9409 | }, |
| 9410 | }, |
| 9411 | flags: []string{"-p384-only"}, |
| 9412 | shouldFail: true, |
| 9413 | expectedError: ":WRONG_CURVE:", |
| 9414 | }) |
| 9415 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9416 | // Test invalid curve points. |
| 9417 | testCases = append(testCases, testCase{ |
| 9418 | name: "InvalidECDHPoint-Client", |
| 9419 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9420 | MaxVersion: VersionTLS12, |
| 9421 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9422 | CurvePreferences: []CurveID{CurveP256}, |
| 9423 | Bugs: ProtocolBugs{ |
| 9424 | InvalidECDHPoint: true, |
| 9425 | }, |
| 9426 | }, |
| 9427 | shouldFail: true, |
| 9428 | expectedError: ":INVALID_ENCODING:", |
| 9429 | }) |
| 9430 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9431 | name: "InvalidECDHPoint-Client-TLS13", |
| 9432 | config: Config{ |
| 9433 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9434 | CurvePreferences: []CurveID{CurveP256}, |
| 9435 | Bugs: ProtocolBugs{ |
| 9436 | InvalidECDHPoint: true, |
| 9437 | }, |
| 9438 | }, |
| 9439 | shouldFail: true, |
| 9440 | expectedError: ":INVALID_ENCODING:", |
| 9441 | }) |
| 9442 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9443 | testType: serverTest, |
| 9444 | name: "InvalidECDHPoint-Server", |
| 9445 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9446 | MaxVersion: VersionTLS12, |
| 9447 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9448 | CurvePreferences: []CurveID{CurveP256}, |
| 9449 | Bugs: ProtocolBugs{ |
| 9450 | InvalidECDHPoint: true, |
| 9451 | }, |
| 9452 | }, |
| 9453 | shouldFail: true, |
| 9454 | expectedError: ":INVALID_ENCODING:", |
| 9455 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9456 | testCases = append(testCases, testCase{ |
| 9457 | testType: serverTest, |
| 9458 | name: "InvalidECDHPoint-Server-TLS13", |
| 9459 | config: Config{ |
| 9460 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9461 | CurvePreferences: []CurveID{CurveP256}, |
| 9462 | Bugs: ProtocolBugs{ |
| 9463 | InvalidECDHPoint: true, |
| 9464 | }, |
| 9465 | }, |
| 9466 | shouldFail: true, |
| 9467 | expectedError: ":INVALID_ENCODING:", |
| 9468 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9469 | |
| 9470 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9471 | testCases = append(testCases, testCase{ |
| 9472 | name: "CurveID-Resume-Client", |
| 9473 | config: Config{ |
| 9474 | MaxVersion: VersionTLS12, |
| 9475 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9476 | CurvePreferences: []CurveID{CurveX25519}, |
| 9477 | }, |
| 9478 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9479 | resumeSession: true, |
| 9480 | }) |
| 9481 | testCases = append(testCases, testCase{ |
| 9482 | testType: serverTest, |
| 9483 | name: "CurveID-Resume-Server", |
| 9484 | config: Config{ |
| 9485 | MaxVersion: VersionTLS12, |
| 9486 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9487 | CurvePreferences: []CurveID{CurveX25519}, |
| 9488 | }, |
| 9489 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9490 | resumeSession: true, |
| 9491 | }) |
| 9492 | |
| 9493 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9494 | // one should be reported. |
| 9495 | testCases = append(testCases, testCase{ |
| 9496 | name: "CurveID-Resume-Client-TLS13", |
| 9497 | config: Config{ |
| 9498 | MaxVersion: VersionTLS13, |
| 9499 | CurvePreferences: []CurveID{CurveX25519}, |
| 9500 | }, |
| 9501 | resumeConfig: &Config{ |
| 9502 | MaxVersion: VersionTLS13, |
| 9503 | CurvePreferences: []CurveID{CurveP256}, |
| 9504 | }, |
| 9505 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9506 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9507 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9508 | }, |
| 9509 | resumeSession: true, |
| 9510 | }) |
| 9511 | testCases = append(testCases, testCase{ |
| 9512 | testType: serverTest, |
| 9513 | name: "CurveID-Resume-Server-TLS13", |
| 9514 | config: Config{ |
| 9515 | MaxVersion: VersionTLS13, |
| 9516 | CurvePreferences: []CurveID{CurveX25519}, |
| 9517 | }, |
| 9518 | resumeConfig: &Config{ |
| 9519 | MaxVersion: VersionTLS13, |
| 9520 | CurvePreferences: []CurveID{CurveP256}, |
| 9521 | }, |
| 9522 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9523 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9524 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9525 | }, |
| 9526 | resumeSession: true, |
| 9527 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9528 | |
| 9529 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9530 | testCases = append(testCases, testCase{ |
| 9531 | name: "PointFormat-ServerHello-TLS12", |
| 9532 | config: Config{ |
| 9533 | MaxVersion: VersionTLS12, |
| 9534 | Bugs: ProtocolBugs{ |
| 9535 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9536 | }, |
| 9537 | }, |
| 9538 | }) |
| 9539 | testCases = append(testCases, testCase{ |
| 9540 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9541 | config: Config{ |
| 9542 | MaxVersion: VersionTLS13, |
| 9543 | Bugs: ProtocolBugs{ |
| 9544 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9545 | }, |
| 9546 | }, |
| 9547 | shouldFail: true, |
| 9548 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9549 | }) |
| 9550 | |
| 9551 | // Test that we tolerate unknown point formats, as long as |
| 9552 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9553 | // check they are still functional. |
| 9554 | testCases = append(testCases, testCase{ |
| 9555 | name: "PointFormat-Client-Tolerance", |
| 9556 | config: Config{ |
| 9557 | MaxVersion: VersionTLS12, |
| 9558 | Bugs: ProtocolBugs{ |
| 9559 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9560 | }, |
| 9561 | }, |
| 9562 | }) |
| 9563 | testCases = append(testCases, testCase{ |
| 9564 | testType: serverTest, |
| 9565 | name: "PointFormat-Server-Tolerance", |
| 9566 | config: Config{ |
| 9567 | MaxVersion: VersionTLS12, |
| 9568 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9569 | Bugs: ProtocolBugs{ |
| 9570 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9571 | }, |
| 9572 | }, |
| 9573 | }) |
| 9574 | |
| 9575 | // Test TLS 1.2 does not require the point format extension to be |
| 9576 | // present. |
| 9577 | testCases = append(testCases, testCase{ |
| 9578 | name: "PointFormat-Client-Missing", |
| 9579 | config: Config{ |
| 9580 | MaxVersion: VersionTLS12, |
| 9581 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9582 | Bugs: ProtocolBugs{ |
| 9583 | SendSupportedPointFormats: []byte{}, |
| 9584 | }, |
| 9585 | }, |
| 9586 | }) |
| 9587 | testCases = append(testCases, testCase{ |
| 9588 | testType: serverTest, |
| 9589 | name: "PointFormat-Server-Missing", |
| 9590 | config: Config{ |
| 9591 | MaxVersion: VersionTLS12, |
| 9592 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9593 | Bugs: ProtocolBugs{ |
| 9594 | SendSupportedPointFormats: []byte{}, |
| 9595 | }, |
| 9596 | }, |
| 9597 | }) |
| 9598 | |
| 9599 | // If the point format extension is present, uncompressed points must be |
| 9600 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9601 | testCases = append(testCases, testCase{ |
| 9602 | name: "PointFormat-Client-MissingUncompressed", |
| 9603 | config: Config{ |
| 9604 | MaxVersion: VersionTLS12, |
| 9605 | Bugs: ProtocolBugs{ |
| 9606 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9607 | }, |
| 9608 | }, |
| 9609 | shouldFail: true, |
| 9610 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9611 | }) |
| 9612 | testCases = append(testCases, testCase{ |
| 9613 | testType: serverTest, |
| 9614 | name: "PointFormat-Server-MissingUncompressed", |
| 9615 | config: Config{ |
| 9616 | MaxVersion: VersionTLS12, |
| 9617 | Bugs: ProtocolBugs{ |
| 9618 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9619 | }, |
| 9620 | }, |
| 9621 | shouldFail: true, |
| 9622 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9623 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9624 | } |
| 9625 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9626 | func addTLS13RecordTests() { |
| 9627 | testCases = append(testCases, testCase{ |
| 9628 | name: "TLS13-RecordPadding", |
| 9629 | config: Config{ |
| 9630 | MaxVersion: VersionTLS13, |
| 9631 | MinVersion: VersionTLS13, |
| 9632 | Bugs: ProtocolBugs{ |
| 9633 | RecordPadding: 10, |
| 9634 | }, |
| 9635 | }, |
| 9636 | }) |
| 9637 | |
| 9638 | testCases = append(testCases, testCase{ |
| 9639 | name: "TLS13-EmptyRecords", |
| 9640 | config: Config{ |
| 9641 | MaxVersion: VersionTLS13, |
| 9642 | MinVersion: VersionTLS13, |
| 9643 | Bugs: ProtocolBugs{ |
| 9644 | OmitRecordContents: true, |
| 9645 | }, |
| 9646 | }, |
| 9647 | shouldFail: true, |
| 9648 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9649 | }) |
| 9650 | |
| 9651 | testCases = append(testCases, testCase{ |
| 9652 | name: "TLS13-OnlyPadding", |
| 9653 | config: Config{ |
| 9654 | MaxVersion: VersionTLS13, |
| 9655 | MinVersion: VersionTLS13, |
| 9656 | Bugs: ProtocolBugs{ |
| 9657 | OmitRecordContents: true, |
| 9658 | RecordPadding: 10, |
| 9659 | }, |
| 9660 | }, |
| 9661 | shouldFail: true, |
| 9662 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9663 | }) |
| 9664 | |
| 9665 | testCases = append(testCases, testCase{ |
| 9666 | name: "TLS13-WrongOuterRecord", |
| 9667 | config: Config{ |
| 9668 | MaxVersion: VersionTLS13, |
| 9669 | MinVersion: VersionTLS13, |
| 9670 | Bugs: ProtocolBugs{ |
| 9671 | OuterRecordType: recordTypeHandshake, |
| 9672 | }, |
| 9673 | }, |
| 9674 | shouldFail: true, |
| 9675 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9676 | }) |
| 9677 | } |
| 9678 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9679 | func addSessionTicketTests() { |
| 9680 | testCases = append(testCases, testCase{ |
| 9681 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9682 | // mean the server changed its mind on sending a ticket. |
| 9683 | name: "SendEmptySessionTicket", |
| 9684 | config: Config{ |
| 9685 | MaxVersion: VersionTLS12, |
| 9686 | Bugs: ProtocolBugs{ |
| 9687 | SendEmptySessionTicket: true, |
| 9688 | }, |
| 9689 | }, |
| 9690 | flags: []string{"-expect-no-session"}, |
| 9691 | }) |
| 9692 | |
| 9693 | // Test that the server ignores unknown PSK modes. |
| 9694 | testCases = append(testCases, testCase{ |
| 9695 | testType: serverTest, |
| 9696 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9697 | config: Config{ |
| 9698 | MaxVersion: VersionTLS13, |
| 9699 | Bugs: ProtocolBugs{ |
| 9700 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9701 | }, |
| 9702 | }, |
| 9703 | resumeSession: true, |
| 9704 | expectedResumeVersion: VersionTLS13, |
| 9705 | }) |
| 9706 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9707 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9708 | testCases = append(testCases, testCase{ |
| 9709 | testType: serverTest, |
| 9710 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9711 | config: Config{ |
| 9712 | MaxVersion: VersionTLS13, |
| 9713 | Bugs: ProtocolBugs{ |
| 9714 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9715 | ExpectNoNewSessionTicket: true, |
| 9716 | }, |
| 9717 | }, |
| 9718 | }) |
| 9719 | |
| 9720 | // 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] | 9721 | testCases = append(testCases, testCase{ |
| 9722 | testType: serverTest, |
| 9723 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9724 | config: Config{ |
| 9725 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9726 | }, |
| 9727 | resumeConfig: &Config{ |
| 9728 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9729 | Bugs: ProtocolBugs{ |
| 9730 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9731 | }, |
| 9732 | }, |
| 9733 | resumeSession: true, |
| 9734 | expectResumeRejected: true, |
| 9735 | }) |
| 9736 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9737 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9738 | testCases = append(testCases, testCase{ |
| 9739 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9740 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9741 | config: Config{ |
| 9742 | MaxVersion: VersionTLS13, |
| 9743 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9744 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9745 | }, |
| 9746 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9747 | resumeSession: true, |
| 9748 | flags: []string{ |
| 9749 | "-resumption-delay", "10", |
| 9750 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9751 | }) |
| 9752 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9753 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9754 | testCases = append(testCases, testCase{ |
| 9755 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9756 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9757 | config: Config{ |
| 9758 | MaxVersion: VersionTLS13, |
| 9759 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9760 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9761 | }, |
| 9762 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9763 | resumeSession: true, |
| 9764 | shouldFail: true, |
| 9765 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9766 | }) |
| 9767 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9768 | // Test that the server's ticket age skew reporting works. |
| 9769 | testCases = append(testCases, testCase{ |
| 9770 | testType: serverTest, |
| 9771 | name: "TLS13-TicketAgeSkew-Forward", |
| 9772 | config: Config{ |
| 9773 | MaxVersion: VersionTLS13, |
| 9774 | Bugs: ProtocolBugs{ |
| 9775 | SendTicketAge: 15 * time.Second, |
| 9776 | }, |
| 9777 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9778 | resumeSession: true, |
| 9779 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9780 | flags: []string{ |
| 9781 | "-resumption-delay", "10", |
| 9782 | "-expect-ticket-age-skew", "5", |
| 9783 | }, |
| 9784 | }) |
| 9785 | testCases = append(testCases, testCase{ |
| 9786 | testType: serverTest, |
| 9787 | name: "TLS13-TicketAgeSkew-Backward", |
| 9788 | config: Config{ |
| 9789 | MaxVersion: VersionTLS13, |
| 9790 | Bugs: ProtocolBugs{ |
| 9791 | SendTicketAge: 5 * time.Second, |
| 9792 | }, |
| 9793 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9794 | resumeSession: true, |
| 9795 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9796 | flags: []string{ |
| 9797 | "-resumption-delay", "10", |
| 9798 | "-expect-ticket-age-skew", "-5", |
| 9799 | }, |
| 9800 | }) |
| 9801 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9802 | testCases = append(testCases, testCase{ |
| 9803 | testType: clientTest, |
| 9804 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9805 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9806 | MaxVersion: VersionTLS13, |
| 9807 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9808 | }, |
| 9809 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9810 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9811 | "-expect-early-data-info", |
| 9812 | }, |
| 9813 | }) |
| 9814 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9815 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9816 | testCases = append(testCases, testCase{ |
| 9817 | testType: clientTest, |
| 9818 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9819 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9820 | MaxVersion: VersionTLS13, |
| 9821 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9822 | }, |
| 9823 | }) |
| 9824 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9825 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9826 | testType: clientTest, |
| 9827 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9828 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9829 | MaxVersion: VersionTLS13, |
| 9830 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9831 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9832 | DuplicateTicketEarlyDataInfo: true, |
| 9833 | }, |
| 9834 | }, |
| 9835 | shouldFail: true, |
| 9836 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9837 | expectedLocalError: "remote error: illegal parameter", |
| 9838 | }) |
| 9839 | |
| 9840 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9841 | testType: serverTest, |
| 9842 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9843 | config: Config{ |
| 9844 | MaxVersion: VersionTLS13, |
| 9845 | Bugs: ProtocolBugs{ |
| 9846 | ExpectTicketEarlyDataInfo: true, |
| 9847 | }, |
| 9848 | }, |
| 9849 | flags: []string{ |
| 9850 | "-enable-early-data", |
| 9851 | }, |
| 9852 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9853 | |
| 9854 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9855 | // is honored. |
| 9856 | testCases = append(testCases, testCase{ |
| 9857 | testType: clientTest, |
| 9858 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9859 | config: Config{ |
| 9860 | MaxVersion: VersionTLS13, |
| 9861 | Bugs: ProtocolBugs{ |
| 9862 | SendTicketLifetime: 20 * time.Second, |
| 9863 | }, |
| 9864 | }, |
| 9865 | flags: []string{ |
| 9866 | "-resumption-delay", "19", |
| 9867 | }, |
| 9868 | resumeSession: true, |
| 9869 | }) |
| 9870 | testCases = append(testCases, testCase{ |
| 9871 | testType: clientTest, |
| 9872 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9873 | config: Config{ |
| 9874 | MaxVersion: VersionTLS13, |
| 9875 | Bugs: ProtocolBugs{ |
| 9876 | SendTicketLifetime: 20 * time.Second, |
| 9877 | // The client should not offer the expired session. |
| 9878 | ExpectNoTLS13PSK: true, |
| 9879 | }, |
| 9880 | }, |
| 9881 | flags: []string{ |
| 9882 | "-resumption-delay", "21", |
| 9883 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9884 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9885 | expectResumeRejected: true, |
| 9886 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9887 | } |
| 9888 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9889 | func addChangeCipherSpecTests() { |
| 9890 | // Test missing ChangeCipherSpecs. |
| 9891 | testCases = append(testCases, testCase{ |
| 9892 | name: "SkipChangeCipherSpec-Client", |
| 9893 | config: Config{ |
| 9894 | MaxVersion: VersionTLS12, |
| 9895 | Bugs: ProtocolBugs{ |
| 9896 | SkipChangeCipherSpec: true, |
| 9897 | }, |
| 9898 | }, |
| 9899 | shouldFail: true, |
| 9900 | expectedError: ":UNEXPECTED_RECORD:", |
| 9901 | }) |
| 9902 | testCases = append(testCases, testCase{ |
| 9903 | testType: serverTest, |
| 9904 | name: "SkipChangeCipherSpec-Server", |
| 9905 | config: Config{ |
| 9906 | MaxVersion: VersionTLS12, |
| 9907 | Bugs: ProtocolBugs{ |
| 9908 | SkipChangeCipherSpec: true, |
| 9909 | }, |
| 9910 | }, |
| 9911 | shouldFail: true, |
| 9912 | expectedError: ":UNEXPECTED_RECORD:", |
| 9913 | }) |
| 9914 | testCases = append(testCases, testCase{ |
| 9915 | testType: serverTest, |
| 9916 | name: "SkipChangeCipherSpec-Server-NPN", |
| 9917 | config: Config{ |
| 9918 | MaxVersion: VersionTLS12, |
| 9919 | NextProtos: []string{"bar"}, |
| 9920 | Bugs: ProtocolBugs{ |
| 9921 | SkipChangeCipherSpec: true, |
| 9922 | }, |
| 9923 | }, |
| 9924 | flags: []string{ |
| 9925 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9926 | }, |
| 9927 | shouldFail: true, |
| 9928 | expectedError: ":UNEXPECTED_RECORD:", |
| 9929 | }) |
| 9930 | |
| 9931 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 9932 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 9933 | // rejected. Test both with and without handshake packing to handle both |
| 9934 | // when the partial post-CCS message is in its own record and when it is |
| 9935 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9936 | for _, packed := range []bool{false, true} { |
| 9937 | var suffix string |
| 9938 | if packed { |
| 9939 | suffix = "-Packed" |
| 9940 | } |
| 9941 | |
| 9942 | testCases = append(testCases, testCase{ |
| 9943 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 9944 | config: Config{ |
| 9945 | MaxVersion: VersionTLS12, |
| 9946 | Bugs: ProtocolBugs{ |
| 9947 | FragmentAcrossChangeCipherSpec: true, |
| 9948 | PackHandshakeFlight: packed, |
| 9949 | }, |
| 9950 | }, |
| 9951 | shouldFail: true, |
| 9952 | expectedError: ":UNEXPECTED_RECORD:", |
| 9953 | }) |
| 9954 | testCases = append(testCases, testCase{ |
| 9955 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 9956 | config: Config{ |
| 9957 | MaxVersion: VersionTLS12, |
| 9958 | }, |
| 9959 | resumeSession: true, |
| 9960 | resumeConfig: &Config{ |
| 9961 | MaxVersion: VersionTLS12, |
| 9962 | Bugs: ProtocolBugs{ |
| 9963 | FragmentAcrossChangeCipherSpec: true, |
| 9964 | PackHandshakeFlight: packed, |
| 9965 | }, |
| 9966 | }, |
| 9967 | shouldFail: true, |
| 9968 | expectedError: ":UNEXPECTED_RECORD:", |
| 9969 | }) |
| 9970 | testCases = append(testCases, testCase{ |
| 9971 | testType: serverTest, |
| 9972 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 9973 | config: Config{ |
| 9974 | MaxVersion: VersionTLS12, |
| 9975 | Bugs: ProtocolBugs{ |
| 9976 | FragmentAcrossChangeCipherSpec: true, |
| 9977 | PackHandshakeFlight: packed, |
| 9978 | }, |
| 9979 | }, |
| 9980 | shouldFail: true, |
| 9981 | expectedError: ":UNEXPECTED_RECORD:", |
| 9982 | }) |
| 9983 | testCases = append(testCases, testCase{ |
| 9984 | testType: serverTest, |
| 9985 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 9986 | config: Config{ |
| 9987 | MaxVersion: VersionTLS12, |
| 9988 | }, |
| 9989 | resumeSession: true, |
| 9990 | resumeConfig: &Config{ |
| 9991 | MaxVersion: VersionTLS12, |
| 9992 | Bugs: ProtocolBugs{ |
| 9993 | FragmentAcrossChangeCipherSpec: true, |
| 9994 | PackHandshakeFlight: packed, |
| 9995 | }, |
| 9996 | }, |
| 9997 | shouldFail: true, |
| 9998 | expectedError: ":UNEXPECTED_RECORD:", |
| 9999 | }) |
| 10000 | testCases = append(testCases, testCase{ |
| 10001 | testType: serverTest, |
| 10002 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 10003 | config: Config{ |
| 10004 | MaxVersion: VersionTLS12, |
| 10005 | NextProtos: []string{"bar"}, |
| 10006 | Bugs: ProtocolBugs{ |
| 10007 | FragmentAcrossChangeCipherSpec: true, |
| 10008 | PackHandshakeFlight: packed, |
| 10009 | }, |
| 10010 | }, |
| 10011 | flags: []string{ |
| 10012 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10013 | }, |
| 10014 | shouldFail: true, |
| 10015 | expectedError: ":UNEXPECTED_RECORD:", |
| 10016 | }) |
| 10017 | } |
| 10018 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 10019 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 10020 | // messages in the handshake queue. Do this by testing the server |
| 10021 | // reading the client Finished, reversing the flight so Finished comes |
| 10022 | // first. |
| 10023 | testCases = append(testCases, testCase{ |
| 10024 | protocol: dtls, |
| 10025 | testType: serverTest, |
| 10026 | name: "SendUnencryptedFinished-DTLS", |
| 10027 | config: Config{ |
| 10028 | MaxVersion: VersionTLS12, |
| 10029 | Bugs: ProtocolBugs{ |
| 10030 | SendUnencryptedFinished: true, |
| 10031 | ReverseHandshakeFragments: true, |
| 10032 | }, |
| 10033 | }, |
| 10034 | shouldFail: true, |
| 10035 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10036 | }) |
| 10037 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10038 | // Test synchronization between encryption changes and the handshake in |
| 10039 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 10040 | testCases = append(testCases, testCase{ |
| 10041 | name: "PartialEncryptedExtensionsWithServerHello", |
| 10042 | config: Config{ |
| 10043 | MaxVersion: VersionTLS13, |
| 10044 | Bugs: ProtocolBugs{ |
| 10045 | PartialEncryptedExtensionsWithServerHello: true, |
| 10046 | }, |
| 10047 | }, |
| 10048 | shouldFail: true, |
| 10049 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10050 | }) |
| 10051 | testCases = append(testCases, testCase{ |
| 10052 | testType: serverTest, |
| 10053 | name: "PartialClientFinishedWithClientHello", |
| 10054 | config: Config{ |
| 10055 | MaxVersion: VersionTLS13, |
| 10056 | Bugs: ProtocolBugs{ |
| 10057 | PartialClientFinishedWithClientHello: true, |
| 10058 | }, |
| 10059 | }, |
| 10060 | shouldFail: true, |
| 10061 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10062 | }) |
| 10063 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10064 | // Test that early ChangeCipherSpecs are handled correctly. |
| 10065 | testCases = append(testCases, testCase{ |
| 10066 | testType: serverTest, |
| 10067 | name: "EarlyChangeCipherSpec-server-1", |
| 10068 | config: Config{ |
| 10069 | MaxVersion: VersionTLS12, |
| 10070 | Bugs: ProtocolBugs{ |
| 10071 | EarlyChangeCipherSpec: 1, |
| 10072 | }, |
| 10073 | }, |
| 10074 | shouldFail: true, |
| 10075 | expectedError: ":UNEXPECTED_RECORD:", |
| 10076 | }) |
| 10077 | testCases = append(testCases, testCase{ |
| 10078 | testType: serverTest, |
| 10079 | name: "EarlyChangeCipherSpec-server-2", |
| 10080 | config: Config{ |
| 10081 | MaxVersion: VersionTLS12, |
| 10082 | Bugs: ProtocolBugs{ |
| 10083 | EarlyChangeCipherSpec: 2, |
| 10084 | }, |
| 10085 | }, |
| 10086 | shouldFail: true, |
| 10087 | expectedError: ":UNEXPECTED_RECORD:", |
| 10088 | }) |
| 10089 | testCases = append(testCases, testCase{ |
| 10090 | protocol: dtls, |
| 10091 | name: "StrayChangeCipherSpec", |
| 10092 | config: Config{ |
| 10093 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10094 | // that stray ChangeCipherSpec messages are |
| 10095 | // rejected. |
| 10096 | MaxVersion: VersionTLS12, |
| 10097 | Bugs: ProtocolBugs{ |
| 10098 | StrayChangeCipherSpec: true, |
| 10099 | }, |
| 10100 | }, |
| 10101 | }) |
| 10102 | |
David Benjamin | b0c761e | 2017-06-25 22:42:55 -0400 | [diff] [blame] | 10103 | // Test that reordered ChangeCipherSpecs are tolerated. |
| 10104 | testCases = append(testCases, testCase{ |
| 10105 | protocol: dtls, |
| 10106 | name: "ReorderChangeCipherSpec-DTLS-Client", |
| 10107 | config: Config{ |
| 10108 | MaxVersion: VersionTLS12, |
| 10109 | Bugs: ProtocolBugs{ |
| 10110 | ReorderChangeCipherSpec: true, |
| 10111 | }, |
| 10112 | }, |
| 10113 | resumeSession: true, |
| 10114 | }) |
| 10115 | testCases = append(testCases, testCase{ |
| 10116 | testType: serverTest, |
| 10117 | protocol: dtls, |
| 10118 | name: "ReorderChangeCipherSpec-DTLS-Server", |
| 10119 | config: Config{ |
| 10120 | MaxVersion: VersionTLS12, |
| 10121 | Bugs: ProtocolBugs{ |
| 10122 | ReorderChangeCipherSpec: true, |
| 10123 | }, |
| 10124 | }, |
| 10125 | resumeSession: true, |
| 10126 | }) |
| 10127 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10128 | // Test that the contents of ChangeCipherSpec are checked. |
| 10129 | testCases = append(testCases, testCase{ |
| 10130 | name: "BadChangeCipherSpec-1", |
| 10131 | config: Config{ |
| 10132 | MaxVersion: VersionTLS12, |
| 10133 | Bugs: ProtocolBugs{ |
| 10134 | BadChangeCipherSpec: []byte{2}, |
| 10135 | }, |
| 10136 | }, |
| 10137 | shouldFail: true, |
| 10138 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10139 | }) |
| 10140 | testCases = append(testCases, testCase{ |
| 10141 | name: "BadChangeCipherSpec-2", |
| 10142 | config: Config{ |
| 10143 | MaxVersion: VersionTLS12, |
| 10144 | Bugs: ProtocolBugs{ |
| 10145 | BadChangeCipherSpec: []byte{1, 1}, |
| 10146 | }, |
| 10147 | }, |
| 10148 | shouldFail: true, |
| 10149 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10150 | }) |
| 10151 | testCases = append(testCases, testCase{ |
| 10152 | protocol: dtls, |
| 10153 | name: "BadChangeCipherSpec-DTLS-1", |
| 10154 | config: Config{ |
| 10155 | MaxVersion: VersionTLS12, |
| 10156 | Bugs: ProtocolBugs{ |
| 10157 | BadChangeCipherSpec: []byte{2}, |
| 10158 | }, |
| 10159 | }, |
| 10160 | shouldFail: true, |
| 10161 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10162 | }) |
| 10163 | testCases = append(testCases, testCase{ |
| 10164 | protocol: dtls, |
| 10165 | name: "BadChangeCipherSpec-DTLS-2", |
| 10166 | config: Config{ |
| 10167 | MaxVersion: VersionTLS12, |
| 10168 | Bugs: ProtocolBugs{ |
| 10169 | BadChangeCipherSpec: []byte{1, 1}, |
| 10170 | }, |
| 10171 | }, |
| 10172 | shouldFail: true, |
| 10173 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10174 | }) |
| 10175 | } |
| 10176 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10177 | type perMessageTest struct { |
| 10178 | messageType uint8 |
| 10179 | test testCase |
| 10180 | } |
| 10181 | |
| 10182 | // makePerMessageTests returns a series of test templates which cover each |
| 10183 | // message in the TLS handshake. These may be used with bugs like |
| 10184 | // WrongMessageType to fully test a per-message bug. |
| 10185 | func makePerMessageTests() []perMessageTest { |
| 10186 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10187 | for _, protocol := range []protocol{tls, dtls} { |
| 10188 | var suffix string |
| 10189 | if protocol == dtls { |
| 10190 | suffix = "-DTLS" |
| 10191 | } |
| 10192 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10193 | ret = append(ret, perMessageTest{ |
| 10194 | messageType: typeClientHello, |
| 10195 | test: testCase{ |
| 10196 | protocol: protocol, |
| 10197 | testType: serverTest, |
| 10198 | name: "ClientHello" + suffix, |
| 10199 | config: Config{ |
| 10200 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10201 | }, |
| 10202 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10203 | }) |
| 10204 | |
| 10205 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10206 | ret = append(ret, perMessageTest{ |
| 10207 | messageType: typeHelloVerifyRequest, |
| 10208 | test: testCase{ |
| 10209 | protocol: protocol, |
| 10210 | name: "HelloVerifyRequest" + suffix, |
| 10211 | config: Config{ |
| 10212 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10213 | }, |
| 10214 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10215 | }) |
| 10216 | } |
| 10217 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10218 | ret = append(ret, perMessageTest{ |
| 10219 | messageType: typeServerHello, |
| 10220 | test: testCase{ |
| 10221 | protocol: protocol, |
| 10222 | name: "ServerHello" + suffix, |
| 10223 | config: Config{ |
| 10224 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10225 | }, |
| 10226 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10227 | }) |
| 10228 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10229 | ret = append(ret, perMessageTest{ |
| 10230 | messageType: typeCertificate, |
| 10231 | test: testCase{ |
| 10232 | protocol: protocol, |
| 10233 | name: "ServerCertificate" + suffix, |
| 10234 | config: Config{ |
| 10235 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10236 | }, |
| 10237 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10238 | }) |
| 10239 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10240 | ret = append(ret, perMessageTest{ |
| 10241 | messageType: typeCertificateStatus, |
| 10242 | test: testCase{ |
| 10243 | protocol: protocol, |
| 10244 | name: "CertificateStatus" + suffix, |
| 10245 | config: Config{ |
| 10246 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10247 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10248 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10249 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10250 | }) |
| 10251 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10252 | ret = append(ret, perMessageTest{ |
| 10253 | messageType: typeServerKeyExchange, |
| 10254 | test: testCase{ |
| 10255 | protocol: protocol, |
| 10256 | name: "ServerKeyExchange" + suffix, |
| 10257 | config: Config{ |
| 10258 | MaxVersion: VersionTLS12, |
| 10259 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10260 | }, |
| 10261 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10262 | }) |
| 10263 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10264 | ret = append(ret, perMessageTest{ |
| 10265 | messageType: typeCertificateRequest, |
| 10266 | test: testCase{ |
| 10267 | protocol: protocol, |
| 10268 | name: "CertificateRequest" + suffix, |
| 10269 | config: Config{ |
| 10270 | MaxVersion: VersionTLS12, |
| 10271 | ClientAuth: RequireAnyClientCert, |
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: typeServerHelloDone, |
| 10278 | test: testCase{ |
| 10279 | protocol: protocol, |
| 10280 | name: "ServerHelloDone" + 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: typeCertificate, |
| 10289 | test: testCase{ |
| 10290 | testType: serverTest, |
| 10291 | protocol: protocol, |
| 10292 | name: "ClientCertificate" + suffix, |
| 10293 | config: Config{ |
| 10294 | Certificates: []Certificate{rsaCertificate}, |
| 10295 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10296 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10297 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10298 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10299 | }) |
| 10300 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10301 | ret = append(ret, perMessageTest{ |
| 10302 | messageType: typeCertificateVerify, |
| 10303 | test: testCase{ |
| 10304 | testType: serverTest, |
| 10305 | protocol: protocol, |
| 10306 | name: "CertificateVerify" + suffix, |
| 10307 | config: Config{ |
| 10308 | Certificates: []Certificate{rsaCertificate}, |
| 10309 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10310 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10311 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10312 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10313 | }) |
| 10314 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10315 | ret = append(ret, perMessageTest{ |
| 10316 | messageType: typeClientKeyExchange, |
| 10317 | test: testCase{ |
| 10318 | testType: serverTest, |
| 10319 | protocol: protocol, |
| 10320 | name: "ClientKeyExchange" + suffix, |
| 10321 | config: Config{ |
| 10322 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10323 | }, |
| 10324 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10325 | }) |
| 10326 | |
| 10327 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10328 | ret = append(ret, perMessageTest{ |
| 10329 | messageType: typeNextProtocol, |
| 10330 | test: testCase{ |
| 10331 | testType: serverTest, |
| 10332 | protocol: protocol, |
| 10333 | name: "NextProtocol" + suffix, |
| 10334 | config: Config{ |
| 10335 | MaxVersion: VersionTLS12, |
| 10336 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10337 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10338 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10339 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10340 | }) |
| 10341 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10342 | ret = append(ret, perMessageTest{ |
| 10343 | messageType: typeChannelID, |
| 10344 | test: testCase{ |
| 10345 | testType: serverTest, |
| 10346 | protocol: protocol, |
| 10347 | name: "ChannelID" + suffix, |
| 10348 | config: Config{ |
| 10349 | MaxVersion: VersionTLS12, |
| 10350 | ChannelID: channelIDKey, |
| 10351 | }, |
| 10352 | flags: []string{ |
| 10353 | "-expect-channel-id", |
| 10354 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10355 | }, |
| 10356 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10357 | }) |
| 10358 | } |
| 10359 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10360 | ret = append(ret, perMessageTest{ |
| 10361 | messageType: typeFinished, |
| 10362 | test: testCase{ |
| 10363 | testType: serverTest, |
| 10364 | protocol: protocol, |
| 10365 | name: "ClientFinished" + suffix, |
| 10366 | config: Config{ |
| 10367 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10368 | }, |
| 10369 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10370 | }) |
| 10371 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10372 | ret = append(ret, perMessageTest{ |
| 10373 | messageType: typeNewSessionTicket, |
| 10374 | test: testCase{ |
| 10375 | protocol: protocol, |
| 10376 | name: "NewSessionTicket" + suffix, |
| 10377 | config: Config{ |
| 10378 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10379 | }, |
| 10380 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10381 | }) |
| 10382 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10383 | ret = append(ret, perMessageTest{ |
| 10384 | messageType: typeFinished, |
| 10385 | test: testCase{ |
| 10386 | protocol: protocol, |
| 10387 | name: "ServerFinished" + suffix, |
| 10388 | config: Config{ |
| 10389 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10390 | }, |
| 10391 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10392 | }) |
| 10393 | |
| 10394 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10395 | |
| 10396 | ret = append(ret, perMessageTest{ |
| 10397 | messageType: typeClientHello, |
| 10398 | test: testCase{ |
| 10399 | testType: serverTest, |
| 10400 | name: "TLS13-ClientHello", |
| 10401 | config: Config{ |
| 10402 | MaxVersion: VersionTLS13, |
| 10403 | }, |
| 10404 | }, |
| 10405 | }) |
| 10406 | |
| 10407 | ret = append(ret, perMessageTest{ |
| 10408 | messageType: typeServerHello, |
| 10409 | test: testCase{ |
| 10410 | name: "TLS13-ServerHello", |
| 10411 | config: Config{ |
| 10412 | MaxVersion: VersionTLS13, |
| 10413 | }, |
| 10414 | }, |
| 10415 | }) |
| 10416 | |
| 10417 | ret = append(ret, perMessageTest{ |
| 10418 | messageType: typeEncryptedExtensions, |
| 10419 | test: testCase{ |
| 10420 | name: "TLS13-EncryptedExtensions", |
| 10421 | config: Config{ |
| 10422 | MaxVersion: VersionTLS13, |
| 10423 | }, |
| 10424 | }, |
| 10425 | }) |
| 10426 | |
| 10427 | ret = append(ret, perMessageTest{ |
| 10428 | messageType: typeCertificateRequest, |
| 10429 | test: testCase{ |
| 10430 | name: "TLS13-CertificateRequest", |
| 10431 | config: Config{ |
| 10432 | MaxVersion: VersionTLS13, |
| 10433 | ClientAuth: RequireAnyClientCert, |
| 10434 | }, |
| 10435 | }, |
| 10436 | }) |
| 10437 | |
| 10438 | ret = append(ret, perMessageTest{ |
| 10439 | messageType: typeCertificate, |
| 10440 | test: testCase{ |
| 10441 | name: "TLS13-ServerCertificate", |
| 10442 | config: Config{ |
| 10443 | MaxVersion: VersionTLS13, |
| 10444 | }, |
| 10445 | }, |
| 10446 | }) |
| 10447 | |
| 10448 | ret = append(ret, perMessageTest{ |
| 10449 | messageType: typeCertificateVerify, |
| 10450 | test: testCase{ |
| 10451 | name: "TLS13-ServerCertificateVerify", |
| 10452 | config: Config{ |
| 10453 | MaxVersion: VersionTLS13, |
| 10454 | }, |
| 10455 | }, |
| 10456 | }) |
| 10457 | |
| 10458 | ret = append(ret, perMessageTest{ |
| 10459 | messageType: typeFinished, |
| 10460 | test: testCase{ |
| 10461 | name: "TLS13-ServerFinished", |
| 10462 | config: Config{ |
| 10463 | MaxVersion: VersionTLS13, |
| 10464 | }, |
| 10465 | }, |
| 10466 | }) |
| 10467 | |
| 10468 | ret = append(ret, perMessageTest{ |
| 10469 | messageType: typeCertificate, |
| 10470 | test: testCase{ |
| 10471 | testType: serverTest, |
| 10472 | name: "TLS13-ClientCertificate", |
| 10473 | config: Config{ |
| 10474 | Certificates: []Certificate{rsaCertificate}, |
| 10475 | MaxVersion: VersionTLS13, |
| 10476 | }, |
| 10477 | flags: []string{"-require-any-client-certificate"}, |
| 10478 | }, |
| 10479 | }) |
| 10480 | |
| 10481 | ret = append(ret, perMessageTest{ |
| 10482 | messageType: typeCertificateVerify, |
| 10483 | test: testCase{ |
| 10484 | testType: serverTest, |
| 10485 | name: "TLS13-ClientCertificateVerify", |
| 10486 | config: Config{ |
| 10487 | Certificates: []Certificate{rsaCertificate}, |
| 10488 | MaxVersion: VersionTLS13, |
| 10489 | }, |
| 10490 | flags: []string{"-require-any-client-certificate"}, |
| 10491 | }, |
| 10492 | }) |
| 10493 | |
| 10494 | ret = append(ret, perMessageTest{ |
| 10495 | messageType: typeFinished, |
| 10496 | test: testCase{ |
| 10497 | testType: serverTest, |
| 10498 | name: "TLS13-ClientFinished", |
| 10499 | config: Config{ |
| 10500 | MaxVersion: VersionTLS13, |
| 10501 | }, |
| 10502 | }, |
| 10503 | }) |
| 10504 | |
| 10505 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10506 | } |
| 10507 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10508 | func addWrongMessageTypeTests() { |
| 10509 | for _, t := range makePerMessageTests() { |
| 10510 | t.test.name = "WrongMessageType-" + t.test.name |
| 10511 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10512 | t.test.shouldFail = true |
| 10513 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10514 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10515 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10516 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10517 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10518 | // an unencrypted alert while the server expects |
| 10519 | // encryption, so the alert is not readable by runner. |
| 10520 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10521 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10522 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10523 | testCases = append(testCases, t.test) |
| 10524 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10525 | |
| 10526 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10527 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10528 | // TLS 1.2. Test that we do not do this. |
| 10529 | testCases = append(testCases, testCase{ |
| 10530 | name: "SendServerHelloAsHelloRetryRequest", |
| 10531 | config: Config{ |
| 10532 | MaxVersion: VersionTLS12, |
| 10533 | Bugs: ProtocolBugs{ |
| 10534 | SendServerHelloAsHelloRetryRequest: true, |
| 10535 | }, |
| 10536 | }, |
| 10537 | shouldFail: true, |
| 10538 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10539 | expectedLocalError: "remote error: unexpected message", |
| 10540 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10541 | } |
| 10542 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10543 | func addTrailingMessageDataTests() { |
| 10544 | for _, t := range makePerMessageTests() { |
| 10545 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10546 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10547 | t.test.shouldFail = true |
| 10548 | t.test.expectedError = ":DECODE_ERROR:" |
| 10549 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10550 | |
| 10551 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10552 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10553 | // an unencrypted alert while the server expects |
| 10554 | // encryption, so the alert is not readable by runner. |
| 10555 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10556 | } |
| 10557 | |
| 10558 | if t.messageType == typeFinished { |
| 10559 | // Bad Finished messages read as the verify data having |
| 10560 | // the wrong length. |
| 10561 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10562 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10563 | } |
| 10564 | |
| 10565 | testCases = append(testCases, t.test) |
| 10566 | } |
| 10567 | } |
| 10568 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10569 | func addTLS13HandshakeTests() { |
| 10570 | testCases = append(testCases, testCase{ |
| 10571 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10572 | name: "NegotiatePSKResumption-TLS13", |
| 10573 | config: Config{ |
| 10574 | MaxVersion: VersionTLS13, |
| 10575 | Bugs: ProtocolBugs{ |
| 10576 | NegotiatePSKResumption: true, |
| 10577 | }, |
| 10578 | }, |
| 10579 | resumeSession: true, |
| 10580 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10581 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10582 | }) |
| 10583 | |
| 10584 | testCases = append(testCases, testCase{ |
| 10585 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10586 | name: "MissingKeyShare-Client", |
| 10587 | config: Config{ |
| 10588 | MaxVersion: VersionTLS13, |
| 10589 | Bugs: ProtocolBugs{ |
| 10590 | MissingKeyShare: true, |
| 10591 | }, |
| 10592 | }, |
| 10593 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10594 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10595 | }) |
| 10596 | |
| 10597 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10598 | testType: serverTest, |
| 10599 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10600 | config: Config{ |
| 10601 | MaxVersion: VersionTLS13, |
| 10602 | Bugs: ProtocolBugs{ |
| 10603 | MissingKeyShare: true, |
| 10604 | }, |
| 10605 | }, |
| 10606 | shouldFail: true, |
| 10607 | expectedError: ":MISSING_KEY_SHARE:", |
| 10608 | }) |
| 10609 | |
| 10610 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10611 | testType: serverTest, |
| 10612 | name: "DuplicateKeyShares", |
| 10613 | config: Config{ |
| 10614 | MaxVersion: VersionTLS13, |
| 10615 | Bugs: ProtocolBugs{ |
| 10616 | DuplicateKeyShares: true, |
| 10617 | }, |
| 10618 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10619 | shouldFail: true, |
| 10620 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10621 | }) |
| 10622 | |
| 10623 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10624 | testType: serverTest, |
| 10625 | name: "SkipEarlyData", |
| 10626 | config: Config{ |
| 10627 | MaxVersion: VersionTLS13, |
| 10628 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10629 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10630 | }, |
| 10631 | }, |
| 10632 | }) |
| 10633 | |
| 10634 | testCases = append(testCases, testCase{ |
| 10635 | testType: serverTest, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 10636 | name: "SkipEarlyData-TLS13Experiment", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10637 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10638 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10639 | Bugs: ProtocolBugs{ |
| 10640 | SendFakeEarlyDataLength: 4, |
| 10641 | }, |
| 10642 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10643 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10644 | }) |
| 10645 | |
| 10646 | testCases = append(testCases, testCase{ |
| 10647 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10648 | name: "SkipEarlyData-TLS13RecordTypeExperiment", |
| 10649 | config: Config{ |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10650 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10651 | Bugs: ProtocolBugs{ |
| 10652 | SendFakeEarlyDataLength: 4, |
| 10653 | }, |
| 10654 | }, |
David Benjamin | f6ae9e6 | 2017-08-08 20:04:41 -0400 | [diff] [blame] | 10655 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10656 | }) |
| 10657 | |
| 10658 | testCases = append(testCases, testCase{ |
| 10659 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10660 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10661 | config: Config{ |
| 10662 | MaxVersion: VersionTLS13, |
| 10663 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10664 | SendFakeEarlyDataLength: 4, |
| 10665 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10666 | }, |
| 10667 | }, |
| 10668 | shouldFail: true, |
| 10669 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10670 | }) |
| 10671 | |
| 10672 | testCases = append(testCases, testCase{ |
| 10673 | testType: serverTest, |
| 10674 | name: "SkipEarlyData-TooMuchData", |
| 10675 | config: Config{ |
| 10676 | MaxVersion: VersionTLS13, |
| 10677 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10678 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10679 | }, |
| 10680 | }, |
| 10681 | shouldFail: true, |
| 10682 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10683 | }) |
| 10684 | |
| 10685 | testCases = append(testCases, testCase{ |
| 10686 | testType: serverTest, |
| 10687 | name: "SkipEarlyData-Interleaved", |
| 10688 | config: Config{ |
| 10689 | MaxVersion: VersionTLS13, |
| 10690 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10691 | SendFakeEarlyDataLength: 4, |
| 10692 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10693 | }, |
| 10694 | }, |
| 10695 | shouldFail: true, |
| 10696 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10697 | }) |
| 10698 | |
| 10699 | testCases = append(testCases, testCase{ |
| 10700 | testType: serverTest, |
| 10701 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10702 | config: Config{ |
| 10703 | MaxVersion: VersionTLS13, |
| 10704 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10705 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10706 | }, |
| 10707 | }, |
| 10708 | shouldFail: true, |
| 10709 | expectedError: ":UNEXPECTED_RECORD:", |
| 10710 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10711 | }) |
| 10712 | |
| 10713 | testCases = append(testCases, testCase{ |
| 10714 | testType: serverTest, |
| 10715 | name: "SkipEarlyData-HRR", |
| 10716 | config: Config{ |
| 10717 | MaxVersion: VersionTLS13, |
| 10718 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10719 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10720 | }, |
| 10721 | DefaultCurves: []CurveID{}, |
| 10722 | }, |
| 10723 | }) |
| 10724 | |
| 10725 | testCases = append(testCases, testCase{ |
| 10726 | testType: serverTest, |
| 10727 | name: "SkipEarlyData-HRR-Interleaved", |
| 10728 | config: Config{ |
| 10729 | MaxVersion: VersionTLS13, |
| 10730 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10731 | SendFakeEarlyDataLength: 4, |
| 10732 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10733 | }, |
| 10734 | DefaultCurves: []CurveID{}, |
| 10735 | }, |
| 10736 | shouldFail: true, |
| 10737 | expectedError: ":UNEXPECTED_RECORD:", |
| 10738 | }) |
| 10739 | |
| 10740 | testCases = append(testCases, testCase{ |
| 10741 | testType: serverTest, |
| 10742 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10743 | config: Config{ |
| 10744 | MaxVersion: VersionTLS13, |
| 10745 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10746 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10747 | }, |
| 10748 | DefaultCurves: []CurveID{}, |
| 10749 | }, |
| 10750 | shouldFail: true, |
| 10751 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10752 | }) |
| 10753 | |
| 10754 | // Test that skipping early data looking for cleartext correctly |
| 10755 | // processes an alert record. |
| 10756 | testCases = append(testCases, testCase{ |
| 10757 | testType: serverTest, |
| 10758 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10759 | config: Config{ |
| 10760 | MaxVersion: VersionTLS13, |
| 10761 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10762 | SendEarlyAlert: true, |
| 10763 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10764 | }, |
| 10765 | DefaultCurves: []CurveID{}, |
| 10766 | }, |
| 10767 | shouldFail: true, |
| 10768 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10769 | }) |
| 10770 | |
| 10771 | testCases = append(testCases, testCase{ |
| 10772 | testType: serverTest, |
| 10773 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10774 | config: Config{ |
| 10775 | MaxVersion: VersionTLS13, |
| 10776 | Bugs: ProtocolBugs{ |
| 10777 | SendEarlyDataOnSecondClientHello: true, |
| 10778 | }, |
| 10779 | DefaultCurves: []CurveID{}, |
| 10780 | }, |
| 10781 | shouldFail: true, |
| 10782 | expectedLocalError: "remote error: bad record MAC", |
| 10783 | }) |
| 10784 | |
| 10785 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10786 | testType: clientTest, |
| 10787 | name: "EmptyEncryptedExtensions", |
| 10788 | config: Config{ |
| 10789 | MaxVersion: VersionTLS13, |
| 10790 | Bugs: ProtocolBugs{ |
| 10791 | EmptyEncryptedExtensions: true, |
| 10792 | }, |
| 10793 | }, |
| 10794 | shouldFail: true, |
| 10795 | expectedLocalError: "remote error: error decoding message", |
| 10796 | }) |
| 10797 | |
| 10798 | testCases = append(testCases, testCase{ |
| 10799 | testType: clientTest, |
| 10800 | name: "EncryptedExtensionsWithKeyShare", |
| 10801 | config: Config{ |
| 10802 | MaxVersion: VersionTLS13, |
| 10803 | Bugs: ProtocolBugs{ |
| 10804 | EncryptedExtensionsWithKeyShare: true, |
| 10805 | }, |
| 10806 | }, |
| 10807 | shouldFail: true, |
| 10808 | expectedLocalError: "remote error: unsupported extension", |
| 10809 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10810 | |
| 10811 | testCases = append(testCases, testCase{ |
| 10812 | testType: serverTest, |
| 10813 | name: "SendHelloRetryRequest", |
| 10814 | config: Config{ |
| 10815 | MaxVersion: VersionTLS13, |
| 10816 | // Require a HelloRetryRequest for every curve. |
| 10817 | DefaultCurves: []CurveID{}, |
| 10818 | }, |
| 10819 | expectedCurveID: CurveX25519, |
| 10820 | }) |
| 10821 | |
| 10822 | testCases = append(testCases, testCase{ |
| 10823 | testType: serverTest, |
| 10824 | name: "SendHelloRetryRequest-2", |
| 10825 | config: Config{ |
| 10826 | MaxVersion: VersionTLS13, |
| 10827 | DefaultCurves: []CurveID{CurveP384}, |
| 10828 | }, |
| 10829 | // Although the ClientHello did not predict our preferred curve, |
| 10830 | // we always select it whether it is predicted or not. |
| 10831 | expectedCurveID: CurveX25519, |
| 10832 | }) |
| 10833 | |
| 10834 | testCases = append(testCases, testCase{ |
| 10835 | name: "UnknownCurve-HelloRetryRequest", |
| 10836 | config: Config{ |
| 10837 | MaxVersion: VersionTLS13, |
| 10838 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10839 | CurvePreferences: []CurveID{CurveP384}, |
| 10840 | Bugs: ProtocolBugs{ |
| 10841 | SendHelloRetryRequestCurve: bogusCurve, |
| 10842 | }, |
| 10843 | }, |
| 10844 | shouldFail: true, |
| 10845 | expectedError: ":WRONG_CURVE:", |
| 10846 | }) |
| 10847 | |
| 10848 | testCases = append(testCases, testCase{ |
| 10849 | name: "DisabledCurve-HelloRetryRequest", |
| 10850 | config: Config{ |
| 10851 | MaxVersion: VersionTLS13, |
| 10852 | CurvePreferences: []CurveID{CurveP256}, |
| 10853 | Bugs: ProtocolBugs{ |
| 10854 | IgnorePeerCurvePreferences: true, |
| 10855 | }, |
| 10856 | }, |
| 10857 | flags: []string{"-p384-only"}, |
| 10858 | shouldFail: true, |
| 10859 | expectedError: ":WRONG_CURVE:", |
| 10860 | }) |
| 10861 | |
| 10862 | testCases = append(testCases, testCase{ |
| 10863 | name: "UnnecessaryHelloRetryRequest", |
| 10864 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10865 | MaxVersion: VersionTLS13, |
| 10866 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10867 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10868 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10869 | }, |
| 10870 | }, |
| 10871 | shouldFail: true, |
| 10872 | expectedError: ":WRONG_CURVE:", |
| 10873 | }) |
| 10874 | |
| 10875 | testCases = append(testCases, testCase{ |
| 10876 | name: "SecondHelloRetryRequest", |
| 10877 | config: Config{ |
| 10878 | MaxVersion: VersionTLS13, |
| 10879 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10880 | CurvePreferences: []CurveID{CurveP384}, |
| 10881 | Bugs: ProtocolBugs{ |
| 10882 | SecondHelloRetryRequest: true, |
| 10883 | }, |
| 10884 | }, |
| 10885 | shouldFail: true, |
| 10886 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10887 | }) |
| 10888 | |
| 10889 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10890 | name: "HelloRetryRequest-Empty", |
| 10891 | config: Config{ |
| 10892 | MaxVersion: VersionTLS13, |
| 10893 | Bugs: ProtocolBugs{ |
| 10894 | AlwaysSendHelloRetryRequest: true, |
| 10895 | }, |
| 10896 | }, |
| 10897 | shouldFail: true, |
| 10898 | expectedError: ":DECODE_ERROR:", |
| 10899 | }) |
| 10900 | |
| 10901 | testCases = append(testCases, testCase{ |
| 10902 | name: "HelloRetryRequest-DuplicateCurve", |
| 10903 | config: Config{ |
| 10904 | MaxVersion: VersionTLS13, |
| 10905 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 10906 | // configuration. Assert this ExpectMissingKeyShare. |
| 10907 | CurvePreferences: []CurveID{CurveP384}, |
| 10908 | Bugs: ProtocolBugs{ |
| 10909 | ExpectMissingKeyShare: true, |
| 10910 | DuplicateHelloRetryRequestExtensions: true, |
| 10911 | }, |
| 10912 | }, |
| 10913 | shouldFail: true, |
| 10914 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10915 | expectedLocalError: "remote error: illegal parameter", |
| 10916 | }) |
| 10917 | |
| 10918 | testCases = append(testCases, testCase{ |
| 10919 | name: "HelloRetryRequest-Cookie", |
| 10920 | config: Config{ |
| 10921 | MaxVersion: VersionTLS13, |
| 10922 | Bugs: ProtocolBugs{ |
| 10923 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10924 | }, |
| 10925 | }, |
| 10926 | }) |
| 10927 | |
| 10928 | testCases = append(testCases, testCase{ |
| 10929 | name: "HelloRetryRequest-DuplicateCookie", |
| 10930 | config: Config{ |
| 10931 | MaxVersion: VersionTLS13, |
| 10932 | Bugs: ProtocolBugs{ |
| 10933 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10934 | DuplicateHelloRetryRequestExtensions: true, |
| 10935 | }, |
| 10936 | }, |
| 10937 | shouldFail: true, |
| 10938 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10939 | expectedLocalError: "remote error: illegal parameter", |
| 10940 | }) |
| 10941 | |
| 10942 | testCases = append(testCases, testCase{ |
| 10943 | name: "HelloRetryRequest-EmptyCookie", |
| 10944 | config: Config{ |
| 10945 | MaxVersion: VersionTLS13, |
| 10946 | Bugs: ProtocolBugs{ |
| 10947 | SendHelloRetryRequestCookie: []byte{}, |
| 10948 | }, |
| 10949 | }, |
| 10950 | shouldFail: true, |
| 10951 | expectedError: ":DECODE_ERROR:", |
| 10952 | }) |
| 10953 | |
| 10954 | testCases = append(testCases, testCase{ |
| 10955 | name: "HelloRetryRequest-Cookie-Curve", |
| 10956 | config: Config{ |
| 10957 | MaxVersion: VersionTLS13, |
| 10958 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10959 | CurvePreferences: []CurveID{CurveP384}, |
| 10960 | Bugs: ProtocolBugs{ |
| 10961 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10962 | ExpectMissingKeyShare: true, |
| 10963 | }, |
| 10964 | }, |
| 10965 | }) |
| 10966 | |
| 10967 | testCases = append(testCases, testCase{ |
| 10968 | name: "HelloRetryRequest-Unknown", |
| 10969 | config: Config{ |
| 10970 | MaxVersion: VersionTLS13, |
| 10971 | Bugs: ProtocolBugs{ |
| 10972 | CustomHelloRetryRequestExtension: "extension", |
| 10973 | }, |
| 10974 | }, |
| 10975 | shouldFail: true, |
| 10976 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10977 | expectedLocalError: "remote error: unsupported extension", |
| 10978 | }) |
| 10979 | |
| 10980 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10981 | testType: serverTest, |
| 10982 | name: "SecondClientHelloMissingKeyShare", |
| 10983 | config: Config{ |
| 10984 | MaxVersion: VersionTLS13, |
| 10985 | DefaultCurves: []CurveID{}, |
| 10986 | Bugs: ProtocolBugs{ |
| 10987 | SecondClientHelloMissingKeyShare: true, |
| 10988 | }, |
| 10989 | }, |
| 10990 | shouldFail: true, |
| 10991 | expectedError: ":MISSING_KEY_SHARE:", |
| 10992 | }) |
| 10993 | |
| 10994 | testCases = append(testCases, testCase{ |
| 10995 | testType: serverTest, |
| 10996 | name: "SecondClientHelloWrongCurve", |
| 10997 | config: Config{ |
| 10998 | MaxVersion: VersionTLS13, |
| 10999 | DefaultCurves: []CurveID{}, |
| 11000 | Bugs: ProtocolBugs{ |
| 11001 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 11002 | }, |
| 11003 | }, |
| 11004 | shouldFail: true, |
| 11005 | expectedError: ":WRONG_CURVE:", |
| 11006 | }) |
| 11007 | |
| 11008 | testCases = append(testCases, testCase{ |
| 11009 | name: "HelloRetryRequestVersionMismatch", |
| 11010 | config: Config{ |
| 11011 | MaxVersion: VersionTLS13, |
| 11012 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11013 | CurvePreferences: []CurveID{CurveP384}, |
| 11014 | Bugs: ProtocolBugs{ |
| 11015 | SendServerHelloVersion: 0x0305, |
| 11016 | }, |
| 11017 | }, |
| 11018 | shouldFail: true, |
| 11019 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11020 | }) |
| 11021 | |
| 11022 | testCases = append(testCases, testCase{ |
| 11023 | name: "HelloRetryRequestCurveMismatch", |
| 11024 | config: Config{ |
| 11025 | MaxVersion: VersionTLS13, |
| 11026 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11027 | CurvePreferences: []CurveID{CurveP384}, |
| 11028 | Bugs: ProtocolBugs{ |
| 11029 | // Send P-384 (correct) in the HelloRetryRequest. |
| 11030 | SendHelloRetryRequestCurve: CurveP384, |
| 11031 | // But send P-256 in the ServerHello. |
| 11032 | SendCurve: CurveP256, |
| 11033 | }, |
| 11034 | }, |
| 11035 | shouldFail: true, |
| 11036 | expectedError: ":WRONG_CURVE:", |
| 11037 | }) |
| 11038 | |
| 11039 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 11040 | // without sending it. |
| 11041 | testCases = append(testCases, testCase{ |
| 11042 | name: "SkipHelloRetryRequest", |
| 11043 | config: Config{ |
| 11044 | MaxVersion: VersionTLS13, |
| 11045 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11046 | CurvePreferences: []CurveID{CurveP384}, |
| 11047 | Bugs: ProtocolBugs{ |
| 11048 | SkipHelloRetryRequest: true, |
| 11049 | }, |
| 11050 | }, |
| 11051 | shouldFail: true, |
| 11052 | expectedError: ":WRONG_CURVE:", |
| 11053 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 11054 | |
| 11055 | testCases = append(testCases, testCase{ |
| 11056 | name: "TLS13-RequestContextInHandshake", |
| 11057 | config: Config{ |
| 11058 | MaxVersion: VersionTLS13, |
| 11059 | MinVersion: VersionTLS13, |
| 11060 | ClientAuth: RequireAnyClientCert, |
| 11061 | Bugs: ProtocolBugs{ |
| 11062 | SendRequestContext: []byte("request context"), |
| 11063 | }, |
| 11064 | }, |
| 11065 | flags: []string{ |
| 11066 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11067 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 11068 | }, |
| 11069 | shouldFail: true, |
| 11070 | expectedError: ":DECODE_ERROR:", |
| 11071 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 11072 | |
| 11073 | testCases = append(testCases, testCase{ |
| 11074 | testType: serverTest, |
| 11075 | name: "TLS13-TrailingKeyShareData", |
| 11076 | config: Config{ |
| 11077 | MaxVersion: VersionTLS13, |
| 11078 | Bugs: ProtocolBugs{ |
| 11079 | TrailingKeyShareData: true, |
| 11080 | }, |
| 11081 | }, |
| 11082 | shouldFail: true, |
| 11083 | expectedError: ":DECODE_ERROR:", |
| 11084 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 11085 | |
| 11086 | testCases = append(testCases, testCase{ |
| 11087 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 11088 | config: Config{ |
| 11089 | MaxVersion: VersionTLS13, |
| 11090 | Bugs: ProtocolBugs{ |
| 11091 | AlwaysSelectPSKIdentity: true, |
| 11092 | }, |
| 11093 | }, |
| 11094 | shouldFail: true, |
| 11095 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11096 | }) |
| 11097 | |
| 11098 | testCases = append(testCases, testCase{ |
| 11099 | name: "TLS13-InvalidPSKIdentity", |
| 11100 | config: Config{ |
| 11101 | MaxVersion: VersionTLS13, |
| 11102 | Bugs: ProtocolBugs{ |
| 11103 | SelectPSKIdentityOnResume: 1, |
| 11104 | }, |
| 11105 | }, |
| 11106 | resumeSession: true, |
| 11107 | shouldFail: true, |
| 11108 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 11109 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11110 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11111 | testCases = append(testCases, testCase{ |
| 11112 | testType: serverTest, |
| 11113 | name: "TLS13-ExtraPSKIdentity", |
| 11114 | config: Config{ |
| 11115 | MaxVersion: VersionTLS13, |
| 11116 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11117 | ExtraPSKIdentity: true, |
| 11118 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11119 | }, |
| 11120 | }, |
| 11121 | resumeSession: true, |
| 11122 | }) |
| 11123 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11124 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11125 | testCases = append(testCases, testCase{ |
| 11126 | name: "TLS13-CustomTicketExtension", |
| 11127 | config: Config{ |
| 11128 | MaxVersion: VersionTLS13, |
| 11129 | Bugs: ProtocolBugs{ |
| 11130 | CustomTicketExtension: "1234", |
| 11131 | }, |
| 11132 | }, |
| 11133 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11134 | |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11135 | for _, noSessionID := range []bool{false, true} { |
| 11136 | prefix := "TLS13Experiment" |
| 11137 | variant := TLS13Experiment |
| 11138 | if noSessionID { |
| 11139 | prefix = "TLS13NoSessionIDExperiment" |
| 11140 | variant = TLS13NoSessionIDExperiment |
| 11141 | } |
| 11142 | |
| 11143 | // Test that enabling a TLS 1.3 variant does not interfere with |
| 11144 | // TLS 1.2 session ID resumption. |
| 11145 | testCases = append(testCases, testCase{ |
| 11146 | testType: clientTest, |
| 11147 | name: prefix + "-ResumeTLS12SessionID", |
| 11148 | config: Config{ |
| 11149 | MaxVersion: VersionTLS12, |
| 11150 | SessionTicketsDisabled: true, |
| 11151 | }, |
| 11152 | resumeSession: true, |
| 11153 | flags: []string{"-tls13-variant", strconv.Itoa(variant)}, |
| 11154 | }) |
| 11155 | |
| 11156 | // Test that the server correctly echoes back session IDs of |
| 11157 | // various lengths. |
| 11158 | testCases = append(testCases, testCase{ |
| 11159 | testType: serverTest, |
| 11160 | name: prefix + "-EmptySessionID", |
| 11161 | config: Config{ |
| 11162 | MaxVersion: VersionTLS13, |
| 11163 | Bugs: ProtocolBugs{ |
| 11164 | SendClientHelloSessionID: []byte{}, |
| 11165 | }, |
| 11166 | }, |
| 11167 | tls13Variant: variant, |
| 11168 | }) |
| 11169 | |
| 11170 | testCases = append(testCases, testCase{ |
| 11171 | testType: serverTest, |
| 11172 | name: prefix + "-ShortSessionID", |
| 11173 | config: Config{ |
| 11174 | MaxVersion: VersionTLS13, |
| 11175 | Bugs: ProtocolBugs{ |
| 11176 | SendClientHelloSessionID: make([]byte, 16), |
| 11177 | }, |
| 11178 | }, |
| 11179 | tls13Variant: variant, |
| 11180 | }) |
| 11181 | |
| 11182 | testCases = append(testCases, testCase{ |
| 11183 | testType: serverTest, |
| 11184 | name: prefix + "-FullSessionID", |
| 11185 | config: Config{ |
| 11186 | MaxVersion: VersionTLS13, |
| 11187 | Bugs: ProtocolBugs{ |
| 11188 | SendClientHelloSessionID: make([]byte, 32), |
| 11189 | }, |
| 11190 | }, |
| 11191 | tls13Variant: variant, |
| 11192 | }) |
| 11193 | } |
| 11194 | |
| 11195 | // Test that the client sends a fake session ID in TLS13Experiment. |
| 11196 | testCases = append(testCases, testCase{ |
| 11197 | testType: clientTest, |
| 11198 | name: "TLS13Experiment-RequireSessionID", |
| 11199 | config: Config{ |
| 11200 | MaxVersion: VersionTLS13, |
| 11201 | Bugs: ProtocolBugs{ |
| 11202 | ExpectClientHelloSessionID: true, |
| 11203 | }, |
| 11204 | }, |
| 11205 | tls13Variant: TLS13Experiment, |
| 11206 | }) |
| 11207 | |
| 11208 | // Test that the client does not send a fake session ID in |
| 11209 | // TLS13NoSessionIDExperiment. |
| 11210 | testCases = append(testCases, testCase{ |
| 11211 | testType: clientTest, |
| 11212 | name: "TLS13NoSessionIDExperiment-RequireEmptySessionID", |
| 11213 | config: Config{ |
| 11214 | MaxVersion: VersionTLS13, |
| 11215 | Bugs: ProtocolBugs{ |
| 11216 | ExpectEmptyClientHelloSessionID: true, |
| 11217 | }, |
| 11218 | }, |
| 11219 | tls13Variant: TLS13NoSessionIDExperiment, |
| 11220 | }) |
| 11221 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11222 | testCases = append(testCases, testCase{ |
| 11223 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11224 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11225 | config: Config{ |
| 11226 | MaxVersion: VersionTLS13, |
| 11227 | MaxEarlyDataSize: 16384, |
| 11228 | }, |
| 11229 | resumeConfig: &Config{ |
| 11230 | MaxVersion: VersionTLS13, |
| 11231 | MaxEarlyDataSize: 16384, |
| 11232 | Bugs: ProtocolBugs{ |
| 11233 | AlwaysRejectEarlyData: true, |
| 11234 | }, |
| 11235 | }, |
| 11236 | resumeSession: true, |
| 11237 | flags: []string{ |
| 11238 | "-enable-early-data", |
| 11239 | "-expect-early-data-info", |
| 11240 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11241 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11242 | }, |
| 11243 | }) |
| 11244 | |
| 11245 | testCases = append(testCases, testCase{ |
| 11246 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11247 | name: "TLS13Experiment-EarlyData-Reject-Client", |
| 11248 | config: Config{ |
| 11249 | MaxVersion: VersionTLS13, |
| 11250 | MaxEarlyDataSize: 16384, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11251 | }, |
| 11252 | resumeConfig: &Config{ |
| 11253 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11254 | MaxEarlyDataSize: 16384, |
| 11255 | Bugs: ProtocolBugs{ |
| 11256 | AlwaysRejectEarlyData: true, |
| 11257 | }, |
| 11258 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11259 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11260 | resumeSession: true, |
| 11261 | flags: []string{ |
| 11262 | "-enable-early-data", |
| 11263 | "-expect-early-data-info", |
| 11264 | "-expect-reject-early-data", |
| 11265 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11266 | }, |
| 11267 | }) |
| 11268 | |
| 11269 | testCases = append(testCases, testCase{ |
| 11270 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11271 | name: "TLS13RecordTypeExperiment-EarlyData-Reject-Client", |
| 11272 | config: Config{ |
| 11273 | MaxVersion: VersionTLS13, |
| 11274 | MaxEarlyDataSize: 16384, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11275 | }, |
| 11276 | resumeConfig: &Config{ |
| 11277 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11278 | MaxEarlyDataSize: 16384, |
| 11279 | Bugs: ProtocolBugs{ |
| 11280 | AlwaysRejectEarlyData: true, |
| 11281 | }, |
| 11282 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11283 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11284 | resumeSession: true, |
| 11285 | flags: []string{ |
| 11286 | "-enable-early-data", |
| 11287 | "-expect-early-data-info", |
| 11288 | "-expect-reject-early-data", |
| 11289 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11290 | }, |
| 11291 | }) |
| 11292 | |
| 11293 | testCases = append(testCases, testCase{ |
| 11294 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11295 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11296 | config: Config{ |
| 11297 | MaxVersion: VersionTLS13, |
| 11298 | MaxEarlyDataSize: 16384, |
| 11299 | Certificates: []Certificate{rsaCertificate}, |
| 11300 | }, |
| 11301 | resumeConfig: &Config{ |
| 11302 | MaxVersion: VersionTLS13, |
| 11303 | MaxEarlyDataSize: 16384, |
| 11304 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11305 | SessionTicketsDisabled: true, |
| 11306 | }, |
| 11307 | resumeSession: true, |
| 11308 | expectResumeRejected: true, |
| 11309 | flags: []string{ |
| 11310 | "-enable-early-data", |
| 11311 | "-expect-early-data-info", |
| 11312 | "-expect-reject-early-data", |
| 11313 | "-on-resume-shim-writes-first", |
| 11314 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11315 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11316 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11317 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11318 | "-on-retry-expect-no-session", |
| 11319 | }, |
| 11320 | }) |
| 11321 | |
| 11322 | testCases = append(testCases, testCase{ |
| 11323 | testType: clientTest, |
| 11324 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11325 | config: Config{ |
| 11326 | MaxVersion: VersionTLS13, |
| 11327 | MaxEarlyDataSize: 16384, |
| 11328 | }, |
| 11329 | resumeConfig: &Config{ |
| 11330 | MaxVersion: VersionTLS13, |
| 11331 | MaxEarlyDataSize: 16384, |
| 11332 | Bugs: ProtocolBugs{ |
| 11333 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11334 | }, |
| 11335 | }, |
| 11336 | resumeSession: true, |
| 11337 | flags: []string{ |
| 11338 | "-enable-early-data", |
| 11339 | "-expect-early-data-info", |
| 11340 | "-expect-reject-early-data", |
| 11341 | }, |
| 11342 | }) |
| 11343 | |
| 11344 | // The client must check the server does not send the early_data |
| 11345 | // extension while rejecting the session. |
| 11346 | testCases = append(testCases, testCase{ |
| 11347 | testType: clientTest, |
| 11348 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11349 | config: Config{ |
| 11350 | MaxVersion: VersionTLS13, |
| 11351 | MaxEarlyDataSize: 16384, |
| 11352 | }, |
| 11353 | resumeConfig: &Config{ |
| 11354 | MaxVersion: VersionTLS13, |
| 11355 | SessionTicketsDisabled: true, |
| 11356 | Bugs: ProtocolBugs{ |
| 11357 | SendEarlyDataExtension: true, |
| 11358 | }, |
| 11359 | }, |
| 11360 | resumeSession: true, |
| 11361 | flags: []string{ |
| 11362 | "-enable-early-data", |
| 11363 | "-expect-early-data-info", |
| 11364 | }, |
| 11365 | shouldFail: true, |
| 11366 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11367 | }) |
| 11368 | |
| 11369 | // The client must fail with a dedicated error code if the server |
| 11370 | // responds with TLS 1.2 when offering 0-RTT. |
| 11371 | testCases = append(testCases, testCase{ |
| 11372 | testType: clientTest, |
| 11373 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11374 | config: Config{ |
| 11375 | MaxVersion: VersionTLS13, |
| 11376 | MaxEarlyDataSize: 16384, |
| 11377 | }, |
| 11378 | resumeConfig: &Config{ |
| 11379 | MaxVersion: VersionTLS12, |
| 11380 | }, |
| 11381 | resumeSession: true, |
| 11382 | flags: []string{ |
| 11383 | "-enable-early-data", |
| 11384 | "-expect-early-data-info", |
| 11385 | }, |
| 11386 | shouldFail: true, |
| 11387 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11388 | }) |
| 11389 | |
| 11390 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11391 | // the server sent an HRR. |
| 11392 | testCases = append(testCases, testCase{ |
| 11393 | testType: clientTest, |
| 11394 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11395 | config: Config{ |
| 11396 | MaxVersion: VersionTLS13, |
| 11397 | MaxEarlyDataSize: 16384, |
| 11398 | }, |
| 11399 | resumeConfig: &Config{ |
| 11400 | MaxVersion: VersionTLS13, |
| 11401 | MaxEarlyDataSize: 16384, |
| 11402 | Bugs: ProtocolBugs{ |
| 11403 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11404 | SendEarlyDataExtension: true, |
| 11405 | }, |
| 11406 | }, |
| 11407 | resumeSession: true, |
| 11408 | flags: []string{ |
| 11409 | "-enable-early-data", |
| 11410 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11411 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11412 | }, |
| 11413 | shouldFail: true, |
| 11414 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11415 | }) |
| 11416 | |
| 11417 | fooString := "foo" |
| 11418 | barString := "bar" |
| 11419 | |
| 11420 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11421 | // that changed it. |
| 11422 | testCases = append(testCases, testCase{ |
| 11423 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11424 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11425 | config: Config{ |
| 11426 | MaxVersion: VersionTLS13, |
| 11427 | MaxEarlyDataSize: 16384, |
| 11428 | Bugs: ProtocolBugs{ |
| 11429 | ALPNProtocol: &fooString, |
| 11430 | }, |
| 11431 | }, |
| 11432 | resumeConfig: &Config{ |
| 11433 | MaxVersion: VersionTLS13, |
| 11434 | MaxEarlyDataSize: 16384, |
| 11435 | Bugs: ProtocolBugs{ |
| 11436 | ALPNProtocol: &barString, |
| 11437 | }, |
| 11438 | }, |
| 11439 | resumeSession: true, |
| 11440 | flags: []string{ |
| 11441 | "-advertise-alpn", "\x03foo\x03bar", |
| 11442 | "-enable-early-data", |
| 11443 | "-expect-early-data-info", |
| 11444 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11445 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11446 | "-on-resume-expect-alpn", "foo", |
| 11447 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11448 | }, |
| 11449 | }) |
| 11450 | |
| 11451 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11452 | // ALPN was omitted from the first connection. |
| 11453 | testCases = append(testCases, testCase{ |
| 11454 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11455 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11456 | config: Config{ |
| 11457 | MaxVersion: VersionTLS13, |
| 11458 | MaxEarlyDataSize: 16384, |
| 11459 | }, |
| 11460 | resumeConfig: &Config{ |
| 11461 | MaxVersion: VersionTLS13, |
| 11462 | MaxEarlyDataSize: 16384, |
| 11463 | NextProtos: []string{"foo"}, |
| 11464 | }, |
| 11465 | resumeSession: true, |
| 11466 | flags: []string{ |
| 11467 | "-advertise-alpn", "\x03foo\x03bar", |
| 11468 | "-enable-early-data", |
| 11469 | "-expect-early-data-info", |
| 11470 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11471 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11472 | "-on-resume-expect-alpn", "", |
| 11473 | "-on-retry-expect-alpn", "foo", |
| 11474 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11475 | }, |
| 11476 | }) |
| 11477 | |
| 11478 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11479 | // ALPN was omitted from the second connection. |
| 11480 | testCases = append(testCases, testCase{ |
| 11481 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11482 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11483 | config: Config{ |
| 11484 | MaxVersion: VersionTLS13, |
| 11485 | MaxEarlyDataSize: 16384, |
| 11486 | NextProtos: []string{"foo"}, |
| 11487 | }, |
| 11488 | resumeConfig: &Config{ |
| 11489 | MaxVersion: VersionTLS13, |
| 11490 | MaxEarlyDataSize: 16384, |
| 11491 | }, |
| 11492 | resumeSession: true, |
| 11493 | flags: []string{ |
| 11494 | "-advertise-alpn", "\x03foo\x03bar", |
| 11495 | "-enable-early-data", |
| 11496 | "-expect-early-data-info", |
| 11497 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11498 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11499 | "-on-resume-expect-alpn", "foo", |
| 11500 | "-on-retry-expect-alpn", "", |
| 11501 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11502 | }, |
| 11503 | }) |
| 11504 | |
| 11505 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11506 | testCases = append(testCases, testCase{ |
| 11507 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11508 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11509 | config: Config{ |
| 11510 | MaxVersion: VersionTLS13, |
| 11511 | MaxEarlyDataSize: 16384, |
| 11512 | Bugs: ProtocolBugs{ |
| 11513 | ALPNProtocol: &fooString, |
| 11514 | }, |
| 11515 | }, |
| 11516 | resumeConfig: &Config{ |
| 11517 | MaxVersion: VersionTLS13, |
| 11518 | MaxEarlyDataSize: 16384, |
| 11519 | Bugs: ProtocolBugs{ |
| 11520 | AlwaysAcceptEarlyData: true, |
| 11521 | ALPNProtocol: &barString, |
| 11522 | }, |
| 11523 | }, |
| 11524 | resumeSession: true, |
| 11525 | flags: []string{ |
| 11526 | "-advertise-alpn", "\x03foo\x03bar", |
| 11527 | "-enable-early-data", |
| 11528 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11529 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11530 | "-on-resume-expect-alpn", "foo", |
| 11531 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11532 | }, |
| 11533 | shouldFail: true, |
| 11534 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11535 | }) |
| 11536 | |
| 11537 | // Test that the server correctly rejects 0-RTT when the previous |
| 11538 | // session did not allow early data on resumption. |
| 11539 | testCases = append(testCases, testCase{ |
| 11540 | testType: serverTest, |
| 11541 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11542 | config: Config{ |
| 11543 | MaxVersion: VersionTLS13, |
| 11544 | }, |
| 11545 | resumeConfig: &Config{ |
| 11546 | MaxVersion: VersionTLS13, |
| 11547 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11548 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11549 | ExpectEarlyDataAccepted: false, |
| 11550 | }, |
| 11551 | }, |
| 11552 | resumeSession: true, |
| 11553 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11554 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11555 | "-expect-reject-early-data", |
| 11556 | }, |
| 11557 | }) |
| 11558 | |
| 11559 | // Test that we reject early data where ALPN is omitted from the first |
| 11560 | // connection. |
| 11561 | testCases = append(testCases, testCase{ |
| 11562 | testType: serverTest, |
| 11563 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11564 | config: Config{ |
| 11565 | MaxVersion: VersionTLS13, |
| 11566 | NextProtos: []string{}, |
| 11567 | }, |
| 11568 | resumeConfig: &Config{ |
| 11569 | MaxVersion: VersionTLS13, |
| 11570 | NextProtos: []string{"foo"}, |
| 11571 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11572 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11573 | ExpectEarlyDataAccepted: false, |
| 11574 | }, |
| 11575 | }, |
| 11576 | resumeSession: true, |
| 11577 | flags: []string{ |
| 11578 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11579 | "-on-initial-select-alpn", "", |
| 11580 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11581 | }, |
| 11582 | }) |
| 11583 | |
| 11584 | // Test that we reject early data where ALPN is omitted from the second |
| 11585 | // connection. |
| 11586 | testCases = append(testCases, testCase{ |
| 11587 | testType: serverTest, |
| 11588 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11589 | config: Config{ |
| 11590 | MaxVersion: VersionTLS13, |
| 11591 | NextProtos: []string{"foo"}, |
| 11592 | }, |
| 11593 | resumeConfig: &Config{ |
| 11594 | MaxVersion: VersionTLS13, |
| 11595 | NextProtos: []string{}, |
| 11596 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11597 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11598 | ExpectEarlyDataAccepted: false, |
| 11599 | }, |
| 11600 | }, |
| 11601 | resumeSession: true, |
| 11602 | flags: []string{ |
| 11603 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11604 | "-on-initial-select-alpn", "foo", |
| 11605 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11606 | }, |
| 11607 | }) |
| 11608 | |
| 11609 | // Test that we reject early data with mismatched ALPN. |
| 11610 | testCases = append(testCases, testCase{ |
| 11611 | testType: serverTest, |
| 11612 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11613 | config: Config{ |
| 11614 | MaxVersion: VersionTLS13, |
| 11615 | NextProtos: []string{"foo"}, |
| 11616 | }, |
| 11617 | resumeConfig: &Config{ |
| 11618 | MaxVersion: VersionTLS13, |
| 11619 | NextProtos: []string{"bar"}, |
| 11620 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11621 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11622 | ExpectEarlyDataAccepted: false, |
| 11623 | }, |
| 11624 | }, |
| 11625 | resumeSession: true, |
| 11626 | flags: []string{ |
| 11627 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11628 | "-on-initial-select-alpn", "foo", |
| 11629 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11630 | }, |
| 11631 | }) |
| 11632 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11633 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11634 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11635 | testCases = append(testCases, testCase{ |
| 11636 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11637 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11638 | config: Config{ |
| 11639 | MaxVersion: VersionTLS13, |
| 11640 | MaxEarlyDataSize: 16384, |
| 11641 | RequestChannelID: true, |
| 11642 | }, |
| 11643 | resumeSession: true, |
| 11644 | expectChannelID: true, |
| 11645 | shouldFail: true, |
| 11646 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 11647 | flags: []string{ |
| 11648 | "-enable-early-data", |
| 11649 | "-expect-early-data-info", |
| 11650 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11651 | }, |
| 11652 | }) |
| 11653 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11654 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11655 | // to decline 0-RTT. |
| 11656 | testCases = append(testCases, testCase{ |
| 11657 | testType: clientTest, |
| 11658 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11659 | config: Config{ |
| 11660 | MaxVersion: VersionTLS13, |
| 11661 | MaxEarlyDataSize: 16384, |
| 11662 | RequestChannelID: true, |
| 11663 | Bugs: ProtocolBugs{ |
| 11664 | AlwaysRejectEarlyData: true, |
| 11665 | }, |
| 11666 | }, |
| 11667 | resumeSession: true, |
| 11668 | expectChannelID: true, |
| 11669 | flags: []string{ |
| 11670 | "-enable-early-data", |
| 11671 | "-expect-early-data-info", |
| 11672 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11673 | "-expect-reject-early-data", |
| 11674 | }, |
| 11675 | }) |
| 11676 | |
| 11677 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11678 | // to decline Channel ID. |
| 11679 | testCases = append(testCases, testCase{ |
| 11680 | testType: clientTest, |
| 11681 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11682 | config: Config{ |
| 11683 | MaxVersion: VersionTLS13, |
| 11684 | MaxEarlyDataSize: 16384, |
| 11685 | }, |
| 11686 | resumeSession: true, |
| 11687 | flags: []string{ |
| 11688 | "-enable-early-data", |
| 11689 | "-expect-early-data-info", |
| 11690 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11691 | "-expect-accept-early-data", |
| 11692 | }, |
| 11693 | }) |
| 11694 | |
| 11695 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11696 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11697 | testCases = append(testCases, testCase{ |
| 11698 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11699 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11700 | config: Config{ |
| 11701 | MaxVersion: VersionTLS13, |
| 11702 | ChannelID: channelIDKey, |
| 11703 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11704 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11705 | ExpectEarlyDataAccepted: false, |
| 11706 | }, |
| 11707 | }, |
| 11708 | resumeSession: true, |
| 11709 | expectChannelID: true, |
| 11710 | flags: []string{ |
| 11711 | "-enable-early-data", |
| 11712 | "-expect-reject-early-data", |
| 11713 | "-expect-channel-id", |
| 11714 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11715 | }, |
| 11716 | }) |
| 11717 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11718 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11719 | // if not offered Channel ID. |
| 11720 | testCases = append(testCases, testCase{ |
| 11721 | testType: serverTest, |
| 11722 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11723 | config: Config{ |
| 11724 | MaxVersion: VersionTLS13, |
| 11725 | Bugs: ProtocolBugs{ |
| 11726 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11727 | ExpectEarlyDataAccepted: true, |
| 11728 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11729 | }, |
| 11730 | }, |
| 11731 | resumeSession: true, |
| 11732 | expectChannelID: false, |
| 11733 | flags: []string{ |
| 11734 | "-enable-early-data", |
| 11735 | "-expect-accept-early-data", |
| 11736 | "-enable-channel-id", |
| 11737 | }, |
| 11738 | }) |
| 11739 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11740 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11741 | // The subsequent records should fail to decrypt. |
| 11742 | testCases = append(testCases, testCase{ |
| 11743 | testType: serverTest, |
| 11744 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11745 | config: Config{ |
| 11746 | MaxVersion: VersionTLS13, |
| 11747 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11748 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11749 | ExpectEarlyDataAccepted: true, |
| 11750 | SkipEndOfEarlyData: true, |
| 11751 | }, |
| 11752 | }, |
| 11753 | resumeSession: true, |
| 11754 | flags: []string{"-enable-early-data"}, |
| 11755 | shouldFail: true, |
| 11756 | expectedLocalError: "remote error: bad record MAC", |
| 11757 | expectedError: ":BAD_DECRYPT:", |
| 11758 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11759 | |
| 11760 | testCases = append(testCases, testCase{ |
| 11761 | testType: serverTest, |
| 11762 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11763 | config: Config{ |
| 11764 | MaxVersion: VersionTLS13, |
| 11765 | }, |
| 11766 | resumeConfig: &Config{ |
| 11767 | MaxVersion: VersionTLS13, |
| 11768 | Bugs: ProtocolBugs{ |
| 11769 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11770 | SendStrayEarlyHandshake: true, |
| 11771 | ExpectEarlyDataAccepted: true}, |
| 11772 | }, |
| 11773 | resumeSession: true, |
| 11774 | shouldFail: true, |
| 11775 | expectedError: ":UNEXPECTED_RECORD:", |
| 11776 | expectedLocalError: "remote error: unexpected message", |
| 11777 | flags: []string{ |
| 11778 | "-enable-early-data", |
| 11779 | }, |
| 11780 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11781 | |
| 11782 | // Test that the client reports TLS 1.3 as the version while sending |
| 11783 | // early data. |
| 11784 | testCases = append(testCases, testCase{ |
| 11785 | testType: clientTest, |
| 11786 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11787 | config: Config{ |
| 11788 | MaxVersion: VersionTLS13, |
| 11789 | MaxEarlyDataSize: 16384, |
| 11790 | }, |
| 11791 | resumeSession: true, |
| 11792 | flags: []string{ |
| 11793 | "-enable-early-data", |
| 11794 | "-expect-early-data-info", |
| 11795 | "-expect-accept-early-data", |
| 11796 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11797 | }, |
| 11798 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11799 | } |
| 11800 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11801 | func addTLS13CipherPreferenceTests() { |
| 11802 | // Test that client preference is honored if the shim has AES hardware |
| 11803 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 11804 | testCases = append(testCases, testCase{ |
| 11805 | testType: serverTest, |
| 11806 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 11807 | config: Config{ |
| 11808 | MaxVersion: VersionTLS13, |
| 11809 | CipherSuites: []uint16{ |
| 11810 | TLS_CHACHA20_POLY1305_SHA256, |
| 11811 | TLS_AES_128_GCM_SHA256, |
| 11812 | }, |
| 11813 | }, |
| 11814 | flags: []string{ |
| 11815 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11816 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11817 | }, |
| 11818 | }) |
| 11819 | |
| 11820 | testCases = append(testCases, testCase{ |
| 11821 | testType: serverTest, |
| 11822 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 11823 | config: Config{ |
| 11824 | MaxVersion: VersionTLS13, |
| 11825 | CipherSuites: []uint16{ |
| 11826 | TLS_AES_128_GCM_SHA256, |
| 11827 | TLS_CHACHA20_POLY1305_SHA256, |
| 11828 | }, |
| 11829 | }, |
| 11830 | flags: []string{ |
| 11831 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11832 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11833 | }, |
| 11834 | }) |
| 11835 | |
| 11836 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 11837 | // whether it has AES hardware. |
| 11838 | testCases = append(testCases, testCase{ |
| 11839 | name: "TLS13-CipherPreference-Client", |
| 11840 | config: Config{ |
| 11841 | MaxVersion: VersionTLS13, |
| 11842 | // Use the client cipher order. (This is the default but |
| 11843 | // is listed to be explicit.) |
| 11844 | PreferServerCipherSuites: false, |
| 11845 | }, |
| 11846 | flags: []string{ |
| 11847 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11848 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11849 | }, |
| 11850 | }) |
| 11851 | } |
| 11852 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11853 | func addPeekTests() { |
| 11854 | // Test SSL_peek works, including on empty records. |
| 11855 | testCases = append(testCases, testCase{ |
| 11856 | name: "Peek-Basic", |
| 11857 | sendEmptyRecords: 1, |
| 11858 | flags: []string{"-peek-then-read"}, |
| 11859 | }) |
| 11860 | |
| 11861 | // Test SSL_peek can drive the initial handshake. |
| 11862 | testCases = append(testCases, testCase{ |
| 11863 | name: "Peek-ImplicitHandshake", |
| 11864 | flags: []string{ |
| 11865 | "-peek-then-read", |
| 11866 | "-implicit-handshake", |
| 11867 | }, |
| 11868 | }) |
| 11869 | |
| 11870 | // Test SSL_peek can discover and drive a renegotiation. |
| 11871 | testCases = append(testCases, testCase{ |
| 11872 | name: "Peek-Renegotiate", |
| 11873 | config: Config{ |
| 11874 | MaxVersion: VersionTLS12, |
| 11875 | }, |
| 11876 | renegotiate: 1, |
| 11877 | flags: []string{ |
| 11878 | "-peek-then-read", |
| 11879 | "-renegotiate-freely", |
| 11880 | "-expect-total-renegotiations", "1", |
| 11881 | }, |
| 11882 | }) |
| 11883 | |
| 11884 | // Test SSL_peek can discover a close_notify. |
| 11885 | testCases = append(testCases, testCase{ |
| 11886 | name: "Peek-Shutdown", |
| 11887 | config: Config{ |
| 11888 | Bugs: ProtocolBugs{ |
| 11889 | ExpectCloseNotify: true, |
| 11890 | }, |
| 11891 | }, |
| 11892 | flags: []string{ |
| 11893 | "-peek-then-read", |
| 11894 | "-check-close-notify", |
| 11895 | }, |
| 11896 | }) |
| 11897 | |
| 11898 | // Test SSL_peek can discover an alert. |
| 11899 | testCases = append(testCases, testCase{ |
| 11900 | name: "Peek-Alert", |
| 11901 | config: Config{ |
| 11902 | Bugs: ProtocolBugs{ |
| 11903 | SendSpuriousAlert: alertRecordOverflow, |
| 11904 | }, |
| 11905 | }, |
| 11906 | flags: []string{"-peek-then-read"}, |
| 11907 | shouldFail: true, |
| 11908 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 11909 | }) |
| 11910 | |
| 11911 | // Test SSL_peek can handle KeyUpdate. |
| 11912 | testCases = append(testCases, testCase{ |
| 11913 | name: "Peek-KeyUpdate", |
| 11914 | config: Config{ |
| 11915 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11916 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 11917 | sendKeyUpdates: 1, |
| 11918 | keyUpdateRequest: keyUpdateNotRequested, |
| 11919 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11920 | }) |
| 11921 | } |
| 11922 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11923 | func addRecordVersionTests() { |
| 11924 | for _, ver := range tlsVersions { |
| 11925 | // Test that the record version is enforced. |
| 11926 | testCases = append(testCases, testCase{ |
| 11927 | name: "CheckRecordVersion-" + ver.name, |
| 11928 | config: Config{ |
| 11929 | MinVersion: ver.version, |
| 11930 | MaxVersion: ver.version, |
| 11931 | Bugs: ProtocolBugs{ |
| 11932 | SendRecordVersion: 0x03ff, |
| 11933 | }, |
| 11934 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11935 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11936 | shouldFail: true, |
| 11937 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11938 | }) |
| 11939 | |
| 11940 | // Test that the ClientHello may use any record version, for |
| 11941 | // compatibility reasons. |
| 11942 | testCases = append(testCases, testCase{ |
| 11943 | testType: serverTest, |
| 11944 | name: "LooseInitialRecordVersion-" + ver.name, |
| 11945 | config: Config{ |
| 11946 | MinVersion: ver.version, |
| 11947 | MaxVersion: ver.version, |
| 11948 | Bugs: ProtocolBugs{ |
| 11949 | SendInitialRecordVersion: 0x03ff, |
| 11950 | }, |
| 11951 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11952 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11953 | }) |
| 11954 | |
| 11955 | // Test that garbage ClientHello record versions are rejected. |
| 11956 | testCases = append(testCases, testCase{ |
| 11957 | testType: serverTest, |
| 11958 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 11959 | config: Config{ |
| 11960 | MinVersion: ver.version, |
| 11961 | MaxVersion: ver.version, |
| 11962 | Bugs: ProtocolBugs{ |
| 11963 | SendInitialRecordVersion: 0xffff, |
| 11964 | }, |
| 11965 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11966 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11967 | shouldFail: true, |
| 11968 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11969 | }) |
| 11970 | } |
| 11971 | } |
| 11972 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11973 | func addCertificateTests() { |
| 11974 | // Test that a certificate chain with intermediate may be sent and |
| 11975 | // received as both client and server. |
| 11976 | for _, ver := range tlsVersions { |
| 11977 | testCases = append(testCases, testCase{ |
| 11978 | testType: clientTest, |
| 11979 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 11980 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11981 | MinVersion: ver.version, |
| 11982 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11983 | Certificates: []Certificate{rsaChainCertificate}, |
| 11984 | ClientAuth: RequireAnyClientCert, |
| 11985 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11986 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11987 | expectPeerCertificate: &rsaChainCertificate, |
| 11988 | flags: []string{ |
| 11989 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11990 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11991 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11992 | }, |
| 11993 | }) |
| 11994 | |
| 11995 | testCases = append(testCases, testCase{ |
| 11996 | testType: serverTest, |
| 11997 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 11998 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11999 | MinVersion: ver.version, |
| 12000 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12001 | Certificates: []Certificate{rsaChainCertificate}, |
| 12002 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12003 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12004 | expectPeerCertificate: &rsaChainCertificate, |
| 12005 | flags: []string{ |
| 12006 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12007 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12008 | "-require-any-client-certificate", |
| 12009 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12010 | }, |
| 12011 | }) |
| 12012 | } |
| 12013 | } |
| 12014 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12015 | func addRetainOnlySHA256ClientCertTests() { |
| 12016 | for _, ver := range tlsVersions { |
| 12017 | // Test that enabling |
| 12018 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 12019 | // actually requesting a client certificate is a no-op. |
| 12020 | testCases = append(testCases, testCase{ |
| 12021 | testType: serverTest, |
| 12022 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 12023 | config: Config{ |
| 12024 | MinVersion: ver.version, |
| 12025 | MaxVersion: ver.version, |
| 12026 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12027 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12028 | flags: []string{ |
| 12029 | "-retain-only-sha256-client-cert-initial", |
| 12030 | "-retain-only-sha256-client-cert-resume", |
| 12031 | }, |
| 12032 | resumeSession: true, |
| 12033 | }) |
| 12034 | |
| 12035 | // Test that when retaining only a SHA-256 certificate is |
| 12036 | // enabled, the hash appears as expected. |
| 12037 | testCases = append(testCases, testCase{ |
| 12038 | testType: serverTest, |
| 12039 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 12040 | config: Config{ |
| 12041 | MinVersion: ver.version, |
| 12042 | MaxVersion: ver.version, |
| 12043 | Certificates: []Certificate{rsaCertificate}, |
| 12044 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12045 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12046 | flags: []string{ |
| 12047 | "-verify-peer", |
| 12048 | "-retain-only-sha256-client-cert-initial", |
| 12049 | "-retain-only-sha256-client-cert-resume", |
| 12050 | "-expect-sha256-client-cert-initial", |
| 12051 | "-expect-sha256-client-cert-resume", |
| 12052 | }, |
| 12053 | resumeSession: true, |
| 12054 | }) |
| 12055 | |
| 12056 | // Test that when the config changes from on to off, a |
| 12057 | // resumption is rejected because the server now wants the full |
| 12058 | // certificate chain. |
| 12059 | testCases = append(testCases, testCase{ |
| 12060 | testType: serverTest, |
| 12061 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 12062 | config: Config{ |
| 12063 | MinVersion: ver.version, |
| 12064 | MaxVersion: ver.version, |
| 12065 | Certificates: []Certificate{rsaCertificate}, |
| 12066 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12067 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12068 | flags: []string{ |
| 12069 | "-verify-peer", |
| 12070 | "-retain-only-sha256-client-cert-initial", |
| 12071 | "-expect-sha256-client-cert-initial", |
| 12072 | }, |
| 12073 | resumeSession: true, |
| 12074 | expectResumeRejected: true, |
| 12075 | }) |
| 12076 | |
| 12077 | // Test that when the config changes from off to on, a |
| 12078 | // resumption is rejected because the server now wants just the |
| 12079 | // hash. |
| 12080 | testCases = append(testCases, testCase{ |
| 12081 | testType: serverTest, |
| 12082 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 12083 | config: Config{ |
| 12084 | MinVersion: ver.version, |
| 12085 | MaxVersion: ver.version, |
| 12086 | Certificates: []Certificate{rsaCertificate}, |
| 12087 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12088 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12089 | flags: []string{ |
| 12090 | "-verify-peer", |
| 12091 | "-retain-only-sha256-client-cert-resume", |
| 12092 | "-expect-sha256-client-cert-resume", |
| 12093 | }, |
| 12094 | resumeSession: true, |
| 12095 | expectResumeRejected: true, |
| 12096 | }) |
| 12097 | } |
| 12098 | } |
| 12099 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12100 | func addECDSAKeyUsageTests() { |
| 12101 | p256 := elliptic.P256() |
| 12102 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 12103 | if err != nil { |
| 12104 | panic(err) |
| 12105 | } |
| 12106 | |
| 12107 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 12108 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 12109 | if err != nil { |
| 12110 | panic(err) |
| 12111 | } |
| 12112 | |
| 12113 | template := x509.Certificate{ |
| 12114 | SerialNumber: serialNumber, |
| 12115 | Subject: pkix.Name{ |
| 12116 | Organization: []string{"Acme Co"}, |
| 12117 | }, |
| 12118 | NotBefore: time.Now(), |
| 12119 | NotAfter: time.Now(), |
| 12120 | |
| 12121 | // An ECC certificate with only the keyAgreement key usgae may |
| 12122 | // be used with ECDH, but not ECDSA. |
| 12123 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 12124 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 12125 | BasicConstraintsValid: true, |
| 12126 | } |
| 12127 | |
| 12128 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 12129 | if err != nil { |
| 12130 | panic(err) |
| 12131 | } |
| 12132 | |
| 12133 | cert := Certificate{ |
| 12134 | Certificate: [][]byte{derBytes}, |
| 12135 | PrivateKey: priv, |
| 12136 | } |
| 12137 | |
| 12138 | for _, ver := range tlsVersions { |
| 12139 | if ver.version < VersionTLS12 { |
| 12140 | continue |
| 12141 | } |
| 12142 | |
| 12143 | testCases = append(testCases, testCase{ |
| 12144 | testType: clientTest, |
| 12145 | name: "ECDSAKeyUsage-" + ver.name, |
| 12146 | config: Config{ |
| 12147 | MinVersion: ver.version, |
| 12148 | MaxVersion: ver.version, |
| 12149 | Certificates: []Certificate{cert}, |
| 12150 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12151 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12152 | shouldFail: true, |
| 12153 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 12154 | }) |
| 12155 | } |
| 12156 | } |
| 12157 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12158 | func addExtraHandshakeTests() { |
| 12159 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 12160 | // to ensure there is no transport I/O. |
| 12161 | testCases = append(testCases, testCase{ |
| 12162 | testType: clientTest, |
| 12163 | name: "ExtraHandshake-Client-TLS12", |
| 12164 | config: Config{ |
| 12165 | MinVersion: VersionTLS12, |
| 12166 | MaxVersion: VersionTLS12, |
| 12167 | }, |
| 12168 | flags: []string{ |
| 12169 | "-async", |
| 12170 | "-no-op-extra-handshake", |
| 12171 | }, |
| 12172 | }) |
| 12173 | testCases = append(testCases, testCase{ |
| 12174 | testType: serverTest, |
| 12175 | name: "ExtraHandshake-Server-TLS12", |
| 12176 | config: Config{ |
| 12177 | MinVersion: VersionTLS12, |
| 12178 | MaxVersion: VersionTLS12, |
| 12179 | }, |
| 12180 | flags: []string{ |
| 12181 | "-async", |
| 12182 | "-no-op-extra-handshake", |
| 12183 | }, |
| 12184 | }) |
| 12185 | testCases = append(testCases, testCase{ |
| 12186 | testType: clientTest, |
| 12187 | name: "ExtraHandshake-Client-TLS13", |
| 12188 | config: Config{ |
| 12189 | MinVersion: VersionTLS13, |
| 12190 | MaxVersion: VersionTLS13, |
| 12191 | }, |
| 12192 | flags: []string{ |
| 12193 | "-async", |
| 12194 | "-no-op-extra-handshake", |
| 12195 | }, |
| 12196 | }) |
| 12197 | testCases = append(testCases, testCase{ |
| 12198 | testType: serverTest, |
| 12199 | name: "ExtraHandshake-Server-TLS13", |
| 12200 | config: Config{ |
| 12201 | MinVersion: VersionTLS13, |
| 12202 | MaxVersion: VersionTLS13, |
| 12203 | }, |
| 12204 | flags: []string{ |
| 12205 | "-async", |
| 12206 | "-no-op-extra-handshake", |
| 12207 | }, |
| 12208 | }) |
| 12209 | |
| 12210 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12211 | testCases = append(testCases, testCase{ |
| 12212 | testType: serverTest, |
| 12213 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12214 | config: Config{ |
| 12215 | MaxVersion: VersionTLS13, |
| 12216 | MinVersion: VersionTLS13, |
| 12217 | Bugs: ProtocolBugs{ |
| 12218 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12219 | ExpectEarlyDataAccepted: true, |
| 12220 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12221 | }, |
| 12222 | }, |
| 12223 | messageCount: 2, |
| 12224 | resumeSession: true, |
| 12225 | flags: []string{ |
| 12226 | "-async", |
| 12227 | "-enable-early-data", |
| 12228 | "-expect-accept-early-data", |
| 12229 | "-no-op-extra-handshake", |
| 12230 | }, |
| 12231 | }) |
| 12232 | |
| 12233 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12234 | // Start. We test this by handshaking twice and asserting the False |
| 12235 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12236 | // how the test works. |
| 12237 | testCases = append(testCases, testCase{ |
| 12238 | testType: clientTest, |
| 12239 | name: "ExtraHandshake-FalseStart", |
| 12240 | config: Config{ |
| 12241 | MaxVersion: VersionTLS12, |
| 12242 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12243 | NextProtos: []string{"foo"}, |
| 12244 | Bugs: ProtocolBugs{ |
| 12245 | ExpectFalseStart: true, |
| 12246 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12247 | }, |
| 12248 | }, |
| 12249 | flags: []string{ |
| 12250 | "-handshake-twice", |
| 12251 | "-false-start", |
| 12252 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12253 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12254 | }, |
| 12255 | shimWritesFirst: true, |
| 12256 | shouldFail: true, |
| 12257 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12258 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12259 | }) |
| 12260 | } |
| 12261 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12262 | // Test that omitted and empty extensions blocks are tolerated. |
| 12263 | func addOmitExtensionsTests() { |
| 12264 | for _, ver := range tlsVersions { |
| 12265 | if ver.version > VersionTLS12 { |
| 12266 | continue |
| 12267 | } |
| 12268 | |
| 12269 | testCases = append(testCases, testCase{ |
| 12270 | testType: serverTest, |
| 12271 | name: "OmitExtensions-ClientHello-" + ver.name, |
| 12272 | config: Config{ |
| 12273 | MinVersion: ver.version, |
| 12274 | MaxVersion: ver.version, |
| 12275 | SessionTicketsDisabled: true, |
| 12276 | Bugs: ProtocolBugs{ |
| 12277 | OmitExtensions: true, |
| 12278 | }, |
| 12279 | }, |
| 12280 | }) |
| 12281 | |
| 12282 | testCases = append(testCases, testCase{ |
| 12283 | testType: serverTest, |
| 12284 | name: "EmptyExtensions-ClientHello-" + ver.name, |
| 12285 | config: Config{ |
| 12286 | MinVersion: ver.version, |
| 12287 | MaxVersion: ver.version, |
| 12288 | SessionTicketsDisabled: true, |
| 12289 | Bugs: ProtocolBugs{ |
| 12290 | EmptyExtensions: true, |
| 12291 | }, |
| 12292 | }, |
| 12293 | }) |
| 12294 | |
| 12295 | testCases = append(testCases, testCase{ |
| 12296 | testType: clientTest, |
| 12297 | name: "OmitExtensions-ServerHello-" + ver.name, |
| 12298 | config: Config{ |
| 12299 | MinVersion: ver.version, |
| 12300 | MaxVersion: ver.version, |
| 12301 | SessionTicketsDisabled: true, |
| 12302 | Bugs: ProtocolBugs{ |
| 12303 | OmitExtensions: true, |
| 12304 | // Disable all ServerHello extensions so |
| 12305 | // OmitExtensions works. |
| 12306 | NoExtendedMasterSecret: true, |
| 12307 | NoRenegotiationInfo: true, |
| 12308 | }, |
| 12309 | }, |
| 12310 | }) |
| 12311 | |
| 12312 | testCases = append(testCases, testCase{ |
| 12313 | testType: clientTest, |
| 12314 | name: "EmptyExtensions-ServerHello-" + ver.name, |
| 12315 | config: Config{ |
| 12316 | MinVersion: ver.version, |
| 12317 | MaxVersion: ver.version, |
| 12318 | SessionTicketsDisabled: true, |
| 12319 | Bugs: ProtocolBugs{ |
| 12320 | EmptyExtensions: true, |
| 12321 | // Disable all ServerHello extensions so |
| 12322 | // EmptyExtensions works. |
| 12323 | NoExtendedMasterSecret: true, |
| 12324 | NoRenegotiationInfo: true, |
| 12325 | }, |
| 12326 | }, |
| 12327 | }) |
| 12328 | } |
| 12329 | } |
| 12330 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12331 | 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] | 12332 | defer wg.Done() |
| 12333 | |
| 12334 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12335 | var err error |
| 12336 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12337 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12338 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12339 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12340 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12341 | if err != nil { |
| 12342 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12343 | } |
| 12344 | break |
| 12345 | } |
| 12346 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12347 | } else if *repeatUntilFailure { |
| 12348 | for err == nil { |
| 12349 | statusChan <- statusMsg{test: test, started: true} |
| 12350 | err = runTest(test, shimPath, -1) |
| 12351 | } |
| 12352 | } else { |
| 12353 | statusChan <- statusMsg{test: test, started: true} |
| 12354 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12355 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12356 | statusChan <- statusMsg{test: test, err: err} |
| 12357 | } |
| 12358 | } |
| 12359 | |
| 12360 | type statusMsg struct { |
| 12361 | test *testCase |
| 12362 | started bool |
| 12363 | err error |
| 12364 | } |
| 12365 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12366 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12367 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12368 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12369 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12370 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12371 | if !*pipe { |
| 12372 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12373 | var erase string |
| 12374 | for i := 0; i < lineLen; i++ { |
| 12375 | erase += "\b \b" |
| 12376 | } |
| 12377 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12378 | } |
| 12379 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12380 | if msg.started { |
| 12381 | started++ |
| 12382 | } else { |
| 12383 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12384 | |
| 12385 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12386 | if msg.err == errUnimplemented { |
| 12387 | if *pipe { |
| 12388 | // Print each test instead of a status line. |
| 12389 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12390 | } |
| 12391 | unimplemented++ |
| 12392 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12393 | } else { |
| 12394 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12395 | failed++ |
| 12396 | testOutput.addResult(msg.test.name, "FAIL") |
| 12397 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12398 | } else { |
| 12399 | if *pipe { |
| 12400 | // Print each test instead of a status line. |
| 12401 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12402 | } |
| 12403 | testOutput.addResult(msg.test.name, "PASS") |
| 12404 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12405 | } |
| 12406 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12407 | if !*pipe { |
| 12408 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12409 | 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] | 12410 | lineLen = len(line) |
| 12411 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12412 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12413 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12414 | |
| 12415 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12416 | } |
| 12417 | |
| 12418 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12419 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12420 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12421 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12422 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12423 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12424 | addCipherSuiteTests() |
| 12425 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12426 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12427 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12428 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12429 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12430 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12431 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12432 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12433 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12434 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12435 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12436 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12437 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12438 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12439 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12440 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12441 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12442 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12443 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12444 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12445 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12446 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12447 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12448 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12449 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12450 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12451 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12452 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12453 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12454 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12455 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12456 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12457 | addExtraHandshakeTests() |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12458 | addOmitExtensionsTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12459 | |
| 12460 | var wg sync.WaitGroup |
| 12461 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12462 | statusChan := make(chan statusMsg, *numWorkers) |
| 12463 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12464 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12465 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12466 | if len(*shimConfigFile) != 0 { |
| 12467 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12468 | if err != nil { |
| 12469 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12470 | os.Exit(1) |
| 12471 | } |
| 12472 | |
| 12473 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12474 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12475 | os.Exit(1) |
| 12476 | } |
| 12477 | } |
| 12478 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12479 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12480 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12481 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12482 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12483 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12484 | } |
| 12485 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12486 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12487 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12488 | matched := true |
| 12489 | if len(*testToRun) != 0 { |
| 12490 | var err error |
| 12491 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12492 | if err != nil { |
| 12493 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12494 | os.Exit(1) |
| 12495 | } |
| 12496 | } |
| 12497 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12498 | if !*includeDisabled { |
| 12499 | for pattern := range shimConfig.DisabledTests { |
| 12500 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12501 | if err != nil { |
| 12502 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12503 | os.Exit(1) |
| 12504 | } |
| 12505 | |
| 12506 | if isDisabled { |
| 12507 | matched = false |
| 12508 | break |
| 12509 | } |
| 12510 | } |
| 12511 | } |
| 12512 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12513 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12514 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12515 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12516 | |
| 12517 | // Only run one test if repeating until failure. |
| 12518 | if *repeatUntilFailure { |
| 12519 | break |
| 12520 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12521 | } |
| 12522 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12523 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12524 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12525 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12526 | os.Exit(1) |
| 12527 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12528 | |
| 12529 | close(testChan) |
| 12530 | wg.Wait() |
| 12531 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12532 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12533 | |
| 12534 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12535 | |
| 12536 | if *jsonOutput != "" { |
| 12537 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12538 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12539 | } |
| 12540 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12541 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12542 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12543 | os.Exit(1) |
| 12544 | } |
| 12545 | |
| 12546 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12547 | os.Exit(1) |
| 12548 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12549 | } |