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{ |
| 4232 | MaxVersion: VersionTLS13, |
| 4233 | MinVersion: VersionTLS13, |
| 4234 | TLS13Variant: TLS13Experiment, |
| 4235 | Bugs: ProtocolBugs{ |
| 4236 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4237 | ExpectEarlyDataAccepted: true, |
| 4238 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4239 | }, |
| 4240 | }, |
| 4241 | messageCount: 2, |
| 4242 | resumeSession: true, |
| 4243 | flags: []string{ |
| 4244 | "-enable-early-data", |
| 4245 | "-expect-accept-early-data", |
| 4246 | "-tls13-variant", "1", |
| 4247 | }, |
| 4248 | }) |
| 4249 | |
| 4250 | tests = append(tests, testCase{ |
| 4251 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 4252 | name: "TLS13RecordTypeExperiment-EarlyData-Server", |
| 4253 | config: Config{ |
| 4254 | MaxVersion: VersionTLS13, |
| 4255 | MinVersion: VersionTLS13, |
| 4256 | TLS13Variant: TLS13RecordTypeExperiment, |
| 4257 | Bugs: ProtocolBugs{ |
| 4258 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 4259 | ExpectEarlyDataAccepted: true, |
| 4260 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 4261 | }, |
| 4262 | }, |
| 4263 | messageCount: 2, |
| 4264 | resumeSession: true, |
| 4265 | flags: []string{ |
| 4266 | "-enable-early-data", |
| 4267 | "-expect-accept-early-data", |
| 4268 | "-tls13-variant", "2", |
| 4269 | }, |
| 4270 | }) |
| 4271 | |
| 4272 | tests = append(tests, testCase{ |
| 4273 | testType: serverTest, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4274 | name: "TLS13-MaxEarlyData-Server", |
| 4275 | config: Config{ |
| 4276 | MaxVersion: VersionTLS13, |
| 4277 | MinVersion: VersionTLS13, |
| 4278 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 4279 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 4280 | ExpectEarlyDataAccepted: true, |
| 4281 | }, |
| 4282 | }, |
| 4283 | messageCount: 2, |
| 4284 | resumeSession: true, |
| 4285 | flags: []string{ |
| 4286 | "-enable-early-data", |
| 4287 | "-expect-accept-early-data", |
| 4288 | }, |
| 4289 | shouldFail: true, |
| 4290 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 4291 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 4292 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4293 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4294 | // TLS client auth. |
| 4295 | tests = append(tests, testCase{ |
| 4296 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4297 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4298 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4299 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4300 | ClientAuth: RequestClientCert, |
| 4301 | }, |
| 4302 | }) |
| 4303 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4304 | testType: serverTest, |
| 4305 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4306 | config: Config{ |
| 4307 | MaxVersion: VersionTLS12, |
| 4308 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4309 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4310 | flags: []string{"-verify-peer"}, |
| 4311 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4312 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4313 | tests = append(tests, testCase{ |
| 4314 | testType: clientTest, |
| 4315 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 4316 | config: Config{ |
| 4317 | MaxVersion: VersionSSL30, |
| 4318 | ClientAuth: RequestClientCert, |
| 4319 | }, |
| 4320 | }) |
| 4321 | tests = append(tests, testCase{ |
| 4322 | testType: serverTest, |
| 4323 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 4324 | config: Config{ |
| 4325 | MaxVersion: VersionSSL30, |
| 4326 | }, |
| 4327 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4328 | flags: []string{"-verify-peer"}, |
| 4329 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4330 | tests = append(tests, testCase{ |
| 4331 | testType: clientTest, |
| 4332 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 4333 | config: Config{ |
| 4334 | MaxVersion: VersionTLS13, |
| 4335 | ClientAuth: RequestClientCert, |
| 4336 | }, |
| 4337 | }) |
| 4338 | tests = append(tests, testCase{ |
| 4339 | testType: serverTest, |
| 4340 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 4341 | config: Config{ |
| 4342 | MaxVersion: VersionTLS13, |
| 4343 | }, |
| 4344 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 4345 | flags: []string{"-verify-peer"}, |
| 4346 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 4347 | } |
| 4348 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4349 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4350 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4351 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4352 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4353 | ClientAuth: RequireAnyClientCert, |
| 4354 | }, |
| 4355 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 4356 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4357 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4358 | }, |
| 4359 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4360 | tests = append(tests, testCase{ |
| 4361 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4362 | name: "ClientAuth-RSA-Client-TLS13", |
| 4363 | config: Config{ |
| 4364 | MaxVersion: VersionTLS13, |
| 4365 | ClientAuth: RequireAnyClientCert, |
| 4366 | }, |
| 4367 | flags: []string{ |
| 4368 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4369 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4370 | }, |
| 4371 | }) |
| 4372 | tests = append(tests, testCase{ |
| 4373 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4374 | name: "ClientAuth-ECDSA-Client", |
| 4375 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4376 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4377 | ClientAuth: RequireAnyClientCert, |
| 4378 | }, |
| 4379 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4380 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4381 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 4382 | }, |
| 4383 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4384 | tests = append(tests, testCase{ |
| 4385 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4386 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 4387 | config: Config{ |
| 4388 | MaxVersion: VersionTLS13, |
| 4389 | ClientAuth: RequireAnyClientCert, |
| 4390 | }, |
| 4391 | flags: []string{ |
| 4392 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4393 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 4394 | }, |
| 4395 | }) |
| 4396 | tests = append(tests, testCase{ |
| 4397 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4398 | name: "ClientAuth-NoCertificate-OldCallback", |
| 4399 | config: Config{ |
| 4400 | MaxVersion: VersionTLS12, |
| 4401 | ClientAuth: RequestClientCert, |
| 4402 | }, |
| 4403 | flags: []string{"-use-old-client-cert-callback"}, |
| 4404 | }) |
| 4405 | tests = append(tests, testCase{ |
| 4406 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4407 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 4408 | config: Config{ |
| 4409 | MaxVersion: VersionTLS13, |
| 4410 | ClientAuth: RequestClientCert, |
| 4411 | }, |
| 4412 | flags: []string{"-use-old-client-cert-callback"}, |
| 4413 | }) |
| 4414 | tests = append(tests, testCase{ |
| 4415 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4416 | name: "ClientAuth-OldCallback", |
| 4417 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4418 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 4419 | ClientAuth: RequireAnyClientCert, |
| 4420 | }, |
| 4421 | flags: []string{ |
| 4422 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4423 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4424 | "-use-old-client-cert-callback", |
| 4425 | }, |
| 4426 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4427 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4428 | testType: clientTest, |
| 4429 | name: "ClientAuth-OldCallback-TLS13", |
| 4430 | config: Config{ |
| 4431 | MaxVersion: VersionTLS13, |
| 4432 | ClientAuth: RequireAnyClientCert, |
| 4433 | }, |
| 4434 | flags: []string{ |
| 4435 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4436 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4437 | "-use-old-client-cert-callback", |
| 4438 | }, |
| 4439 | }) |
| 4440 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4441 | testType: serverTest, |
| 4442 | name: "ClientAuth-Server", |
| 4443 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4444 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4445 | Certificates: []Certificate{rsaCertificate}, |
| 4446 | }, |
| 4447 | flags: []string{"-require-any-client-certificate"}, |
| 4448 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4449 | tests = append(tests, testCase{ |
| 4450 | testType: serverTest, |
| 4451 | name: "ClientAuth-Server-TLS13", |
| 4452 | config: Config{ |
| 4453 | MaxVersion: VersionTLS13, |
| 4454 | Certificates: []Certificate{rsaCertificate}, |
| 4455 | }, |
| 4456 | flags: []string{"-require-any-client-certificate"}, |
| 4457 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4458 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4459 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4460 | tests = append(tests, testCase{ |
| 4461 | testType: serverTest, |
| 4462 | name: "Basic-Server-RSA", |
| 4463 | config: Config{ |
| 4464 | MaxVersion: VersionTLS12, |
| 4465 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 4466 | }, |
| 4467 | flags: []string{ |
| 4468 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4469 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4470 | }, |
| 4471 | }) |
| 4472 | tests = append(tests, testCase{ |
| 4473 | testType: serverTest, |
| 4474 | name: "Basic-Server-ECDHE-RSA", |
| 4475 | config: Config{ |
| 4476 | MaxVersion: VersionTLS12, |
| 4477 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4478 | }, |
| 4479 | flags: []string{ |
| 4480 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4481 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4482 | }, |
| 4483 | }) |
| 4484 | tests = append(tests, testCase{ |
| 4485 | testType: serverTest, |
| 4486 | name: "Basic-Server-ECDHE-ECDSA", |
| 4487 | config: Config{ |
| 4488 | MaxVersion: VersionTLS12, |
| 4489 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4490 | }, |
| 4491 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4492 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4493 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4494 | }, |
| 4495 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4496 | tests = append(tests, testCase{ |
| 4497 | testType: serverTest, |
| 4498 | name: "Basic-Server-Ed25519", |
| 4499 | config: Config{ |
| 4500 | MaxVersion: VersionTLS12, |
| 4501 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4502 | }, |
| 4503 | flags: []string{ |
| 4504 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4505 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4506 | "-enable-ed25519", |
| 4507 | }, |
| 4508 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4509 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4510 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4511 | tests = append(tests, testCase{ |
| 4512 | name: "SessionTicketsDisabled-Client", |
| 4513 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4514 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4515 | SessionTicketsDisabled: true, |
| 4516 | }, |
| 4517 | }) |
| 4518 | tests = append(tests, testCase{ |
| 4519 | testType: serverTest, |
| 4520 | name: "SessionTicketsDisabled-Server", |
| 4521 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4522 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4523 | SessionTicketsDisabled: true, |
| 4524 | }, |
| 4525 | }) |
| 4526 | |
| 4527 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4528 | // identity hint. |
| 4529 | tests = append(tests, testCase{ |
| 4530 | name: "EmptyPSKHint-Client", |
| 4531 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4532 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4533 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4534 | PreSharedKey: []byte("secret"), |
| 4535 | }, |
| 4536 | flags: []string{"-psk", "secret"}, |
| 4537 | }) |
| 4538 | tests = append(tests, testCase{ |
| 4539 | testType: serverTest, |
| 4540 | name: "EmptyPSKHint-Server", |
| 4541 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4542 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4543 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4544 | PreSharedKey: []byte("secret"), |
| 4545 | }, |
| 4546 | flags: []string{"-psk", "secret"}, |
| 4547 | }) |
| 4548 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4549 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4550 | tests = append(tests, testCase{ |
| 4551 | testType: clientTest, |
| 4552 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4553 | config: Config{ |
| 4554 | MaxVersion: VersionTLS12, |
| 4555 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4556 | flags: []string{ |
| 4557 | "-enable-ocsp-stapling", |
| 4558 | "-expect-ocsp-response", |
| 4559 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4560 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4561 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4562 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4563 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4564 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4565 | testType: serverTest, |
| 4566 | name: "OCSPStapling-Server", |
| 4567 | config: Config{ |
| 4568 | MaxVersion: VersionTLS12, |
| 4569 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4570 | expectedOCSPResponse: testOCSPResponse, |
| 4571 | flags: []string{ |
| 4572 | "-ocsp-response", |
| 4573 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4574 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4575 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4576 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4577 | tests = append(tests, testCase{ |
| 4578 | testType: clientTest, |
| 4579 | name: "OCSPStapling-Client-TLS13", |
| 4580 | config: Config{ |
| 4581 | MaxVersion: VersionTLS13, |
| 4582 | }, |
| 4583 | flags: []string{ |
| 4584 | "-enable-ocsp-stapling", |
| 4585 | "-expect-ocsp-response", |
| 4586 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4587 | "-verify-peer", |
| 4588 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4589 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4590 | }) |
| 4591 | tests = append(tests, testCase{ |
| 4592 | testType: serverTest, |
| 4593 | name: "OCSPStapling-Server-TLS13", |
| 4594 | config: Config{ |
| 4595 | MaxVersion: VersionTLS13, |
| 4596 | }, |
| 4597 | expectedOCSPResponse: testOCSPResponse, |
| 4598 | flags: []string{ |
| 4599 | "-ocsp-response", |
| 4600 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4601 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4602 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4603 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4604 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4605 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4606 | for _, vers := range tlsVersions { |
| 4607 | if config.protocol == dtls && !vers.hasDTLS { |
| 4608 | continue |
| 4609 | } |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4610 | for _, useCustomCallback := range []bool{false, true} { |
| 4611 | for _, testType := range []testType{clientTest, serverTest} { |
| 4612 | suffix := "-Client" |
| 4613 | if testType == serverTest { |
| 4614 | suffix = "-Server" |
| 4615 | } |
| 4616 | suffix += "-" + vers.name |
| 4617 | if useCustomCallback { |
| 4618 | suffix += "-CustomCallback" |
| 4619 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4620 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4621 | flags := []string{"-verify-peer"} |
| 4622 | if testType == serverTest { |
| 4623 | flags = append(flags, "-require-any-client-certificate") |
| 4624 | } |
| 4625 | if useCustomCallback { |
| 4626 | flags = append(flags, "-use-custom-verify-callback") |
| 4627 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4628 | |
David Benjamin | 3a1dd46 | 2017-07-11 16:13:10 -0400 | [diff] [blame] | 4629 | tests = append(tests, testCase{ |
| 4630 | testType: testType, |
| 4631 | name: "CertificateVerificationSucceed" + suffix, |
| 4632 | config: Config{ |
| 4633 | MaxVersion: vers.version, |
| 4634 | Certificates: []Certificate{rsaCertificate}, |
| 4635 | }, |
| 4636 | tls13Variant: vers.tls13Variant, |
| 4637 | flags: append([]string{"-expect-verify-result"}, flags...), |
| 4638 | resumeSession: true, |
| 4639 | }) |
| 4640 | tests = append(tests, testCase{ |
| 4641 | testType: testType, |
| 4642 | name: "CertificateVerificationFail" + suffix, |
| 4643 | config: Config{ |
| 4644 | MaxVersion: vers.version, |
| 4645 | Certificates: []Certificate{rsaCertificate}, |
| 4646 | }, |
| 4647 | tls13Variant: vers.tls13Variant, |
| 4648 | flags: append([]string{"-verify-fail"}, flags...), |
| 4649 | shouldFail: true, |
| 4650 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4651 | }) |
| 4652 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4653 | } |
| 4654 | |
| 4655 | // By default, the client is in a soft fail mode where the peer |
| 4656 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4657 | tests = append(tests, testCase{ |
| 4658 | testType: clientTest, |
| 4659 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4660 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4661 | MaxVersion: vers.version, |
| 4662 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4663 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4664 | tls13Variant: vers.tls13Variant, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4665 | flags: []string{ |
| 4666 | "-verify-fail", |
| 4667 | "-expect-verify-result", |
| 4668 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4669 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4670 | }) |
| 4671 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4672 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4673 | tests = append(tests, testCase{ |
| 4674 | name: "ShimSendAlert", |
| 4675 | flags: []string{"-send-alert"}, |
| 4676 | shimWritesFirst: true, |
| 4677 | shouldFail: true, |
| 4678 | expectedLocalError: "remote error: decompression failure", |
| 4679 | }) |
| 4680 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4681 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4682 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4683 | name: "Renegotiate-Client", |
| 4684 | config: Config{ |
| 4685 | MaxVersion: VersionTLS12, |
| 4686 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4687 | renegotiate: 1, |
| 4688 | flags: []string{ |
| 4689 | "-renegotiate-freely", |
| 4690 | "-expect-total-renegotiations", "1", |
| 4691 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4692 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4693 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4694 | tests = append(tests, testCase{ |
| 4695 | name: "SendHalfHelloRequest", |
| 4696 | config: Config{ |
| 4697 | MaxVersion: VersionTLS12, |
| 4698 | Bugs: ProtocolBugs{ |
| 4699 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4700 | }, |
| 4701 | }, |
| 4702 | sendHalfHelloRequest: true, |
| 4703 | flags: []string{"-renegotiate-ignore"}, |
| 4704 | shouldFail: true, |
| 4705 | expectedError: ":UNEXPECTED_RECORD:", |
| 4706 | }) |
| 4707 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4708 | // NPN on client and server; results in post-handshake message. |
| 4709 | tests = append(tests, testCase{ |
| 4710 | name: "NPN-Client", |
| 4711 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4712 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4713 | NextProtos: []string{"foo"}, |
| 4714 | }, |
| 4715 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4716 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4717 | expectedNextProto: "foo", |
| 4718 | expectedNextProtoType: npn, |
| 4719 | }) |
| 4720 | tests = append(tests, testCase{ |
| 4721 | testType: serverTest, |
| 4722 | name: "NPN-Server", |
| 4723 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4724 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4725 | NextProtos: []string{"bar"}, |
| 4726 | }, |
| 4727 | flags: []string{ |
| 4728 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4729 | "-expect-next-proto", "bar", |
| 4730 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4731 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4732 | expectedNextProto: "bar", |
| 4733 | expectedNextProtoType: npn, |
| 4734 | }) |
| 4735 | |
| 4736 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4737 | |
| 4738 | // Client does False Start and negotiates NPN. |
| 4739 | tests = append(tests, testCase{ |
| 4740 | name: "FalseStart", |
| 4741 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4742 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4743 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4744 | NextProtos: []string{"foo"}, |
| 4745 | Bugs: ProtocolBugs{ |
| 4746 | ExpectFalseStart: true, |
| 4747 | }, |
| 4748 | }, |
| 4749 | flags: []string{ |
| 4750 | "-false-start", |
| 4751 | "-select-next-proto", "foo", |
| 4752 | }, |
| 4753 | shimWritesFirst: true, |
| 4754 | resumeSession: true, |
| 4755 | }) |
| 4756 | |
| 4757 | // Client does False Start and negotiates ALPN. |
| 4758 | tests = append(tests, testCase{ |
| 4759 | name: "FalseStart-ALPN", |
| 4760 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4761 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4762 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4763 | NextProtos: []string{"foo"}, |
| 4764 | Bugs: ProtocolBugs{ |
| 4765 | ExpectFalseStart: true, |
| 4766 | }, |
| 4767 | }, |
| 4768 | flags: []string{ |
| 4769 | "-false-start", |
| 4770 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4771 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4772 | }, |
| 4773 | shimWritesFirst: true, |
| 4774 | resumeSession: true, |
| 4775 | }) |
| 4776 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4777 | // False Start without session tickets. |
| 4778 | tests = append(tests, testCase{ |
| 4779 | name: "FalseStart-SessionTicketsDisabled", |
| 4780 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4781 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4782 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4783 | NextProtos: []string{"foo"}, |
| 4784 | SessionTicketsDisabled: true, |
| 4785 | Bugs: ProtocolBugs{ |
| 4786 | ExpectFalseStart: true, |
| 4787 | }, |
| 4788 | }, |
| 4789 | flags: []string{ |
| 4790 | "-false-start", |
| 4791 | "-select-next-proto", "foo", |
| 4792 | }, |
| 4793 | shimWritesFirst: true, |
| 4794 | }) |
| 4795 | |
| 4796 | // Server parses a V2ClientHello. |
| 4797 | tests = append(tests, testCase{ |
| 4798 | testType: serverTest, |
| 4799 | name: "SendV2ClientHello", |
| 4800 | config: Config{ |
| 4801 | // Choose a cipher suite that does not involve |
| 4802 | // elliptic curves, so no extensions are |
| 4803 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4804 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4805 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4806 | Bugs: ProtocolBugs{ |
| 4807 | SendV2ClientHello: true, |
| 4808 | }, |
| 4809 | }, |
David Benjamin | 78b8b99 | 2017-08-01 18:38:41 -0400 | [diff] [blame] | 4810 | flags: []string{ |
| 4811 | "-expect-msg-callback", |
| 4812 | `read v2clienthello |
| 4813 | write hs 2 |
| 4814 | write hs 11 |
| 4815 | write hs 14 |
| 4816 | read hs 16 |
| 4817 | read ccs |
| 4818 | read hs 20 |
| 4819 | write ccs |
| 4820 | write hs 20 |
| 4821 | read alert 1 0 |
| 4822 | `, |
| 4823 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4824 | }) |
| 4825 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4826 | // Test Channel ID |
| 4827 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4828 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4829 | continue |
| 4830 | } |
| 4831 | // Client sends a Channel ID. |
| 4832 | tests = append(tests, testCase{ |
| 4833 | name: "ChannelID-Client-" + ver.name, |
| 4834 | config: Config{ |
| 4835 | MaxVersion: ver.version, |
| 4836 | RequestChannelID: true, |
| 4837 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4838 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4839 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4840 | resumeSession: true, |
| 4841 | expectChannelID: true, |
| 4842 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4843 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4844 | // Server accepts a Channel ID. |
| 4845 | tests = append(tests, testCase{ |
| 4846 | testType: serverTest, |
| 4847 | name: "ChannelID-Server-" + ver.name, |
| 4848 | config: Config{ |
| 4849 | MaxVersion: ver.version, |
| 4850 | ChannelID: channelIDKey, |
| 4851 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4852 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4853 | flags: []string{ |
| 4854 | "-expect-channel-id", |
| 4855 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4856 | }, |
| 4857 | resumeSession: true, |
| 4858 | expectChannelID: true, |
| 4859 | }) |
| 4860 | |
| 4861 | tests = append(tests, testCase{ |
| 4862 | testType: serverTest, |
| 4863 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4864 | config: Config{ |
| 4865 | MaxVersion: ver.version, |
| 4866 | ChannelID: channelIDKey, |
| 4867 | Bugs: ProtocolBugs{ |
| 4868 | InvalidChannelIDSignature: true, |
| 4869 | }, |
| 4870 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 4871 | tls13Variant: ver.tls13Variant, |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4872 | flags: []string{"-enable-channel-id"}, |
| 4873 | shouldFail: true, |
| 4874 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4875 | }) |
David Benjamin | 634f475 | 2017-07-01 11:08:41 -0400 | [diff] [blame] | 4876 | |
| 4877 | if ver.version < VersionTLS13 { |
| 4878 | // Channel ID requires ECDHE ciphers. |
| 4879 | tests = append(tests, testCase{ |
| 4880 | testType: serverTest, |
| 4881 | name: "ChannelID-NoECDHE-" + ver.name, |
| 4882 | config: Config{ |
| 4883 | MaxVersion: ver.version, |
| 4884 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 4885 | ChannelID: channelIDKey, |
| 4886 | }, |
| 4887 | expectChannelID: false, |
| 4888 | flags: []string{"-enable-channel-id"}, |
| 4889 | }) |
| 4890 | |
| 4891 | // Sanity-check setting expectChannelID false works. |
| 4892 | tests = append(tests, testCase{ |
| 4893 | testType: serverTest, |
| 4894 | name: "ChannelID-ECDHE-" + ver.name, |
| 4895 | config: Config{ |
| 4896 | MaxVersion: ver.version, |
| 4897 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 4898 | ChannelID: channelIDKey, |
| 4899 | }, |
| 4900 | expectChannelID: false, |
| 4901 | flags: []string{"-enable-channel-id"}, |
| 4902 | shouldFail: true, |
| 4903 | expectedLocalError: "channel ID unexpectedly negotiated", |
| 4904 | }) |
| 4905 | } |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4906 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4907 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4908 | // Channel ID and NPN at the same time, to ensure their relative |
| 4909 | // ordering is correct. |
| 4910 | tests = append(tests, testCase{ |
| 4911 | name: "ChannelID-NPN-Client", |
| 4912 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4913 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4914 | RequestChannelID: true, |
| 4915 | NextProtos: []string{"foo"}, |
| 4916 | }, |
| 4917 | flags: []string{ |
| 4918 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4919 | "-select-next-proto", "foo", |
| 4920 | }, |
| 4921 | resumeSession: true, |
| 4922 | expectChannelID: true, |
| 4923 | expectedNextProto: "foo", |
| 4924 | expectedNextProtoType: npn, |
| 4925 | }) |
| 4926 | tests = append(tests, testCase{ |
| 4927 | testType: serverTest, |
| 4928 | name: "ChannelID-NPN-Server", |
| 4929 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4930 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4931 | ChannelID: channelIDKey, |
| 4932 | NextProtos: []string{"bar"}, |
| 4933 | }, |
| 4934 | flags: []string{ |
| 4935 | "-expect-channel-id", |
| 4936 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4937 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4938 | "-expect-next-proto", "bar", |
| 4939 | }, |
| 4940 | resumeSession: true, |
| 4941 | expectChannelID: true, |
| 4942 | expectedNextProto: "bar", |
| 4943 | expectedNextProtoType: npn, |
| 4944 | }) |
| 4945 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4946 | // Bidirectional shutdown with the runner initiating. |
| 4947 | tests = append(tests, testCase{ |
| 4948 | name: "Shutdown-Runner", |
| 4949 | config: Config{ |
| 4950 | Bugs: ProtocolBugs{ |
| 4951 | ExpectCloseNotify: true, |
| 4952 | }, |
| 4953 | }, |
| 4954 | flags: []string{"-check-close-notify"}, |
| 4955 | }) |
| 4956 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4957 | if !config.implicitHandshake { |
| 4958 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4959 | // in the meantime, sends garbage before the close_notify which |
| 4960 | // the shim must ignore. This test is disabled under implicit |
| 4961 | // handshake tests because the shim never reads or writes. |
| 4962 | tests = append(tests, testCase{ |
| 4963 | name: "Shutdown-Shim", |
| 4964 | config: Config{ |
| 4965 | MaxVersion: VersionTLS12, |
| 4966 | Bugs: ProtocolBugs{ |
| 4967 | ExpectCloseNotify: true, |
| 4968 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4969 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4970 | shimShutsDown: true, |
| 4971 | sendEmptyRecords: 1, |
| 4972 | sendWarningAlerts: 1, |
| 4973 | flags: []string{"-check-close-notify"}, |
| 4974 | }) |
| 4975 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4976 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4977 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4978 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4979 | tests = append(tests, testCase{ |
| 4980 | name: "SkipHelloVerifyRequest", |
| 4981 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4982 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4983 | Bugs: ProtocolBugs{ |
| 4984 | SkipHelloVerifyRequest: true, |
| 4985 | }, |
| 4986 | }, |
| 4987 | }) |
| 4988 | } |
| 4989 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4990 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4991 | test.protocol = config.protocol |
| 4992 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4993 | test.name += "-DTLS" |
| 4994 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4995 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4996 | test.name += "-Async" |
| 4997 | test.flags = append(test.flags, "-async") |
| 4998 | } else { |
| 4999 | test.name += "-Sync" |
| 5000 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5001 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5002 | test.name += "-SplitHandshakeRecords" |
| 5003 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5004 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 5005 | test.config.Bugs.MaxPacketLength = 256 |
| 5006 | test.flags = append(test.flags, "-mtu", "256") |
| 5007 | } |
| 5008 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 5009 | if config.packHandshakeFlight { |
| 5010 | test.name += "-PackHandshakeFlight" |
| 5011 | test.config.Bugs.PackHandshakeFlight = true |
| 5012 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 5013 | if config.implicitHandshake { |
| 5014 | test.name += "-ImplicitHandshake" |
| 5015 | test.flags = append(test.flags, "-implicit-handshake") |
| 5016 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 5017 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 5018 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 5019 | } |
| 5020 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5021 | func addDDoSCallbackTests() { |
| 5022 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5023 | for _, resume := range []bool{false, true} { |
| 5024 | suffix := "Resume" |
| 5025 | if resume { |
| 5026 | suffix = "No" + suffix |
| 5027 | } |
| 5028 | |
| 5029 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5030 | testType: serverTest, |
| 5031 | name: "Server-DDoS-OK-" + suffix, |
| 5032 | config: Config{ |
| 5033 | MaxVersion: VersionTLS12, |
| 5034 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5035 | flags: []string{"-install-ddos-callback"}, |
| 5036 | resumeSession: resume, |
| 5037 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5038 | testCases = append(testCases, testCase{ |
| 5039 | testType: serverTest, |
| 5040 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 5041 | config: Config{ |
| 5042 | MaxVersion: VersionTLS13, |
| 5043 | }, |
| 5044 | flags: []string{"-install-ddos-callback"}, |
| 5045 | resumeSession: resume, |
| 5046 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5047 | |
| 5048 | failFlag := "-fail-ddos-callback" |
| 5049 | if resume { |
| 5050 | failFlag = "-fail-second-ddos-callback" |
| 5051 | } |
| 5052 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5053 | testType: serverTest, |
| 5054 | name: "Server-DDoS-Reject-" + suffix, |
| 5055 | config: Config{ |
| 5056 | MaxVersion: VersionTLS12, |
| 5057 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5058 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5059 | resumeSession: resume, |
| 5060 | shouldFail: true, |
| 5061 | expectedError: ":CONNECTION_REJECTED:", |
| 5062 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5063 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5064 | testCases = append(testCases, testCase{ |
| 5065 | testType: serverTest, |
| 5066 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 5067 | config: Config{ |
| 5068 | MaxVersion: VersionTLS13, |
| 5069 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 5070 | flags: []string{"-install-ddos-callback", failFlag}, |
| 5071 | resumeSession: resume, |
| 5072 | shouldFail: true, |
| 5073 | expectedError: ":CONNECTION_REJECTED:", |
| 5074 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5075 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 5076 | } |
| 5077 | } |
| 5078 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5079 | func addVersionNegotiationTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5080 | for _, protocol := range []protocol{tls, dtls} { |
| 5081 | for _, shimVers := range allVersions(protocol) { |
| 5082 | // Assemble flags to disable all newer versions on the shim. |
| 5083 | var flags []string |
| 5084 | for _, vers := range allVersions(protocol) { |
| 5085 | if vers.version > shimVers.version { |
| 5086 | flags = append(flags, vers.excludeFlag) |
| 5087 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5088 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5089 | |
| 5090 | flags2 := []string{"-max-version", shimVers.shimFlag(protocol)} |
| 5091 | |
| 5092 | if shimVers.tls13Variant != 0 { |
| 5093 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5094 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5095 | } |
| 5096 | |
| 5097 | // Test configuring the runner's maximum version. |
| 5098 | for _, runnerVers := range allVersions(protocol) { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5099 | expectedVersion := shimVers.version |
| 5100 | if runnerVers.version < shimVers.version { |
| 5101 | expectedVersion = runnerVers.version |
| 5102 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5103 | // When running and shim have different TLS 1.3 variants enabled, |
| 5104 | // shim clients are expected to fall back to TLS 1.2, while shim |
| 5105 | // servers support both variants when enabled when the experiment is |
| 5106 | // enabled. |
| 5107 | expectedServerVersion := expectedVersion |
| 5108 | expectedClientVersion := expectedVersion |
| 5109 | if expectedVersion == VersionTLS13 && runnerVers.tls13Variant != shimVers.tls13Variant { |
| 5110 | expectedClientVersion = VersionTLS12 |
| 5111 | expectedServerVersion = VersionTLS12 |
| 5112 | if shimVers.tls13Variant != TLS13Default { |
| 5113 | expectedServerVersion = VersionTLS13 |
| 5114 | } |
| 5115 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5116 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5117 | suffix := shimVers.name + "-" + runnerVers.name |
| 5118 | if protocol == dtls { |
| 5119 | suffix += "-DTLS" |
| 5120 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5121 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5122 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5123 | clientVers := shimVers.version |
| 5124 | if clientVers > VersionTLS10 { |
| 5125 | clientVers = VersionTLS10 |
| 5126 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5127 | clientVers = recordVersionToWire(clientVers, protocol) |
| 5128 | serverVers := expectedServerVersion |
| 5129 | if expectedServerVersion >= VersionTLS13 { |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5130 | serverVers = VersionTLS10 |
| 5131 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5132 | serverVers = recordVersionToWire(serverVers, protocol) |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 5133 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5134 | testCases = append(testCases, testCase{ |
| 5135 | protocol: protocol, |
| 5136 | testType: clientTest, |
| 5137 | name: "VersionNegotiation-Client-" + suffix, |
| 5138 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5139 | MaxVersion: runnerVers.version, |
| 5140 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5141 | Bugs: ProtocolBugs{ |
| 5142 | ExpectInitialRecordVersion: clientVers, |
| 5143 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5144 | }, |
| 5145 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5146 | expectedVersion: expectedClientVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5147 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5148 | testCases = append(testCases, testCase{ |
| 5149 | protocol: protocol, |
| 5150 | testType: clientTest, |
| 5151 | name: "VersionNegotiation-Client2-" + suffix, |
| 5152 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5153 | MaxVersion: runnerVers.version, |
| 5154 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5155 | Bugs: ProtocolBugs{ |
| 5156 | ExpectInitialRecordVersion: clientVers, |
| 5157 | }, |
| 5158 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5159 | flags: flags2, |
| 5160 | expectedVersion: expectedClientVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5161 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5162 | |
| 5163 | testCases = append(testCases, testCase{ |
| 5164 | protocol: protocol, |
| 5165 | testType: serverTest, |
| 5166 | name: "VersionNegotiation-Server-" + suffix, |
| 5167 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5168 | MaxVersion: runnerVers.version, |
| 5169 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5170 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5171 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 5172 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5173 | }, |
| 5174 | flags: flags, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5175 | expectedVersion: expectedServerVersion, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5176 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5177 | testCases = append(testCases, testCase{ |
| 5178 | protocol: protocol, |
| 5179 | testType: serverTest, |
| 5180 | name: "VersionNegotiation-Server2-" + suffix, |
| 5181 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5182 | MaxVersion: runnerVers.version, |
| 5183 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5184 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5185 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5186 | }, |
| 5187 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5188 | flags: flags2, |
| 5189 | expectedVersion: expectedServerVersion, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 5190 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5191 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5192 | } |
| 5193 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5194 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5195 | // Test the version extension at all versions. |
| 5196 | for _, vers := range tlsVersions { |
| 5197 | protocols := []protocol{tls} |
| 5198 | if vers.hasDTLS { |
| 5199 | protocols = append(protocols, dtls) |
| 5200 | } |
| 5201 | for _, protocol := range protocols { |
| 5202 | suffix := vers.name |
| 5203 | if protocol == dtls { |
| 5204 | suffix += "-DTLS" |
| 5205 | } |
| 5206 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5207 | testCases = append(testCases, testCase{ |
| 5208 | protocol: protocol, |
| 5209 | testType: serverTest, |
| 5210 | name: "VersionNegotiationExtension-" + suffix, |
| 5211 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5212 | TLS13Variant: vers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5213 | Bugs: ProtocolBugs{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5214 | SendSupportedVersions: []uint16{0x1111, vers.wire(protocol), 0x2222}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5215 | }, |
| 5216 | }, |
| 5217 | expectedVersion: vers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5218 | flags: []string{"-tls13-variant", strconv.Itoa(vers.tls13Variant)}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5219 | }) |
| 5220 | } |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5221 | } |
| 5222 | |
| 5223 | // If all versions are unknown, negotiation fails. |
| 5224 | testCases = append(testCases, testCase{ |
| 5225 | testType: serverTest, |
| 5226 | name: "NoSupportedVersions", |
| 5227 | config: Config{ |
| 5228 | Bugs: ProtocolBugs{ |
| 5229 | SendSupportedVersions: []uint16{0x1111}, |
| 5230 | }, |
| 5231 | }, |
| 5232 | shouldFail: true, |
| 5233 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5234 | }) |
| 5235 | testCases = append(testCases, testCase{ |
| 5236 | protocol: dtls, |
| 5237 | testType: serverTest, |
| 5238 | name: "NoSupportedVersions-DTLS", |
| 5239 | config: Config{ |
| 5240 | Bugs: ProtocolBugs{ |
| 5241 | SendSupportedVersions: []uint16{0x1111}, |
| 5242 | }, |
| 5243 | }, |
| 5244 | shouldFail: true, |
| 5245 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5246 | }) |
| 5247 | |
| 5248 | testCases = append(testCases, testCase{ |
| 5249 | testType: serverTest, |
| 5250 | name: "ClientHelloVersionTooHigh", |
| 5251 | config: Config{ |
| 5252 | MaxVersion: VersionTLS13, |
| 5253 | Bugs: ProtocolBugs{ |
| 5254 | SendClientVersion: 0x0304, |
| 5255 | OmitSupportedVersions: true, |
| 5256 | }, |
| 5257 | }, |
| 5258 | expectedVersion: VersionTLS12, |
| 5259 | }) |
| 5260 | |
| 5261 | testCases = append(testCases, testCase{ |
| 5262 | testType: serverTest, |
| 5263 | name: "ConflictingVersionNegotiation", |
| 5264 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5265 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5266 | SendClientVersion: VersionTLS12, |
| 5267 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5268 | }, |
| 5269 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5270 | // The extension takes precedence over the ClientHello version. |
| 5271 | expectedVersion: VersionTLS11, |
| 5272 | }) |
| 5273 | |
| 5274 | testCases = append(testCases, testCase{ |
| 5275 | testType: serverTest, |
| 5276 | name: "ConflictingVersionNegotiation-2", |
| 5277 | config: Config{ |
| 5278 | Bugs: ProtocolBugs{ |
| 5279 | SendClientVersion: VersionTLS11, |
| 5280 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 5281 | }, |
| 5282 | }, |
| 5283 | // The extension takes precedence over the ClientHello version. |
| 5284 | expectedVersion: VersionTLS12, |
| 5285 | }) |
| 5286 | |
| 5287 | testCases = append(testCases, testCase{ |
| 5288 | testType: serverTest, |
| 5289 | name: "RejectFinalTLS13", |
| 5290 | config: Config{ |
| 5291 | Bugs: ProtocolBugs{ |
| 5292 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 5293 | }, |
| 5294 | }, |
| 5295 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 5296 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5297 | expectedVersion: VersionTLS12, |
| 5298 | }) |
| 5299 | |
Steven Valdez | 038da9b | 2017-07-10 12:57:25 -0400 | [diff] [blame] | 5300 | // Test that TLS 1.2 isn't negotiated by the supported_versions extension in |
| 5301 | // the ServerHello. |
| 5302 | testCases = append(testCases, testCase{ |
| 5303 | testType: clientTest, |
| 5304 | name: "SupportedVersionSelection-TLS12", |
| 5305 | config: Config{ |
| 5306 | MaxVersion: VersionTLS12, |
| 5307 | Bugs: ProtocolBugs{ |
| 5308 | SendServerSupportedExtensionVersion: VersionTLS12, |
| 5309 | }, |
| 5310 | }, |
| 5311 | shouldFail: true, |
| 5312 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5313 | }) |
| 5314 | |
| 5315 | // Test that the non-experimental TLS 1.3 isn't negotiated by the |
| 5316 | // supported_versions extension in the ServerHello. |
| 5317 | testCases = append(testCases, testCase{ |
| 5318 | testType: clientTest, |
| 5319 | name: "SupportedVersionSelection-TLS13", |
| 5320 | config: Config{ |
| 5321 | MaxVersion: VersionTLS13, |
| 5322 | Bugs: ProtocolBugs{ |
| 5323 | SendServerSupportedExtensionVersion: tls13DraftVersion, |
| 5324 | }, |
| 5325 | }, |
| 5326 | shouldFail: true, |
| 5327 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5328 | }) |
| 5329 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 5330 | // Test that the maximum version is selected regardless of the |
| 5331 | // client-sent order. |
| 5332 | testCases = append(testCases, testCase{ |
| 5333 | testType: serverTest, |
| 5334 | name: "IgnoreClientVersionOrder", |
| 5335 | config: Config{ |
| 5336 | Bugs: ProtocolBugs{ |
| 5337 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 5338 | }, |
| 5339 | }, |
| 5340 | expectedVersion: VersionTLS13, |
| 5341 | }) |
| 5342 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5343 | // Test for version tolerance. |
| 5344 | testCases = append(testCases, testCase{ |
| 5345 | testType: serverTest, |
| 5346 | name: "MinorVersionTolerance", |
| 5347 | config: Config{ |
| 5348 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5349 | SendClientVersion: 0x03ff, |
| 5350 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5351 | }, |
| 5352 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5353 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5354 | }) |
| 5355 | testCases = append(testCases, testCase{ |
| 5356 | testType: serverTest, |
| 5357 | name: "MajorVersionTolerance", |
| 5358 | config: Config{ |
| 5359 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5360 | SendClientVersion: 0x0400, |
| 5361 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5362 | }, |
| 5363 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5364 | // TLS 1.3 must be negotiated with the supported_versions |
| 5365 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5366 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5367 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 5368 | testCases = append(testCases, testCase{ |
| 5369 | testType: serverTest, |
| 5370 | name: "VersionTolerance-TLS13", |
| 5371 | config: Config{ |
| 5372 | Bugs: ProtocolBugs{ |
| 5373 | // Although TLS 1.3 does not use |
| 5374 | // ClientHello.version, it still tolerates high |
| 5375 | // values there. |
| 5376 | SendClientVersion: 0x0400, |
| 5377 | }, |
| 5378 | }, |
| 5379 | expectedVersion: VersionTLS13, |
| 5380 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5381 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5382 | testCases = append(testCases, testCase{ |
| 5383 | protocol: dtls, |
| 5384 | testType: serverTest, |
| 5385 | name: "MinorVersionTolerance-DTLS", |
| 5386 | config: Config{ |
| 5387 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5388 | SendClientVersion: 0xfe00, |
| 5389 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5390 | }, |
| 5391 | }, |
| 5392 | expectedVersion: VersionTLS12, |
| 5393 | }) |
| 5394 | testCases = append(testCases, testCase{ |
| 5395 | protocol: dtls, |
| 5396 | testType: serverTest, |
| 5397 | name: "MajorVersionTolerance-DTLS", |
| 5398 | config: Config{ |
| 5399 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5400 | SendClientVersion: 0xfdff, |
| 5401 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5402 | }, |
| 5403 | }, |
| 5404 | expectedVersion: VersionTLS12, |
| 5405 | }) |
| 5406 | |
| 5407 | // Test that versions below 3.0 are rejected. |
| 5408 | testCases = append(testCases, testCase{ |
| 5409 | testType: serverTest, |
| 5410 | name: "VersionTooLow", |
| 5411 | config: Config{ |
| 5412 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5413 | SendClientVersion: 0x0200, |
| 5414 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5415 | }, |
| 5416 | }, |
| 5417 | shouldFail: true, |
| 5418 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5419 | }) |
| 5420 | testCases = append(testCases, testCase{ |
| 5421 | protocol: dtls, |
| 5422 | testType: serverTest, |
| 5423 | name: "VersionTooLow-DTLS", |
| 5424 | config: Config{ |
| 5425 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 5426 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 5427 | }, |
| 5428 | }, |
| 5429 | shouldFail: true, |
| 5430 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5431 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5432 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 5433 | testCases = append(testCases, testCase{ |
| 5434 | name: "ServerBogusVersion", |
| 5435 | config: Config{ |
| 5436 | Bugs: ProtocolBugs{ |
| 5437 | SendServerHelloVersion: 0x1234, |
| 5438 | }, |
| 5439 | }, |
| 5440 | shouldFail: true, |
| 5441 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 5442 | }) |
| 5443 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5444 | // Test TLS 1.3's downgrade signal. |
| 5445 | testCases = append(testCases, testCase{ |
| 5446 | name: "Downgrade-TLS12-Client", |
| 5447 | config: Config{ |
| 5448 | Bugs: ProtocolBugs{ |
| 5449 | NegotiateVersion: VersionTLS12, |
| 5450 | }, |
| 5451 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5452 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5453 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5454 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5455 | }) |
| 5456 | testCases = append(testCases, testCase{ |
| 5457 | testType: serverTest, |
| 5458 | name: "Downgrade-TLS12-Server", |
| 5459 | config: Config{ |
| 5460 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5461 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5462 | }, |
| 5463 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 5464 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 5465 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 5466 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 5467 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 5468 | } |
| 5469 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5470 | func addMinimumVersionTests() { |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5471 | for _, protocol := range []protocol{tls, dtls} { |
| 5472 | for _, shimVers := range allVersions(protocol) { |
| 5473 | // Assemble flags to disable all older versions on the shim. |
| 5474 | var flags []string |
| 5475 | for _, vers := range allVersions(protocol) { |
| 5476 | if vers.version < shimVers.version { |
| 5477 | flags = append(flags, vers.excludeFlag) |
| 5478 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5479 | } |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5480 | |
| 5481 | flags2 := []string{"-min-version", shimVers.shimFlag(protocol)} |
| 5482 | |
| 5483 | if shimVers.tls13Variant != 0 { |
| 5484 | flags = append(flags, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5485 | flags2 = append(flags2, "-tls13-variant", strconv.Itoa(shimVers.tls13Variant)) |
| 5486 | } |
| 5487 | |
| 5488 | for _, runnerVers := range allVersions(protocol) { |
| 5489 | // Different TLS 1.3 variants are incompatible with each other and don't |
| 5490 | // produce consistent minimum versions. |
| 5491 | // |
| 5492 | // TODO(davidben): Fold these tests (the main value is in the |
| 5493 | // NegotiateVersion bug) into addVersionNegotiationTests and test based |
| 5494 | // on intended shim behavior, not the shim + runner combination. |
| 5495 | if shimVers.tls13Variant != runnerVers.tls13Variant { |
| 5496 | continue |
| 5497 | } |
| 5498 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5499 | suffix := shimVers.name + "-" + runnerVers.name |
| 5500 | if protocol == dtls { |
| 5501 | suffix += "-DTLS" |
| 5502 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5503 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5504 | var expectedVersion uint16 |
| 5505 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5506 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5507 | if runnerVers.version >= shimVers.version { |
| 5508 | expectedVersion = runnerVers.version |
| 5509 | } else { |
| 5510 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5511 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 5512 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5513 | } |
| 5514 | |
| 5515 | testCases = append(testCases, testCase{ |
| 5516 | protocol: protocol, |
| 5517 | testType: clientTest, |
| 5518 | name: "MinimumVersion-Client-" + suffix, |
| 5519 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5520 | MaxVersion: runnerVers.version, |
| 5521 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5522 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5523 | // Ensure the server does not decline to |
| 5524 | // select a version (versions extension) or |
| 5525 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5526 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5527 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5528 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5529 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5530 | flags: flags, |
| 5531 | expectedVersion: expectedVersion, |
| 5532 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5533 | expectedError: expectedError, |
| 5534 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5535 | }) |
| 5536 | testCases = append(testCases, testCase{ |
| 5537 | protocol: protocol, |
| 5538 | testType: clientTest, |
| 5539 | name: "MinimumVersion-Client2-" + suffix, |
| 5540 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5541 | MaxVersion: runnerVers.version, |
| 5542 | TLS13Variant: runnerVers.tls13Variant, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5543 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5544 | // Ensure the server does not decline to |
| 5545 | // select a version (versions extension) or |
| 5546 | // cipher (some ciphers depend on versions). |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5547 | NegotiateVersion: runnerVers.wire(protocol), |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5548 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 5549 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5550 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5551 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5552 | expectedVersion: expectedVersion, |
| 5553 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5554 | expectedError: expectedError, |
| 5555 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5556 | }) |
| 5557 | |
| 5558 | testCases = append(testCases, testCase{ |
| 5559 | protocol: protocol, |
| 5560 | testType: serverTest, |
| 5561 | name: "MinimumVersion-Server-" + suffix, |
| 5562 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5563 | MaxVersion: runnerVers.version, |
| 5564 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5565 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5566 | flags: flags, |
| 5567 | expectedVersion: expectedVersion, |
| 5568 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5569 | expectedError: expectedError, |
| 5570 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5571 | }) |
| 5572 | testCases = append(testCases, testCase{ |
| 5573 | protocol: protocol, |
| 5574 | testType: serverTest, |
| 5575 | name: "MinimumVersion-Server2-" + suffix, |
| 5576 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5577 | MaxVersion: runnerVers.version, |
| 5578 | TLS13Variant: runnerVers.tls13Variant, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5579 | }, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 5580 | flags: flags2, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 5581 | expectedVersion: expectedVersion, |
| 5582 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 5583 | expectedError: expectedError, |
| 5584 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 5585 | }) |
| 5586 | } |
| 5587 | } |
| 5588 | } |
| 5589 | } |
| 5590 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5591 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5592 | // TODO(davidben): Extensions, where applicable, all move their server |
| 5593 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 5594 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 5595 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5596 | // Repeat extensions tests all versions except SSL 3.0. |
| 5597 | for _, ver := range tlsVersions { |
| 5598 | if ver.version == VersionSSL30 { |
| 5599 | continue |
| 5600 | } |
| 5601 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5602 | // Test that duplicate extensions are rejected. |
| 5603 | testCases = append(testCases, testCase{ |
| 5604 | testType: clientTest, |
| 5605 | name: "DuplicateExtensionClient-" + ver.name, |
| 5606 | config: Config{ |
| 5607 | MaxVersion: ver.version, |
| 5608 | Bugs: ProtocolBugs{ |
| 5609 | DuplicateExtension: true, |
| 5610 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5611 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5612 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5613 | shouldFail: true, |
| 5614 | expectedLocalError: "remote error: error decoding message", |
| 5615 | }) |
| 5616 | testCases = append(testCases, testCase{ |
| 5617 | testType: serverTest, |
| 5618 | name: "DuplicateExtensionServer-" + ver.name, |
| 5619 | config: Config{ |
| 5620 | MaxVersion: ver.version, |
| 5621 | Bugs: ProtocolBugs{ |
| 5622 | DuplicateExtension: true, |
| 5623 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5624 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5625 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5626 | shouldFail: true, |
| 5627 | expectedLocalError: "remote error: error decoding message", |
| 5628 | }) |
| 5629 | |
| 5630 | // Test SNI. |
| 5631 | testCases = append(testCases, testCase{ |
| 5632 | testType: clientTest, |
| 5633 | name: "ServerNameExtensionClient-" + ver.name, |
| 5634 | config: Config{ |
| 5635 | MaxVersion: ver.version, |
| 5636 | Bugs: ProtocolBugs{ |
| 5637 | ExpectServerName: "example.com", |
| 5638 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5639 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5640 | tls13Variant: ver.tls13Variant, |
| 5641 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5642 | }) |
| 5643 | testCases = append(testCases, testCase{ |
| 5644 | testType: clientTest, |
| 5645 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5646 | config: Config{ |
| 5647 | MaxVersion: ver.version, |
| 5648 | Bugs: ProtocolBugs{ |
| 5649 | ExpectServerName: "mismatch.com", |
| 5650 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5651 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5652 | flags: []string{"-host-name", "example.com"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5653 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5654 | shouldFail: true, |
| 5655 | expectedLocalError: "tls: unexpected server name", |
| 5656 | }) |
| 5657 | testCases = append(testCases, testCase{ |
| 5658 | testType: clientTest, |
| 5659 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5660 | config: Config{ |
| 5661 | MaxVersion: ver.version, |
| 5662 | Bugs: ProtocolBugs{ |
| 5663 | ExpectServerName: "missing.com", |
| 5664 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5665 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5666 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5667 | shouldFail: true, |
| 5668 | expectedLocalError: "tls: unexpected server name", |
| 5669 | }) |
| 5670 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5671 | testType: clientTest, |
| 5672 | name: "TolerateServerNameAck-" + ver.name, |
| 5673 | config: Config{ |
| 5674 | MaxVersion: ver.version, |
| 5675 | Bugs: ProtocolBugs{ |
| 5676 | SendServerNameAck: true, |
| 5677 | }, |
| 5678 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5679 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5680 | flags: []string{"-host-name", "example.com"}, |
| 5681 | resumeSession: true, |
| 5682 | }) |
| 5683 | testCases = append(testCases, testCase{ |
| 5684 | testType: clientTest, |
| 5685 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5686 | config: Config{ |
| 5687 | MaxVersion: ver.version, |
| 5688 | Bugs: ProtocolBugs{ |
| 5689 | SendServerNameAck: true, |
| 5690 | }, |
| 5691 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5692 | tls13Variant: ver.tls13Variant, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5693 | shouldFail: true, |
| 5694 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5695 | expectedLocalError: "remote error: unsupported extension", |
| 5696 | }) |
| 5697 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5698 | testType: serverTest, |
| 5699 | name: "ServerNameExtensionServer-" + ver.name, |
| 5700 | config: Config{ |
| 5701 | MaxVersion: ver.version, |
| 5702 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5703 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5704 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5705 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5706 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5707 | }) |
| 5708 | |
| 5709 | // Test ALPN. |
| 5710 | testCases = append(testCases, testCase{ |
| 5711 | testType: clientTest, |
| 5712 | name: "ALPNClient-" + ver.name, |
| 5713 | config: Config{ |
| 5714 | MaxVersion: ver.version, |
| 5715 | NextProtos: []string{"foo"}, |
| 5716 | }, |
| 5717 | flags: []string{ |
| 5718 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5719 | "-expect-alpn", "foo", |
| 5720 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5721 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5722 | expectedNextProto: "foo", |
| 5723 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5724 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5725 | }) |
| 5726 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5727 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5728 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5729 | config: Config{ |
| 5730 | MaxVersion: ver.version, |
| 5731 | Bugs: ProtocolBugs{ |
| 5732 | SendALPN: "baz", |
| 5733 | }, |
| 5734 | }, |
| 5735 | flags: []string{ |
| 5736 | "-advertise-alpn", "\x03foo\x03bar", |
| 5737 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5738 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5739 | shouldFail: true, |
| 5740 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5741 | expectedLocalError: "remote error: illegal parameter", |
| 5742 | }) |
| 5743 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5744 | testType: clientTest, |
| 5745 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5746 | config: Config{ |
| 5747 | MaxVersion: ver.version, |
| 5748 | Bugs: ProtocolBugs{ |
| 5749 | SendALPN: "baz", |
| 5750 | }, |
| 5751 | }, |
| 5752 | flags: []string{ |
| 5753 | "-advertise-alpn", "\x03foo\x03bar", |
| 5754 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5755 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5756 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5757 | tls13Variant: ver.tls13Variant, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5758 | }) |
| 5759 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5760 | testType: serverTest, |
| 5761 | name: "ALPNServer-" + ver.name, |
| 5762 | config: Config{ |
| 5763 | MaxVersion: ver.version, |
| 5764 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5765 | }, |
| 5766 | flags: []string{ |
| 5767 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5768 | "-select-alpn", "foo", |
| 5769 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5770 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5771 | expectedNextProto: "foo", |
| 5772 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5773 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5774 | }) |
| 5775 | testCases = append(testCases, testCase{ |
| 5776 | testType: serverTest, |
| 5777 | name: "ALPNServer-Decline-" + ver.name, |
| 5778 | config: Config{ |
| 5779 | MaxVersion: ver.version, |
| 5780 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5781 | }, |
| 5782 | flags: []string{"-decline-alpn"}, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5783 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5784 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5785 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5786 | }) |
| 5787 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5788 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5789 | // called once. |
| 5790 | testCases = append(testCases, testCase{ |
| 5791 | testType: serverTest, |
| 5792 | name: "ALPNServer-Async-" + ver.name, |
| 5793 | config: Config{ |
| 5794 | MaxVersion: ver.version, |
| 5795 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5796 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5797 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5798 | }, |
| 5799 | flags: []string{ |
| 5800 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5801 | "-select-alpn", "foo", |
| 5802 | "-async", |
| 5803 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5804 | tls13Variant: ver.tls13Variant, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5805 | expectedNextProto: "foo", |
| 5806 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5807 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5808 | }) |
| 5809 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5810 | var emptyString string |
| 5811 | testCases = append(testCases, testCase{ |
| 5812 | testType: clientTest, |
| 5813 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5814 | config: Config{ |
| 5815 | MaxVersion: ver.version, |
| 5816 | NextProtos: []string{""}, |
| 5817 | Bugs: ProtocolBugs{ |
| 5818 | // A server returning an empty ALPN protocol |
| 5819 | // should be rejected. |
| 5820 | ALPNProtocol: &emptyString, |
| 5821 | }, |
| 5822 | }, |
| 5823 | flags: []string{ |
| 5824 | "-advertise-alpn", "\x03foo", |
| 5825 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5826 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5827 | shouldFail: true, |
| 5828 | expectedError: ":PARSE_TLSEXT:", |
| 5829 | }) |
| 5830 | testCases = append(testCases, testCase{ |
| 5831 | testType: serverTest, |
| 5832 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5833 | config: Config{ |
| 5834 | MaxVersion: ver.version, |
| 5835 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5836 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5837 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5838 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5839 | flags: []string{ |
| 5840 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5841 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5842 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5843 | shouldFail: true, |
| 5844 | expectedError: ":PARSE_TLSEXT:", |
| 5845 | }) |
| 5846 | |
| 5847 | // Test NPN and the interaction with ALPN. |
| 5848 | if ver.version < VersionTLS13 { |
| 5849 | // Test that the server prefers ALPN over NPN. |
| 5850 | testCases = append(testCases, testCase{ |
| 5851 | testType: serverTest, |
| 5852 | name: "ALPNServer-Preferred-" + ver.name, |
| 5853 | config: Config{ |
| 5854 | MaxVersion: ver.version, |
| 5855 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5856 | }, |
| 5857 | flags: []string{ |
| 5858 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5859 | "-select-alpn", "foo", |
| 5860 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5861 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5862 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5863 | expectedNextProto: "foo", |
| 5864 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5865 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5866 | }) |
| 5867 | testCases = append(testCases, testCase{ |
| 5868 | testType: serverTest, |
| 5869 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5870 | config: Config{ |
| 5871 | MaxVersion: ver.version, |
| 5872 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5873 | Bugs: ProtocolBugs{ |
| 5874 | SwapNPNAndALPN: true, |
| 5875 | }, |
| 5876 | }, |
| 5877 | flags: []string{ |
| 5878 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5879 | "-select-alpn", "foo", |
| 5880 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5881 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5882 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5883 | expectedNextProto: "foo", |
| 5884 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5885 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5886 | }) |
| 5887 | |
| 5888 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5889 | testCases = append(testCases, testCase{ |
| 5890 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5891 | config: Config{ |
| 5892 | MaxVersion: ver.version, |
| 5893 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5894 | Bugs: ProtocolBugs{ |
| 5895 | NegotiateALPNAndNPN: true, |
| 5896 | }, |
| 5897 | }, |
| 5898 | flags: []string{ |
| 5899 | "-advertise-alpn", "\x03foo", |
| 5900 | "-select-next-proto", "foo", |
| 5901 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5902 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5903 | shouldFail: true, |
| 5904 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5905 | }) |
| 5906 | testCases = append(testCases, testCase{ |
| 5907 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5908 | config: Config{ |
| 5909 | MaxVersion: ver.version, |
| 5910 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5911 | Bugs: ProtocolBugs{ |
| 5912 | NegotiateALPNAndNPN: true, |
| 5913 | SwapNPNAndALPN: true, |
| 5914 | }, |
| 5915 | }, |
| 5916 | flags: []string{ |
| 5917 | "-advertise-alpn", "\x03foo", |
| 5918 | "-select-next-proto", "foo", |
| 5919 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5920 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5921 | shouldFail: true, |
| 5922 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5923 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5924 | } |
| 5925 | |
| 5926 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5927 | |
| 5928 | // Resume with a corrupt ticket. |
| 5929 | testCases = append(testCases, testCase{ |
| 5930 | testType: serverTest, |
| 5931 | name: "CorruptTicket-" + ver.name, |
| 5932 | config: Config{ |
| 5933 | MaxVersion: ver.version, |
| 5934 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5935 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5936 | in[len(in)-1] ^= 1 |
| 5937 | return in, nil |
| 5938 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5939 | }, |
| 5940 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5941 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5942 | resumeSession: true, |
| 5943 | expectResumeRejected: true, |
| 5944 | }) |
| 5945 | // Test the ticket callback, with and without renewal. |
| 5946 | testCases = append(testCases, testCase{ |
| 5947 | testType: serverTest, |
| 5948 | name: "TicketCallback-" + ver.name, |
| 5949 | config: Config{ |
| 5950 | MaxVersion: ver.version, |
| 5951 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5952 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5953 | resumeSession: true, |
| 5954 | flags: []string{"-use-ticket-callback"}, |
| 5955 | }) |
| 5956 | testCases = append(testCases, testCase{ |
| 5957 | testType: serverTest, |
| 5958 | name: "TicketCallback-Renew-" + ver.name, |
| 5959 | config: Config{ |
| 5960 | MaxVersion: ver.version, |
| 5961 | Bugs: ProtocolBugs{ |
| 5962 | ExpectNewTicket: true, |
| 5963 | }, |
| 5964 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5965 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5966 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5967 | resumeSession: true, |
| 5968 | }) |
| 5969 | |
| 5970 | // Test that the ticket callback is only called once when everything before |
| 5971 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5972 | // certificate selection callbacks run. |
| 5973 | testCases = append(testCases, testCase{ |
| 5974 | testType: serverTest, |
| 5975 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5976 | config: Config{ |
| 5977 | MaxVersion: ver.version, |
| 5978 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5979 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5980 | in[len(in)-1] ^= 1 |
| 5981 | return in, nil |
| 5982 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5983 | }, |
| 5984 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 5985 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5986 | resumeSession: true, |
| 5987 | expectResumeRejected: true, |
| 5988 | flags: []string{ |
| 5989 | "-use-ticket-callback", |
| 5990 | "-async", |
| 5991 | }, |
| 5992 | }) |
| 5993 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5994 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5995 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5996 | testCases = append(testCases, testCase{ |
| 5997 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5998 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5999 | config: Config{ |
| 6000 | MaxVersion: ver.version, |
| 6001 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6002 | EmptyTicketSessionID: true, |
| 6003 | }, |
| 6004 | }, |
| 6005 | resumeSession: true, |
| 6006 | }) |
| 6007 | testCases = append(testCases, testCase{ |
| 6008 | testType: serverTest, |
| 6009 | name: "TicketSessionIDLength-16-" + ver.name, |
| 6010 | config: Config{ |
| 6011 | MaxVersion: ver.version, |
| 6012 | Bugs: ProtocolBugs{ |
| 6013 | TicketSessionIDLength: 16, |
| 6014 | }, |
| 6015 | }, |
| 6016 | resumeSession: true, |
| 6017 | }) |
| 6018 | testCases = append(testCases, testCase{ |
| 6019 | testType: serverTest, |
| 6020 | name: "TicketSessionIDLength-32-" + ver.name, |
| 6021 | config: Config{ |
| 6022 | MaxVersion: ver.version, |
| 6023 | Bugs: ProtocolBugs{ |
| 6024 | TicketSessionIDLength: 32, |
| 6025 | }, |
| 6026 | }, |
| 6027 | resumeSession: true, |
| 6028 | }) |
| 6029 | testCases = append(testCases, testCase{ |
| 6030 | testType: serverTest, |
| 6031 | name: "TicketSessionIDLength-33-" + ver.name, |
| 6032 | config: Config{ |
| 6033 | MaxVersion: ver.version, |
| 6034 | Bugs: ProtocolBugs{ |
| 6035 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6036 | }, |
| 6037 | }, |
| 6038 | resumeSession: true, |
| 6039 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 6040 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6041 | expectedError: ":DECODE_ERROR:", |
| 6042 | }) |
| 6043 | } |
| 6044 | |
| 6045 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 6046 | // are ignored. |
| 6047 | if ver.hasDTLS { |
| 6048 | testCases = append(testCases, testCase{ |
| 6049 | protocol: dtls, |
| 6050 | name: "SRTP-Client-" + ver.name, |
| 6051 | config: Config{ |
| 6052 | MaxVersion: ver.version, |
| 6053 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6054 | }, |
| 6055 | flags: []string{ |
| 6056 | "-srtp-profiles", |
| 6057 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6058 | }, |
| 6059 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6060 | }) |
| 6061 | testCases = append(testCases, testCase{ |
| 6062 | protocol: dtls, |
| 6063 | testType: serverTest, |
| 6064 | name: "SRTP-Server-" + ver.name, |
| 6065 | config: Config{ |
| 6066 | MaxVersion: ver.version, |
| 6067 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 6068 | }, |
| 6069 | flags: []string{ |
| 6070 | "-srtp-profiles", |
| 6071 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6072 | }, |
| 6073 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6074 | }) |
| 6075 | // Test that the MKI is ignored. |
| 6076 | testCases = append(testCases, testCase{ |
| 6077 | protocol: dtls, |
| 6078 | testType: serverTest, |
| 6079 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 6080 | config: Config{ |
| 6081 | MaxVersion: ver.version, |
| 6082 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 6083 | Bugs: ProtocolBugs{ |
| 6084 | SRTPMasterKeyIdentifer: "bogus", |
| 6085 | }, |
| 6086 | }, |
| 6087 | flags: []string{ |
| 6088 | "-srtp-profiles", |
| 6089 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6090 | }, |
| 6091 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 6092 | }) |
| 6093 | // Test that SRTP isn't negotiated on the server if there were |
| 6094 | // no matching profiles. |
| 6095 | testCases = append(testCases, testCase{ |
| 6096 | protocol: dtls, |
| 6097 | testType: serverTest, |
| 6098 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 6099 | config: Config{ |
| 6100 | MaxVersion: ver.version, |
| 6101 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 6102 | }, |
| 6103 | flags: []string{ |
| 6104 | "-srtp-profiles", |
| 6105 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 6106 | }, |
| 6107 | expectedSRTPProtectionProfile: 0, |
| 6108 | }) |
| 6109 | // Test that the server returning an invalid SRTP profile is |
| 6110 | // flagged as an error by the client. |
| 6111 | testCases = append(testCases, testCase{ |
| 6112 | protocol: dtls, |
| 6113 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 6114 | config: Config{ |
| 6115 | MaxVersion: ver.version, |
| 6116 | Bugs: ProtocolBugs{ |
| 6117 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 6118 | }, |
| 6119 | }, |
| 6120 | flags: []string{ |
| 6121 | "-srtp-profiles", |
| 6122 | "SRTP_AES128_CM_SHA1_80", |
| 6123 | }, |
| 6124 | shouldFail: true, |
| 6125 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 6126 | }) |
| 6127 | } |
| 6128 | |
| 6129 | // Test SCT list. |
| 6130 | testCases = append(testCases, testCase{ |
| 6131 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 6132 | testType: clientTest, |
| 6133 | config: Config{ |
| 6134 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 6135 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6136 | flags: []string{ |
| 6137 | "-enable-signed-cert-timestamps", |
| 6138 | "-expect-signed-cert-timestamps", |
| 6139 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6140 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6141 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6142 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6143 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6144 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6145 | var differentSCTList []byte |
| 6146 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6147 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6148 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6149 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 6150 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6151 | testCases = append(testCases, testCase{ |
| 6152 | name: "SendSCTListOnResume-" + ver.name, |
| 6153 | config: Config{ |
| 6154 | MaxVersion: ver.version, |
| 6155 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6156 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6157 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 6158 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6159 | flags: []string{ |
| 6160 | "-enable-signed-cert-timestamps", |
| 6161 | "-expect-signed-cert-timestamps", |
| 6162 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 6163 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6164 | tls13Variant: ver.tls13Variant, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6165 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6166 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6167 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6168 | testCases = append(testCases, testCase{ |
| 6169 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 6170 | testType: serverTest, |
| 6171 | config: Config{ |
| 6172 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6173 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6174 | flags: []string{ |
| 6175 | "-signed-cert-timestamps", |
| 6176 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 6177 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6178 | tls13Variant: ver.tls13Variant, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6179 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6180 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6181 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6182 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6183 | emptySCTListCert := *testCerts[0].cert |
| 6184 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 6185 | |
| 6186 | // Test empty SCT list. |
| 6187 | testCases = append(testCases, testCase{ |
| 6188 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 6189 | testType: clientTest, |
| 6190 | config: Config{ |
| 6191 | MaxVersion: ver.version, |
| 6192 | Certificates: []Certificate{emptySCTListCert}, |
| 6193 | }, |
| 6194 | flags: []string{ |
| 6195 | "-enable-signed-cert-timestamps", |
| 6196 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6197 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6198 | shouldFail: true, |
| 6199 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6200 | }) |
| 6201 | |
| 6202 | emptySCTCert := *testCerts[0].cert |
| 6203 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 6204 | |
| 6205 | // Test empty SCT in non-empty list. |
| 6206 | testCases = append(testCases, testCase{ |
| 6207 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 6208 | testType: clientTest, |
| 6209 | config: Config{ |
| 6210 | MaxVersion: ver.version, |
| 6211 | Certificates: []Certificate{emptySCTCert}, |
| 6212 | }, |
| 6213 | flags: []string{ |
| 6214 | "-enable-signed-cert-timestamps", |
| 6215 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6216 | tls13Variant: ver.tls13Variant, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6217 | shouldFail: true, |
| 6218 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6219 | }) |
| 6220 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6221 | // Test that certificate-related extensions are not sent unsolicited. |
| 6222 | testCases = append(testCases, testCase{ |
| 6223 | testType: serverTest, |
| 6224 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 6225 | config: Config{ |
| 6226 | MaxVersion: ver.version, |
| 6227 | Bugs: ProtocolBugs{ |
| 6228 | NoOCSPStapling: true, |
| 6229 | NoSignedCertificateTimestamps: true, |
| 6230 | }, |
| 6231 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 6232 | tls13Variant: ver.tls13Variant, |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 6233 | flags: []string{ |
| 6234 | "-ocsp-response", |
| 6235 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6236 | "-signed-cert-timestamps", |
| 6237 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6238 | }, |
| 6239 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 6240 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6241 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 6242 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 6243 | testType: clientTest, |
| 6244 | name: "ClientHelloPadding", |
| 6245 | config: Config{ |
| 6246 | Bugs: ProtocolBugs{ |
| 6247 | RequireClientHelloSize: 512, |
| 6248 | }, |
| 6249 | }, |
| 6250 | // This hostname just needs to be long enough to push the |
| 6251 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 6252 | // long. |
| 6253 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 6254 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6255 | |
| 6256 | // Extensions should not function in SSL 3.0. |
| 6257 | testCases = append(testCases, testCase{ |
| 6258 | testType: serverTest, |
| 6259 | name: "SSLv3Extensions-NoALPN", |
| 6260 | config: Config{ |
| 6261 | MaxVersion: VersionSSL30, |
| 6262 | NextProtos: []string{"foo", "bar", "baz"}, |
| 6263 | }, |
| 6264 | flags: []string{ |
| 6265 | "-select-alpn", "foo", |
| 6266 | }, |
| 6267 | expectNoNextProto: true, |
| 6268 | }) |
| 6269 | |
| 6270 | // Test session tickets separately as they follow a different codepath. |
| 6271 | testCases = append(testCases, testCase{ |
| 6272 | testType: serverTest, |
| 6273 | name: "SSLv3Extensions-NoTickets", |
| 6274 | config: Config{ |
| 6275 | MaxVersion: VersionSSL30, |
| 6276 | Bugs: ProtocolBugs{ |
| 6277 | // Historically, session tickets in SSL 3.0 |
| 6278 | // failed in different ways depending on whether |
| 6279 | // the client supported renegotiation_info. |
| 6280 | NoRenegotiationInfo: true, |
| 6281 | }, |
| 6282 | }, |
| 6283 | resumeSession: true, |
| 6284 | }) |
| 6285 | testCases = append(testCases, testCase{ |
| 6286 | testType: serverTest, |
| 6287 | name: "SSLv3Extensions-NoTickets2", |
| 6288 | config: Config{ |
| 6289 | MaxVersion: VersionSSL30, |
| 6290 | }, |
| 6291 | resumeSession: true, |
| 6292 | }) |
| 6293 | |
| 6294 | // But SSL 3.0 does send and process renegotiation_info. |
| 6295 | testCases = append(testCases, testCase{ |
| 6296 | testType: serverTest, |
| 6297 | name: "SSLv3Extensions-RenegotiationInfo", |
| 6298 | config: Config{ |
| 6299 | MaxVersion: VersionSSL30, |
| 6300 | Bugs: ProtocolBugs{ |
| 6301 | RequireRenegotiationInfo: true, |
| 6302 | }, |
| 6303 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6304 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6305 | }) |
| 6306 | testCases = append(testCases, testCase{ |
| 6307 | testType: serverTest, |
| 6308 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 6309 | config: Config{ |
| 6310 | MaxVersion: VersionSSL30, |
| 6311 | Bugs: ProtocolBugs{ |
| 6312 | NoRenegotiationInfo: true, |
| 6313 | SendRenegotiationSCSV: true, |
| 6314 | RequireRenegotiationInfo: true, |
| 6315 | }, |
| 6316 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6317 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 6318 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6319 | |
| 6320 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 6321 | // in ServerHello. |
| 6322 | testCases = append(testCases, testCase{ |
| 6323 | name: "NPN-Forbidden-TLS13", |
| 6324 | config: Config{ |
| 6325 | MaxVersion: VersionTLS13, |
| 6326 | NextProtos: []string{"foo"}, |
| 6327 | Bugs: ProtocolBugs{ |
| 6328 | NegotiateNPNAtAllVersions: true, |
| 6329 | }, |
| 6330 | }, |
| 6331 | flags: []string{"-select-next-proto", "foo"}, |
| 6332 | shouldFail: true, |
| 6333 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6334 | }) |
| 6335 | testCases = append(testCases, testCase{ |
| 6336 | name: "EMS-Forbidden-TLS13", |
| 6337 | config: Config{ |
| 6338 | MaxVersion: VersionTLS13, |
| 6339 | Bugs: ProtocolBugs{ |
| 6340 | NegotiateEMSAtAllVersions: true, |
| 6341 | }, |
| 6342 | }, |
| 6343 | shouldFail: true, |
| 6344 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6345 | }) |
| 6346 | testCases = append(testCases, testCase{ |
| 6347 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 6348 | config: Config{ |
| 6349 | MaxVersion: VersionTLS13, |
| 6350 | Bugs: ProtocolBugs{ |
| 6351 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 6352 | }, |
| 6353 | }, |
| 6354 | shouldFail: true, |
| 6355 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6356 | }) |
| 6357 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6358 | name: "Ticket-Forbidden-TLS13", |
| 6359 | config: Config{ |
| 6360 | MaxVersion: VersionTLS12, |
| 6361 | }, |
| 6362 | resumeConfig: &Config{ |
| 6363 | MaxVersion: VersionTLS13, |
| 6364 | Bugs: ProtocolBugs{ |
| 6365 | AdvertiseTicketExtension: true, |
| 6366 | }, |
| 6367 | }, |
| 6368 | resumeSession: true, |
| 6369 | shouldFail: true, |
| 6370 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 6371 | }) |
| 6372 | |
| 6373 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 6374 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 6375 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 6376 | // implicit in every test.) |
| 6377 | testCases = append(testCases, testCase{ |
| 6378 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 6379 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6380 | config: Config{ |
| 6381 | MaxVersion: VersionTLS13, |
| 6382 | NextProtos: []string{"bar"}, |
| 6383 | }, |
| 6384 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 6385 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 6386 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6387 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 6388 | // tolerated. |
| 6389 | testCases = append(testCases, testCase{ |
| 6390 | name: "SendOCSPResponseOnResume-TLS12", |
| 6391 | config: Config{ |
| 6392 | MaxVersion: VersionTLS12, |
| 6393 | Bugs: ProtocolBugs{ |
| 6394 | SendOCSPResponseOnResume: []byte("bogus"), |
| 6395 | }, |
| 6396 | }, |
| 6397 | flags: []string{ |
| 6398 | "-enable-ocsp-stapling", |
| 6399 | "-expect-ocsp-response", |
| 6400 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6401 | }, |
| 6402 | resumeSession: true, |
| 6403 | }) |
| 6404 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6405 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6406 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6407 | config: Config{ |
| 6408 | MaxVersion: VersionTLS13, |
| 6409 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6410 | SendExtensionOnCertificate: testOCSPExtension, |
| 6411 | }, |
| 6412 | }, |
| 6413 | shouldFail: true, |
| 6414 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6415 | }) |
| 6416 | |
| 6417 | testCases = append(testCases, testCase{ |
| 6418 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 6419 | config: Config{ |
| 6420 | MaxVersion: VersionTLS13, |
| 6421 | Bugs: ProtocolBugs{ |
| 6422 | SendExtensionOnCertificate: testSCTExtension, |
| 6423 | }, |
| 6424 | }, |
| 6425 | shouldFail: true, |
| 6426 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6427 | }) |
| 6428 | |
| 6429 | // Test that extensions on client certificates are never accepted. |
| 6430 | testCases = append(testCases, testCase{ |
| 6431 | name: "SendExtensionOnClientCertificate-TLS13", |
| 6432 | testType: serverTest, |
| 6433 | config: Config{ |
| 6434 | MaxVersion: VersionTLS13, |
| 6435 | Certificates: []Certificate{rsaCertificate}, |
| 6436 | Bugs: ProtocolBugs{ |
| 6437 | SendExtensionOnCertificate: testOCSPExtension, |
| 6438 | }, |
| 6439 | }, |
| 6440 | flags: []string{ |
| 6441 | "-enable-ocsp-stapling", |
| 6442 | "-require-any-client-certificate", |
| 6443 | }, |
| 6444 | shouldFail: true, |
| 6445 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6446 | }) |
| 6447 | |
| 6448 | testCases = append(testCases, testCase{ |
| 6449 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 6450 | config: Config{ |
| 6451 | MaxVersion: VersionTLS13, |
| 6452 | Bugs: ProtocolBugs{ |
| 6453 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 6454 | }, |
| 6455 | }, |
| 6456 | shouldFail: true, |
| 6457 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6458 | }) |
| 6459 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6460 | var differentSCTList []byte |
| 6461 | differentSCTList = append(differentSCTList, testSCTList...) |
| 6462 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 6463 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6464 | // Test that extensions on intermediates are allowed but ignored. |
| 6465 | testCases = append(testCases, testCase{ |
| 6466 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 6467 | config: Config{ |
| 6468 | MaxVersion: VersionTLS13, |
| 6469 | Certificates: []Certificate{rsaChainCertificate}, |
| 6470 | Bugs: ProtocolBugs{ |
| 6471 | // Send different values on the intermediate. This tests |
| 6472 | // the intermediate's extensions do not override the |
| 6473 | // leaf's. |
| 6474 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 6475 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6476 | }, |
| 6477 | }, |
| 6478 | flags: []string{ |
| 6479 | "-enable-ocsp-stapling", |
| 6480 | "-expect-ocsp-response", |
| 6481 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6482 | "-enable-signed-cert-timestamps", |
| 6483 | "-expect-signed-cert-timestamps", |
| 6484 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6485 | }, |
| 6486 | resumeSession: true, |
| 6487 | }) |
| 6488 | |
| 6489 | // Test that extensions are not sent on intermediates when configured |
| 6490 | // only for a leaf. |
| 6491 | testCases = append(testCases, testCase{ |
| 6492 | testType: serverTest, |
| 6493 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 6494 | config: Config{ |
| 6495 | MaxVersion: VersionTLS13, |
| 6496 | Bugs: ProtocolBugs{ |
| 6497 | ExpectNoExtensionsOnIntermediate: true, |
| 6498 | }, |
| 6499 | }, |
| 6500 | flags: []string{ |
| 6501 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 6502 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 6503 | "-ocsp-response", |
| 6504 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6505 | "-signed-cert-timestamps", |
| 6506 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6507 | }, |
| 6508 | }) |
| 6509 | |
| 6510 | // Test that extensions are not sent on client certificates. |
| 6511 | testCases = append(testCases, testCase{ |
| 6512 | name: "SendNoClientCertificateExtensions-TLS13", |
| 6513 | config: Config{ |
| 6514 | MaxVersion: VersionTLS13, |
| 6515 | ClientAuth: RequireAnyClientCert, |
| 6516 | }, |
| 6517 | flags: []string{ |
| 6518 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 6519 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 6520 | "-ocsp-response", |
| 6521 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 6522 | "-signed-cert-timestamps", |
| 6523 | base64.StdEncoding.EncodeToString(testSCTList), |
| 6524 | }, |
| 6525 | }) |
| 6526 | |
| 6527 | testCases = append(testCases, testCase{ |
| 6528 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 6529 | config: Config{ |
| 6530 | MaxVersion: VersionTLS13, |
| 6531 | Bugs: ProtocolBugs{ |
| 6532 | SendDuplicateCertExtensions: true, |
| 6533 | }, |
| 6534 | }, |
| 6535 | flags: []string{ |
| 6536 | "-enable-ocsp-stapling", |
| 6537 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6538 | }, |
| 6539 | resumeSession: true, |
| 6540 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6541 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 6542 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6543 | |
| 6544 | testCases = append(testCases, testCase{ |
| 6545 | name: "SignedCertificateTimestampListInvalid-Server", |
| 6546 | testType: serverTest, |
| 6547 | flags: []string{ |
| 6548 | "-signed-cert-timestamps", |
| 6549 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 6550 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 6551 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 6552 | expectedError: ":INVALID_SCT_LIST:", |
| 6553 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 6554 | } |
| 6555 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6556 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6557 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6558 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6559 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 6560 | // have session IDs, so skip their cross-resumption |
| 6561 | // tests. |
| 6562 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 6563 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 6564 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6565 | } |
| 6566 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6567 | protocols := []protocol{tls} |
| 6568 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 6569 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 6570 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6571 | for _, protocol := range protocols { |
| 6572 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 6573 | if protocol == dtls { |
| 6574 | suffix += "-DTLS" |
| 6575 | } |
| 6576 | |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6577 | // We can't resume across TLS 1.3 variants and error out earlier in the |
| 6578 | // session resumption. |
| 6579 | if sessionVers.tls13Variant != resumeVers.tls13Variant { |
| 6580 | continue |
| 6581 | } |
| 6582 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6583 | if sessionVers.version == resumeVers.version { |
| 6584 | testCases = append(testCases, testCase{ |
| 6585 | protocol: protocol, |
| 6586 | name: "Resume-Client" + suffix, |
| 6587 | resumeSession: true, |
| 6588 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6589 | MaxVersion: sessionVers.version, |
| 6590 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6591 | Bugs: ProtocolBugs{ |
| 6592 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 6593 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 6594 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6595 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6596 | expectedVersion: sessionVers.version, |
| 6597 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6598 | flags: []string{ |
| 6599 | "-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6600 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6601 | }) |
| 6602 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6603 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 6604 | |
| 6605 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 6606 | // there is no way to convince a non-lookahead client the |
| 6607 | // session was resumed. It will appear to the client that a |
| 6608 | // stray ChangeCipherSpec was sent. |
| 6609 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 6610 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6611 | } |
| 6612 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6613 | testCases = append(testCases, testCase{ |
| 6614 | protocol: protocol, |
| 6615 | name: "Resume-Client-Mismatch" + suffix, |
| 6616 | resumeSession: true, |
| 6617 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6618 | MaxVersion: sessionVers.version, |
| 6619 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6620 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6621 | expectedVersion: sessionVers.version, |
| 6622 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6623 | MaxVersion: resumeVers.version, |
| 6624 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6625 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6626 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6627 | }, |
| 6628 | }, |
| 6629 | expectedResumeVersion: resumeVers.version, |
| 6630 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6631 | expectedError: error, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6632 | flags: []string{ |
| 6633 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6634 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6635 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6636 | }) |
| 6637 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6638 | |
| 6639 | testCases = append(testCases, testCase{ |
| 6640 | protocol: protocol, |
| 6641 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6642 | resumeSession: true, |
| 6643 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6644 | MaxVersion: sessionVers.version, |
| 6645 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6646 | }, |
| 6647 | expectedVersion: sessionVers.version, |
| 6648 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6649 | MaxVersion: resumeVers.version, |
| 6650 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6651 | }, |
| 6652 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6653 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6654 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6655 | flags: []string{ |
| 6656 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6657 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6658 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6659 | }) |
| 6660 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6661 | testCases = append(testCases, testCase{ |
| 6662 | protocol: protocol, |
| 6663 | testType: serverTest, |
| 6664 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6665 | resumeSession: true, |
| 6666 | config: Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6667 | MaxVersion: sessionVers.version, |
| 6668 | TLS13Variant: sessionVers.tls13Variant, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6669 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6670 | expectedVersion: sessionVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6671 | expectResumeRejected: sessionVers != resumeVers, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6672 | resumeConfig: &Config{ |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6673 | MaxVersion: resumeVers.version, |
| 6674 | TLS13Variant: resumeVers.tls13Variant, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6675 | Bugs: ProtocolBugs{ |
| 6676 | SendBothTickets: true, |
| 6677 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6678 | }, |
| 6679 | expectedResumeVersion: resumeVers.version, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 6680 | flags: []string{ |
| 6681 | "-on-initial-tls13-variant", strconv.Itoa(sessionVers.tls13Variant), |
| 6682 | "-on-resume-tls13-variant", strconv.Itoa(resumeVers.tls13Variant), |
| 6683 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6684 | }) |
| 6685 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6686 | } |
| 6687 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6688 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6689 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6690 | testCases = append(testCases, testCase{ |
| 6691 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6692 | name: "ShimTicketRewritable", |
| 6693 | resumeSession: true, |
| 6694 | config: Config{ |
| 6695 | MaxVersion: VersionTLS12, |
| 6696 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6697 | Bugs: ProtocolBugs{ |
| 6698 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6699 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6700 | if err != nil { |
| 6701 | return nil, err |
| 6702 | } |
| 6703 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6704 | }, |
| 6705 | }, |
| 6706 | }, |
| 6707 | flags: []string{ |
| 6708 | "-ticket-key", |
| 6709 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6710 | }, |
| 6711 | }) |
| 6712 | |
| 6713 | // Resumptions are declined if the version does not match. |
| 6714 | testCases = append(testCases, testCase{ |
| 6715 | testType: serverTest, |
| 6716 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6717 | resumeSession: true, |
| 6718 | config: Config{ |
| 6719 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6720 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6721 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6722 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6723 | return SetShimTicketVersion(in, VersionTLS13) |
| 6724 | }, |
| 6725 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6726 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6727 | flags: []string{ |
| 6728 | "-ticket-key", |
| 6729 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6730 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6731 | expectResumeRejected: true, |
| 6732 | }) |
| 6733 | |
| 6734 | testCases = append(testCases, testCase{ |
| 6735 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6736 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6737 | resumeSession: true, |
| 6738 | config: Config{ |
| 6739 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6740 | Bugs: ProtocolBugs{ |
| 6741 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6742 | return SetShimTicketVersion(in, VersionTLS12) |
| 6743 | }, |
| 6744 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6745 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6746 | flags: []string{ |
| 6747 | "-ticket-key", |
| 6748 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6749 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6750 | expectResumeRejected: true, |
| 6751 | }) |
| 6752 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6753 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6754 | testCases = append(testCases, testCase{ |
| 6755 | testType: serverTest, |
| 6756 | name: "Resume-Server-DeclineBadCipher", |
| 6757 | resumeSession: true, |
| 6758 | config: Config{ |
| 6759 | MaxVersion: VersionTLS12, |
| 6760 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6761 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6762 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6763 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6764 | }, |
| 6765 | }, |
| 6766 | }, |
| 6767 | flags: []string{ |
| 6768 | "-ticket-key", |
| 6769 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6770 | }, |
| 6771 | expectResumeRejected: true, |
| 6772 | }) |
| 6773 | |
| 6774 | testCases = append(testCases, testCase{ |
| 6775 | testType: serverTest, |
| 6776 | name: "Resume-Server-DeclineBadCipher-2", |
| 6777 | resumeSession: true, |
| 6778 | config: Config{ |
| 6779 | MaxVersion: VersionTLS12, |
| 6780 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6781 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6782 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6783 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6784 | }, |
| 6785 | }, |
| 6786 | }, |
| 6787 | flags: []string{ |
| 6788 | "-cipher", "AES128", |
| 6789 | "-ticket-key", |
| 6790 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6791 | }, |
| 6792 | expectResumeRejected: true, |
| 6793 | }) |
| 6794 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6795 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6796 | testCases = append(testCases, testCase{ |
| 6797 | testType: serverTest, |
| 6798 | name: "Resume-Server-CipherNotPreferred", |
| 6799 | resumeSession: true, |
| 6800 | config: Config{ |
| 6801 | MaxVersion: VersionTLS12, |
| 6802 | Bugs: ProtocolBugs{ |
| 6803 | ExpectNewTicket: true, |
| 6804 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6805 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6806 | }, |
| 6807 | }, |
| 6808 | }, |
| 6809 | flags: []string{ |
| 6810 | "-ticket-key", |
| 6811 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6812 | }, |
| 6813 | shouldFail: false, |
| 6814 | expectResumeRejected: true, |
| 6815 | }) |
| 6816 | |
| 6817 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6818 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6819 | testCases = append(testCases, testCase{ |
| 6820 | testType: serverTest, |
| 6821 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6822 | resumeSession: true, |
| 6823 | config: Config{ |
| 6824 | MaxVersion: VersionTLS13, |
| 6825 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6826 | Bugs: ProtocolBugs{ |
| 6827 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6828 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6829 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6830 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6831 | }, |
| 6832 | }, |
| 6833 | }, |
| 6834 | flags: []string{ |
| 6835 | "-ticket-key", |
| 6836 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6837 | }, |
| 6838 | shouldFail: false, |
| 6839 | expectResumeRejected: true, |
| 6840 | }) |
| 6841 | |
| 6842 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6843 | testCases = append(testCases, testCase{ |
| 6844 | testType: serverTest, |
| 6845 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6846 | resumeSession: true, |
| 6847 | config: Config{ |
| 6848 | MaxVersion: VersionTLS13, |
| 6849 | Bugs: ProtocolBugs{ |
| 6850 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6851 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6852 | }, |
| 6853 | }, |
| 6854 | }, |
| 6855 | flags: []string{ |
| 6856 | "-ticket-key", |
| 6857 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6858 | }, |
| 6859 | expectResumeRejected: true, |
| 6860 | }) |
| 6861 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6862 | // If the client does not offer the cipher from the session, decline to |
| 6863 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6864 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6865 | testCases = append(testCases, testCase{ |
| 6866 | testType: serverTest, |
| 6867 | name: "Resume-Server-UnofferedCipher", |
| 6868 | resumeSession: true, |
| 6869 | config: Config{ |
| 6870 | MaxVersion: VersionTLS12, |
| 6871 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6872 | }, |
| 6873 | resumeConfig: &Config{ |
| 6874 | MaxVersion: VersionTLS12, |
| 6875 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6876 | Bugs: ProtocolBugs{ |
| 6877 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6878 | }, |
| 6879 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6880 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6881 | }) |
| 6882 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6883 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6884 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6885 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6886 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6887 | testCases = append(testCases, testCase{ |
| 6888 | testType: serverTest, |
| 6889 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6890 | resumeSession: true, |
| 6891 | config: Config{ |
| 6892 | MaxVersion: VersionTLS13, |
| 6893 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6894 | }, |
| 6895 | resumeConfig: &Config{ |
| 6896 | MaxVersion: VersionTLS13, |
| 6897 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6898 | Bugs: ProtocolBugs{ |
| 6899 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6900 | }, |
| 6901 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6902 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6903 | }) |
| 6904 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6905 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6906 | testCases = append(testCases, testCase{ |
| 6907 | name: "Resume-Client-CipherMismatch", |
| 6908 | resumeSession: true, |
| 6909 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6910 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6911 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6912 | }, |
| 6913 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6914 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6915 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6916 | Bugs: ProtocolBugs{ |
| 6917 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6918 | }, |
| 6919 | }, |
| 6920 | shouldFail: true, |
| 6921 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6922 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6923 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6924 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6925 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6926 | testCases = append(testCases, testCase{ |
| 6927 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6928 | resumeSession: true, |
| 6929 | config: Config{ |
| 6930 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6931 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6932 | }, |
| 6933 | resumeConfig: &Config{ |
| 6934 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6935 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6936 | }, |
| 6937 | }) |
| 6938 | |
| 6939 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6940 | testCases = append(testCases, testCase{ |
| 6941 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6942 | resumeSession: true, |
| 6943 | config: Config{ |
| 6944 | MaxVersion: VersionTLS13, |
| 6945 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6946 | }, |
| 6947 | resumeConfig: &Config{ |
| 6948 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6949 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6950 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6951 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6952 | }, |
| 6953 | }, |
| 6954 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6955 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6956 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6957 | |
| 6958 | testCases = append(testCases, testCase{ |
| 6959 | testType: serverTest, |
| 6960 | name: "Resume-Server-BinderWrongLength", |
| 6961 | resumeSession: true, |
| 6962 | config: Config{ |
| 6963 | MaxVersion: VersionTLS13, |
| 6964 | Bugs: ProtocolBugs{ |
| 6965 | SendShortPSKBinder: true, |
| 6966 | }, |
| 6967 | }, |
| 6968 | shouldFail: true, |
| 6969 | expectedLocalError: "remote error: error decrypting message", |
| 6970 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6971 | }) |
| 6972 | |
| 6973 | testCases = append(testCases, testCase{ |
| 6974 | testType: serverTest, |
| 6975 | name: "Resume-Server-NoPSKBinder", |
| 6976 | resumeSession: true, |
| 6977 | config: Config{ |
| 6978 | MaxVersion: VersionTLS13, |
| 6979 | Bugs: ProtocolBugs{ |
| 6980 | SendNoPSKBinder: true, |
| 6981 | }, |
| 6982 | }, |
| 6983 | shouldFail: true, |
| 6984 | expectedLocalError: "remote error: error decoding message", |
| 6985 | expectedError: ":DECODE_ERROR:", |
| 6986 | }) |
| 6987 | |
| 6988 | testCases = append(testCases, testCase{ |
| 6989 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6990 | name: "Resume-Server-ExtraPSKBinder", |
| 6991 | resumeSession: true, |
| 6992 | config: Config{ |
| 6993 | MaxVersion: VersionTLS13, |
| 6994 | Bugs: ProtocolBugs{ |
| 6995 | SendExtraPSKBinder: true, |
| 6996 | }, |
| 6997 | }, |
| 6998 | shouldFail: true, |
| 6999 | expectedLocalError: "remote error: illegal parameter", |
| 7000 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 7001 | }) |
| 7002 | |
| 7003 | testCases = append(testCases, testCase{ |
| 7004 | testType: serverTest, |
| 7005 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 7006 | resumeSession: true, |
| 7007 | config: Config{ |
| 7008 | MaxVersion: VersionTLS13, |
| 7009 | Bugs: ProtocolBugs{ |
| 7010 | ExtraPSKIdentity: true, |
| 7011 | }, |
| 7012 | }, |
| 7013 | shouldFail: true, |
| 7014 | expectedLocalError: "remote error: illegal parameter", |
| 7015 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 7016 | }) |
| 7017 | |
| 7018 | testCases = append(testCases, testCase{ |
| 7019 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 7020 | name: "Resume-Server-InvalidPSKBinder", |
| 7021 | resumeSession: true, |
| 7022 | config: Config{ |
| 7023 | MaxVersion: VersionTLS13, |
| 7024 | Bugs: ProtocolBugs{ |
| 7025 | SendInvalidPSKBinder: true, |
| 7026 | }, |
| 7027 | }, |
| 7028 | shouldFail: true, |
| 7029 | expectedLocalError: "remote error: error decrypting message", |
| 7030 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 7031 | }) |
| 7032 | |
| 7033 | testCases = append(testCases, testCase{ |
| 7034 | testType: serverTest, |
| 7035 | name: "Resume-Server-PSKBinderFirstExtension", |
| 7036 | resumeSession: true, |
| 7037 | config: Config{ |
| 7038 | MaxVersion: VersionTLS13, |
| 7039 | Bugs: ProtocolBugs{ |
| 7040 | PSKBinderFirst: true, |
| 7041 | }, |
| 7042 | }, |
| 7043 | shouldFail: true, |
| 7044 | expectedLocalError: "remote error: illegal parameter", |
| 7045 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 7046 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 7047 | } |
| 7048 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7049 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 7050 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7051 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7052 | testType: serverTest, |
| 7053 | name: "Renegotiate-Server-Forbidden", |
| 7054 | config: Config{ |
| 7055 | MaxVersion: VersionTLS12, |
| 7056 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7057 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7058 | shouldFail: true, |
| 7059 | expectedError: ":NO_RENEGOTIATION:", |
| 7060 | expectedLocalError: "remote error: no renegotiation", |
| 7061 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7062 | // The server shouldn't echo the renegotiation extension unless |
| 7063 | // requested by the client. |
| 7064 | testCases = append(testCases, testCase{ |
| 7065 | testType: serverTest, |
| 7066 | name: "Renegotiate-Server-NoExt", |
| 7067 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7068 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7069 | Bugs: ProtocolBugs{ |
| 7070 | NoRenegotiationInfo: true, |
| 7071 | RequireRenegotiationInfo: true, |
| 7072 | }, |
| 7073 | }, |
| 7074 | shouldFail: true, |
| 7075 | expectedLocalError: "renegotiation extension missing", |
| 7076 | }) |
| 7077 | // The renegotiation SCSV should be sufficient for the server to echo |
| 7078 | // the extension. |
| 7079 | testCases = append(testCases, testCase{ |
| 7080 | testType: serverTest, |
| 7081 | name: "Renegotiate-Server-NoExt-SCSV", |
| 7082 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7083 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 7084 | Bugs: ProtocolBugs{ |
| 7085 | NoRenegotiationInfo: true, |
| 7086 | SendRenegotiationSCSV: true, |
| 7087 | RequireRenegotiationInfo: true, |
| 7088 | }, |
| 7089 | }, |
| 7090 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7091 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7092 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7093 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7094 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7095 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 7096 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7097 | }, |
| 7098 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7099 | renegotiate: 1, |
| 7100 | flags: []string{ |
| 7101 | "-renegotiate-freely", |
| 7102 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7103 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7104 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 7105 | }) |
| 7106 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7107 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7108 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7109 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7110 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7111 | Bugs: ProtocolBugs{ |
| 7112 | EmptyRenegotiationInfo: true, |
| 7113 | }, |
| 7114 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7115 | flags: []string{"-renegotiate-freely"}, |
| 7116 | shouldFail: true, |
| 7117 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7118 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7119 | }) |
| 7120 | testCases = append(testCases, testCase{ |
| 7121 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7122 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7123 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7124 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7125 | Bugs: ProtocolBugs{ |
| 7126 | BadRenegotiationInfo: true, |
| 7127 | }, |
| 7128 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7129 | flags: []string{"-renegotiate-freely"}, |
| 7130 | shouldFail: true, |
| 7131 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7132 | expectedLocalError: "handshake failure", |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7133 | }) |
| 7134 | testCases = append(testCases, testCase{ |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7135 | name: "Renegotiate-Client-BadExt2", |
| 7136 | renegotiate: 1, |
| 7137 | config: Config{ |
| 7138 | MaxVersion: VersionTLS12, |
| 7139 | Bugs: ProtocolBugs{ |
| 7140 | BadRenegotiationInfoEnd: true, |
| 7141 | }, |
| 7142 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7143 | flags: []string{"-renegotiate-freely"}, |
| 7144 | shouldFail: true, |
| 7145 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7146 | expectedLocalError: "handshake failure", |
David Benjamin | 9343b0b | 2017-07-01 00:31:27 -0400 | [diff] [blame] | 7147 | }) |
| 7148 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7149 | name: "Renegotiate-Client-Downgrade", |
| 7150 | renegotiate: 1, |
| 7151 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7152 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7153 | Bugs: ProtocolBugs{ |
| 7154 | NoRenegotiationInfoAfterInitial: true, |
| 7155 | }, |
| 7156 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7157 | flags: []string{"-renegotiate-freely"}, |
| 7158 | shouldFail: true, |
| 7159 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7160 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7161 | }) |
| 7162 | testCases = append(testCases, testCase{ |
| 7163 | name: "Renegotiate-Client-Upgrade", |
| 7164 | renegotiate: 1, |
| 7165 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7166 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7167 | Bugs: ProtocolBugs{ |
| 7168 | NoRenegotiationInfoInInitial: true, |
| 7169 | }, |
| 7170 | }, |
Adam Langley | e6c58ff | 2017-07-28 11:00:11 -0700 | [diff] [blame] | 7171 | flags: []string{"-renegotiate-freely"}, |
| 7172 | shouldFail: true, |
| 7173 | expectedError: ":RENEGOTIATION_MISMATCH:", |
Adam Langley | 10e1060 | 2017-07-25 13:33:21 -0700 | [diff] [blame] | 7174 | expectedLocalError: "handshake failure", |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 7175 | }) |
| 7176 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7177 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7178 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7179 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7180 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7181 | Bugs: ProtocolBugs{ |
| 7182 | NoRenegotiationInfo: true, |
| 7183 | }, |
| 7184 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7185 | flags: []string{ |
| 7186 | "-renegotiate-freely", |
| 7187 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7188 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7189 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7190 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7191 | |
| 7192 | // Test that the server may switch ciphers on renegotiation without |
| 7193 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 7194 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7195 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7196 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7197 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7198 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7199 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7200 | }, |
| 7201 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7202 | flags: []string{ |
| 7203 | "-renegotiate-freely", |
| 7204 | "-expect-total-renegotiations", "1", |
| 7205 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7206 | }) |
| 7207 | testCases = append(testCases, testCase{ |
| 7208 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7209 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7210 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7211 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 7212 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7213 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 7214 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7215 | flags: []string{ |
| 7216 | "-renegotiate-freely", |
| 7217 | "-expect-total-renegotiations", "1", |
| 7218 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7219 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7220 | |
| 7221 | // Test that the server may not switch versions on renegotiation. |
| 7222 | testCases = append(testCases, testCase{ |
| 7223 | name: "Renegotiate-Client-SwitchVersion", |
| 7224 | config: Config{ |
| 7225 | MaxVersion: VersionTLS12, |
| 7226 | // Pick a cipher which exists at both versions. |
| 7227 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 7228 | Bugs: ProtocolBugs{ |
| 7229 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 7230 | // Avoid failing early at the record layer. |
| 7231 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 7232 | }, |
| 7233 | }, |
| 7234 | renegotiate: 1, |
| 7235 | flags: []string{ |
| 7236 | "-renegotiate-freely", |
| 7237 | "-expect-total-renegotiations", "1", |
| 7238 | }, |
| 7239 | shouldFail: true, |
| 7240 | expectedError: ":WRONG_SSL_VERSION:", |
| 7241 | }) |
| 7242 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 7243 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7244 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7245 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7246 | config: Config{ |
| 7247 | MaxVersion: VersionTLS10, |
| 7248 | Bugs: ProtocolBugs{ |
| 7249 | RequireSameRenegoClientVersion: true, |
| 7250 | }, |
| 7251 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7252 | flags: []string{ |
| 7253 | "-renegotiate-freely", |
| 7254 | "-expect-total-renegotiations", "1", |
| 7255 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 7256 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7257 | testCases = append(testCases, testCase{ |
| 7258 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7259 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7260 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 7261 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7262 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 7263 | NextProtos: []string{"foo"}, |
| 7264 | }, |
| 7265 | flags: []string{ |
| 7266 | "-false-start", |
| 7267 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7268 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 7269 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 7270 | }, |
| 7271 | shimWritesFirst: true, |
| 7272 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7273 | |
| 7274 | // Client-side renegotiation controls. |
| 7275 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7276 | name: "Renegotiate-Client-Forbidden-1", |
| 7277 | config: Config{ |
| 7278 | MaxVersion: VersionTLS12, |
| 7279 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7280 | renegotiate: 1, |
| 7281 | shouldFail: true, |
| 7282 | expectedError: ":NO_RENEGOTIATION:", |
| 7283 | expectedLocalError: "remote error: no renegotiation", |
| 7284 | }) |
| 7285 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7286 | name: "Renegotiate-Client-Once-1", |
| 7287 | config: Config{ |
| 7288 | MaxVersion: VersionTLS12, |
| 7289 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7290 | renegotiate: 1, |
| 7291 | flags: []string{ |
| 7292 | "-renegotiate-once", |
| 7293 | "-expect-total-renegotiations", "1", |
| 7294 | }, |
| 7295 | }) |
| 7296 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7297 | name: "Renegotiate-Client-Freely-1", |
| 7298 | config: Config{ |
| 7299 | MaxVersion: VersionTLS12, |
| 7300 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7301 | renegotiate: 1, |
| 7302 | flags: []string{ |
| 7303 | "-renegotiate-freely", |
| 7304 | "-expect-total-renegotiations", "1", |
| 7305 | }, |
| 7306 | }) |
| 7307 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7308 | name: "Renegotiate-Client-Once-2", |
| 7309 | config: Config{ |
| 7310 | MaxVersion: VersionTLS12, |
| 7311 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7312 | renegotiate: 2, |
| 7313 | flags: []string{"-renegotiate-once"}, |
| 7314 | shouldFail: true, |
| 7315 | expectedError: ":NO_RENEGOTIATION:", |
| 7316 | expectedLocalError: "remote error: no renegotiation", |
| 7317 | }) |
| 7318 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7319 | name: "Renegotiate-Client-Freely-2", |
| 7320 | config: Config{ |
| 7321 | MaxVersion: VersionTLS12, |
| 7322 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 7323 | renegotiate: 2, |
| 7324 | flags: []string{ |
| 7325 | "-renegotiate-freely", |
| 7326 | "-expect-total-renegotiations", "2", |
| 7327 | }, |
| 7328 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7329 | testCases = append(testCases, testCase{ |
| 7330 | name: "Renegotiate-Client-NoIgnore", |
| 7331 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7332 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7333 | Bugs: ProtocolBugs{ |
| 7334 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7335 | }, |
| 7336 | }, |
| 7337 | shouldFail: true, |
| 7338 | expectedError: ":NO_RENEGOTIATION:", |
| 7339 | }) |
| 7340 | testCases = append(testCases, testCase{ |
| 7341 | name: "Renegotiate-Client-Ignore", |
| 7342 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7343 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 7344 | Bugs: ProtocolBugs{ |
| 7345 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7346 | }, |
| 7347 | }, |
| 7348 | flags: []string{ |
| 7349 | "-renegotiate-ignore", |
| 7350 | "-expect-total-renegotiations", "0", |
| 7351 | }, |
| 7352 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7353 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 7354 | // Renegotiation is not allowed at SSL 3.0. |
| 7355 | testCases = append(testCases, testCase{ |
| 7356 | name: "Renegotiate-Client-SSL3", |
| 7357 | config: Config{ |
| 7358 | MaxVersion: VersionSSL30, |
| 7359 | }, |
| 7360 | renegotiate: 1, |
| 7361 | flags: []string{ |
| 7362 | "-renegotiate-freely", |
| 7363 | "-expect-total-renegotiations", "1", |
| 7364 | }, |
| 7365 | shouldFail: true, |
| 7366 | expectedError: ":NO_RENEGOTIATION:", |
| 7367 | expectedLocalError: "remote error: no renegotiation", |
| 7368 | }) |
| 7369 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7370 | // Renegotiation is not allowed when there is an unfinished write. |
| 7371 | testCases = append(testCases, testCase{ |
| 7372 | name: "Renegotiate-Client-UnfinishedWrite", |
| 7373 | config: Config{ |
| 7374 | MaxVersion: VersionTLS12, |
| 7375 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 7376 | renegotiate: 1, |
| 7377 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7378 | flags: []string{ |
| 7379 | "-async", |
| 7380 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 7381 | }, |
| 7382 | shouldFail: true, |
| 7383 | expectedError: ":NO_RENEGOTIATION:", |
| 7384 | // We do not successfully send the no_renegotiation alert in |
| 7385 | // this case. https://crbug.com/boringssl/130 |
| 7386 | }) |
| 7387 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7388 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7389 | testCases = append(testCases, testCase{ |
| 7390 | name: "StrayHelloRequest", |
| 7391 | config: Config{ |
| 7392 | MaxVersion: VersionTLS12, |
| 7393 | Bugs: ProtocolBugs{ |
| 7394 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7395 | }, |
| 7396 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7397 | shouldFail: true, |
| 7398 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7399 | }) |
| 7400 | testCases = append(testCases, testCase{ |
| 7401 | name: "StrayHelloRequest-Packed", |
| 7402 | config: Config{ |
| 7403 | MaxVersion: VersionTLS12, |
| 7404 | Bugs: ProtocolBugs{ |
| 7405 | PackHandshakeFlight: true, |
| 7406 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7407 | }, |
| 7408 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 7409 | shouldFail: true, |
| 7410 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 7411 | }) |
| 7412 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 7413 | // Test renegotiation works if HelloRequest and server Finished come in |
| 7414 | // the same record. |
| 7415 | testCases = append(testCases, testCase{ |
| 7416 | name: "Renegotiate-Client-Packed", |
| 7417 | config: Config{ |
| 7418 | MaxVersion: VersionTLS12, |
| 7419 | Bugs: ProtocolBugs{ |
| 7420 | PackHandshakeFlight: true, |
| 7421 | PackHelloRequestWithFinished: true, |
| 7422 | }, |
| 7423 | }, |
| 7424 | renegotiate: 1, |
| 7425 | flags: []string{ |
| 7426 | "-renegotiate-freely", |
| 7427 | "-expect-total-renegotiations", "1", |
| 7428 | }, |
| 7429 | }) |
| 7430 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7431 | // Renegotiation is forbidden in TLS 1.3. |
| 7432 | testCases = append(testCases, testCase{ |
| 7433 | name: "Renegotiate-Client-TLS13", |
| 7434 | config: Config{ |
| 7435 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7436 | Bugs: ProtocolBugs{ |
| 7437 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 7438 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7439 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7440 | flags: []string{ |
| 7441 | "-renegotiate-freely", |
| 7442 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 7443 | shouldFail: true, |
| 7444 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 7445 | }) |
| 7446 | |
| 7447 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 7448 | testCases = append(testCases, testCase{ |
| 7449 | name: "StrayHelloRequest-TLS13", |
| 7450 | config: Config{ |
| 7451 | MaxVersion: VersionTLS13, |
| 7452 | Bugs: ProtocolBugs{ |
| 7453 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 7454 | }, |
| 7455 | }, |
| 7456 | shouldFail: true, |
| 7457 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 7458 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 7459 | |
| 7460 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 7461 | // always reads as supporting it, regardless of whether it was |
| 7462 | // negotiated. |
| 7463 | testCases = append(testCases, testCase{ |
| 7464 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 7465 | config: Config{ |
| 7466 | MaxVersion: VersionTLS13, |
| 7467 | Bugs: ProtocolBugs{ |
| 7468 | NoRenegotiationInfo: true, |
| 7469 | }, |
| 7470 | }, |
| 7471 | flags: []string{ |
| 7472 | "-expect-secure-renegotiation", |
| 7473 | }, |
| 7474 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 7475 | |
| 7476 | // Certificates may not change on renegotiation. |
| 7477 | testCases = append(testCases, testCase{ |
| 7478 | name: "Renegotiation-CertificateChange", |
| 7479 | config: Config{ |
| 7480 | MaxVersion: VersionTLS12, |
| 7481 | Certificates: []Certificate{rsaCertificate}, |
| 7482 | Bugs: ProtocolBugs{ |
| 7483 | RenegotiationCertificate: &rsaChainCertificate, |
| 7484 | }, |
| 7485 | }, |
| 7486 | renegotiate: 1, |
| 7487 | flags: []string{"-renegotiate-freely"}, |
| 7488 | shouldFail: true, |
| 7489 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7490 | }) |
| 7491 | testCases = append(testCases, testCase{ |
| 7492 | name: "Renegotiation-CertificateChange-2", |
| 7493 | config: Config{ |
| 7494 | MaxVersion: VersionTLS12, |
| 7495 | Certificates: []Certificate{rsaCertificate}, |
| 7496 | Bugs: ProtocolBugs{ |
| 7497 | RenegotiationCertificate: &rsa1024Certificate, |
| 7498 | }, |
| 7499 | }, |
| 7500 | renegotiate: 1, |
| 7501 | flags: []string{"-renegotiate-freely"}, |
| 7502 | shouldFail: true, |
| 7503 | expectedError: ":SERVER_CERT_CHANGED:", |
| 7504 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 7505 | |
| 7506 | // We do not negotiate ALPN after the initial handshake. This is |
| 7507 | // error-prone and only risks bugs in consumers. |
| 7508 | testCases = append(testCases, testCase{ |
| 7509 | testType: clientTest, |
| 7510 | name: "Renegotiation-ForbidALPN", |
| 7511 | config: Config{ |
| 7512 | MaxVersion: VersionTLS12, |
| 7513 | Bugs: ProtocolBugs{ |
| 7514 | // Forcibly negotiate ALPN on both initial and |
| 7515 | // renegotiation handshakes. The test stack will |
| 7516 | // internally check the client does not offer |
| 7517 | // it. |
| 7518 | SendALPN: "foo", |
| 7519 | }, |
| 7520 | }, |
| 7521 | flags: []string{ |
| 7522 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 7523 | "-expect-alpn", "foo", |
| 7524 | "-renegotiate-freely", |
| 7525 | }, |
| 7526 | renegotiate: 1, |
| 7527 | shouldFail: true, |
| 7528 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 7529 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 7530 | } |
| 7531 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7532 | func addDTLSReplayTests() { |
| 7533 | // Test that sequence number replays are detected. |
| 7534 | testCases = append(testCases, testCase{ |
| 7535 | protocol: dtls, |
| 7536 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7537 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7538 | replayWrites: true, |
| 7539 | }) |
| 7540 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7541 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7542 | // than the retransmit window. |
| 7543 | testCases = append(testCases, testCase{ |
| 7544 | protocol: dtls, |
| 7545 | name: "DTLS-Replay-LargeGaps", |
| 7546 | config: Config{ |
| 7547 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7548 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7549 | return in * 127 |
| 7550 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7551 | }, |
| 7552 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 7553 | messageCount: 200, |
| 7554 | replayWrites: true, |
| 7555 | }) |
| 7556 | |
| 7557 | // Test the incoming sequence number changing non-monotonically. |
| 7558 | testCases = append(testCases, testCase{ |
| 7559 | protocol: dtls, |
| 7560 | name: "DTLS-Replay-NonMonotonic", |
| 7561 | config: Config{ |
| 7562 | Bugs: ProtocolBugs{ |
| 7563 | SequenceNumberMapping: func(in uint64) uint64 { |
| 7564 | return in ^ 31 |
| 7565 | }, |
| 7566 | }, |
| 7567 | }, |
| 7568 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 7569 | replayWrites: true, |
| 7570 | }) |
| 7571 | } |
| 7572 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7573 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7574 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7575 | id signatureAlgorithm |
| 7576 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7577 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7578 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 7579 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 7580 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 7581 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7582 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7583 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 7584 | // hash function doesn't have to match the curve and so the same |
| 7585 | // signature algorithm works with P-224. |
| 7586 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7587 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 7588 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 7589 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7590 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 7591 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 7592 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7593 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7594 | // Tests for key types prior to TLS 1.2. |
| 7595 | {"RSA", 0, testCertRSA}, |
| 7596 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7597 | } |
| 7598 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7599 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 7600 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 7601 | |
| 7602 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7603 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 7604 | // versions a signing cipher. |
| 7605 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7606 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7607 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 7608 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 7609 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 7610 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7611 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7612 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7613 | var allAlgorithms []signatureAlgorithm |
| 7614 | for _, alg := range testSignatureAlgorithms { |
| 7615 | if alg.id != 0 { |
| 7616 | allAlgorithms = append(allAlgorithms, alg.id) |
| 7617 | } |
| 7618 | } |
| 7619 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7620 | // Make sure each signature algorithm works. Include some fake values in |
| 7621 | // the list and ensure they're ignored. |
| 7622 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7623 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7624 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 7625 | continue |
| 7626 | } |
| 7627 | |
| 7628 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 7629 | // or remove it in C. |
| 7630 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7631 | continue |
| 7632 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7633 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7634 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7635 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7636 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7637 | shouldSignFail = true |
| 7638 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7639 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7640 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 7641 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 7642 | shouldSignFail = true |
| 7643 | shouldVerifyFail = true |
| 7644 | } |
| 7645 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 7646 | // the curve has to match the hash size. |
| 7647 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7648 | shouldSignFail = true |
| 7649 | shouldVerifyFail = true |
| 7650 | } |
| 7651 | |
| 7652 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 7653 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 7654 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 7655 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7656 | |
| 7657 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7658 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7659 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7660 | } |
| 7661 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7662 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7663 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7664 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7665 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 7666 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7667 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7668 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7669 | config: Config{ |
| 7670 | MaxVersion: ver.version, |
| 7671 | ClientAuth: RequireAnyClientCert, |
| 7672 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7673 | fakeSigAlg1, |
| 7674 | alg.id, |
| 7675 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7676 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7677 | }, |
| 7678 | flags: []string{ |
| 7679 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7680 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7681 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7682 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7683 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7684 | tls13Variant: ver.tls13Variant, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7685 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7686 | expectedError: signError, |
| 7687 | expectedPeerSignatureAlgorithm: alg.id, |
| 7688 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7689 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7690 | testCases = append(testCases, testCase{ |
| 7691 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7692 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7693 | config: Config{ |
| 7694 | MaxVersion: ver.version, |
| 7695 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7696 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7697 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7698 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7699 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7700 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7701 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7702 | // Some signature algorithms may not be advertised. |
| 7703 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7704 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7705 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7706 | tls13Variant: ver.tls13Variant, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7707 | flags: []string{ |
| 7708 | "-require-any-client-certificate", |
| 7709 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7710 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7711 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7712 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7713 | // Resume the session to assert the peer signature |
| 7714 | // algorithm is reported on both handshakes. |
| 7715 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7716 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7717 | expectedError: verifyError, |
| 7718 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7719 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7720 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7721 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7722 | testCases = append(testCases, testCase{ |
| 7723 | testType: serverTest, |
| 7724 | name: "ServerAuth-Sign" + suffix, |
| 7725 | config: Config{ |
| 7726 | MaxVersion: ver.version, |
| 7727 | CipherSuites: signingCiphers, |
| 7728 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7729 | fakeSigAlg1, |
| 7730 | alg.id, |
| 7731 | fakeSigAlg2, |
| 7732 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7733 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7734 | tls13Variant: ver.tls13Variant, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7735 | flags: []string{ |
| 7736 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7737 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7738 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7739 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7740 | }, |
| 7741 | shouldFail: shouldSignFail, |
| 7742 | expectedError: signError, |
| 7743 | expectedPeerSignatureAlgorithm: alg.id, |
| 7744 | }) |
| 7745 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7746 | |
| 7747 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7748 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7749 | config: Config{ |
| 7750 | MaxVersion: ver.version, |
| 7751 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7752 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7753 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7754 | alg.id, |
| 7755 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7756 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7757 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7758 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7759 | // Some signature algorithms may not be advertised. |
| 7760 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7761 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7762 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7763 | tls13Variant: ver.tls13Variant, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7764 | flags: []string{ |
| 7765 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7766 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7767 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7768 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7769 | // Resume the session to assert the peer signature |
| 7770 | // algorithm is reported on both handshakes. |
| 7771 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7772 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7773 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7774 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7775 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7776 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7777 | testCases = append(testCases, testCase{ |
| 7778 | testType: serverTest, |
| 7779 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7780 | config: Config{ |
| 7781 | MaxVersion: ver.version, |
| 7782 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7783 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7784 | alg.id, |
| 7785 | }, |
| 7786 | Bugs: ProtocolBugs{ |
| 7787 | InvalidSignature: true, |
| 7788 | }, |
| 7789 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7790 | tls13Variant: ver.tls13Variant, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7791 | flags: []string{ |
| 7792 | "-require-any-client-certificate", |
| 7793 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7794 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7795 | }, |
| 7796 | shouldFail: true, |
| 7797 | expectedError: ":BAD_SIGNATURE:", |
| 7798 | }) |
| 7799 | |
| 7800 | testCases = append(testCases, testCase{ |
| 7801 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7802 | config: Config{ |
| 7803 | MaxVersion: ver.version, |
| 7804 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7805 | CipherSuites: signingCiphers, |
| 7806 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7807 | alg.id, |
| 7808 | }, |
| 7809 | Bugs: ProtocolBugs{ |
| 7810 | InvalidSignature: true, |
| 7811 | }, |
| 7812 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7813 | tls13Variant: ver.tls13Variant, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7814 | flags: []string{ |
| 7815 | "-enable-all-curves", |
| 7816 | "-enable-ed25519", |
| 7817 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7818 | shouldFail: true, |
| 7819 | expectedError: ":BAD_SIGNATURE:", |
| 7820 | }) |
| 7821 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7822 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7823 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7824 | testCases = append(testCases, testCase{ |
| 7825 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7826 | config: Config{ |
| 7827 | MaxVersion: ver.version, |
| 7828 | ClientAuth: RequireAnyClientCert, |
| 7829 | VerifySignatureAlgorithms: allAlgorithms, |
| 7830 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7831 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7832 | flags: []string{ |
| 7833 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7834 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7835 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7836 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7837 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7838 | }, |
| 7839 | expectedPeerSignatureAlgorithm: alg.id, |
| 7840 | }) |
| 7841 | |
| 7842 | testCases = append(testCases, testCase{ |
| 7843 | testType: serverTest, |
| 7844 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7845 | config: Config{ |
| 7846 | MaxVersion: ver.version, |
| 7847 | CipherSuites: signingCiphers, |
| 7848 | VerifySignatureAlgorithms: allAlgorithms, |
| 7849 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 7850 | tls13Variant: ver.tls13Variant, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7851 | flags: []string{ |
| 7852 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7853 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7854 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7855 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7856 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7857 | }, |
| 7858 | expectedPeerSignatureAlgorithm: alg.id, |
| 7859 | }) |
| 7860 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7861 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7862 | } |
| 7863 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7864 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7865 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7866 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7867 | config: Config{ |
| 7868 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7869 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7870 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7871 | signatureECDSAWithP521AndSHA512, |
| 7872 | signatureRSAPKCS1WithSHA384, |
| 7873 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7874 | }, |
| 7875 | }, |
| 7876 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7877 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7878 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7879 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7880 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7881 | }) |
| 7882 | |
| 7883 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7884 | name: "ClientAuth-SignatureType-TLS13", |
| 7885 | config: Config{ |
| 7886 | ClientAuth: RequireAnyClientCert, |
| 7887 | MaxVersion: VersionTLS13, |
| 7888 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7889 | signatureECDSAWithP521AndSHA512, |
| 7890 | signatureRSAPKCS1WithSHA384, |
| 7891 | signatureRSAPSSWithSHA384, |
| 7892 | signatureECDSAWithSHA1, |
| 7893 | }, |
| 7894 | }, |
| 7895 | flags: []string{ |
| 7896 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7897 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7898 | }, |
| 7899 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7900 | }) |
| 7901 | |
| 7902 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7903 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7904 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7905 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7906 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7907 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7908 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7909 | signatureECDSAWithP521AndSHA512, |
| 7910 | signatureRSAPKCS1WithSHA384, |
| 7911 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7912 | }, |
| 7913 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7914 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7915 | }) |
| 7916 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7917 | testCases = append(testCases, testCase{ |
| 7918 | testType: serverTest, |
| 7919 | name: "ServerAuth-SignatureType-TLS13", |
| 7920 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7921 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7922 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7923 | signatureECDSAWithP521AndSHA512, |
| 7924 | signatureRSAPKCS1WithSHA384, |
| 7925 | signatureRSAPSSWithSHA384, |
| 7926 | signatureECDSAWithSHA1, |
| 7927 | }, |
| 7928 | }, |
| 7929 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7930 | }) |
| 7931 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7932 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7933 | testCases = append(testCases, testCase{ |
| 7934 | testType: serverTest, |
| 7935 | name: "Verify-ClientAuth-SignatureType", |
| 7936 | config: Config{ |
| 7937 | MaxVersion: VersionTLS12, |
| 7938 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7939 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7940 | signatureRSAPKCS1WithSHA256, |
| 7941 | }, |
| 7942 | Bugs: ProtocolBugs{ |
| 7943 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7944 | }, |
| 7945 | }, |
| 7946 | flags: []string{ |
| 7947 | "-require-any-client-certificate", |
| 7948 | }, |
| 7949 | shouldFail: true, |
| 7950 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7951 | }) |
| 7952 | |
| 7953 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7954 | testType: serverTest, |
| 7955 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7956 | config: Config{ |
| 7957 | MaxVersion: VersionTLS13, |
| 7958 | Certificates: []Certificate{rsaCertificate}, |
| 7959 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7960 | signatureRSAPSSWithSHA256, |
| 7961 | }, |
| 7962 | Bugs: ProtocolBugs{ |
| 7963 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7964 | }, |
| 7965 | }, |
| 7966 | flags: []string{ |
| 7967 | "-require-any-client-certificate", |
| 7968 | }, |
| 7969 | shouldFail: true, |
| 7970 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7971 | }) |
| 7972 | |
| 7973 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7974 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7975 | config: Config{ |
| 7976 | MaxVersion: VersionTLS12, |
| 7977 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7978 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7979 | signatureRSAPKCS1WithSHA256, |
| 7980 | }, |
| 7981 | Bugs: ProtocolBugs{ |
| 7982 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7983 | }, |
| 7984 | }, |
| 7985 | shouldFail: true, |
| 7986 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7987 | }) |
| 7988 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7989 | testCases = append(testCases, testCase{ |
| 7990 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7991 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7992 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7993 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7994 | signatureRSAPSSWithSHA256, |
| 7995 | }, |
| 7996 | Bugs: ProtocolBugs{ |
| 7997 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7998 | }, |
| 7999 | }, |
| 8000 | shouldFail: true, |
| 8001 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8002 | }) |
| 8003 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8004 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 8005 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8006 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8007 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8008 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8009 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8010 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8011 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8012 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8013 | }, |
| 8014 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8015 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8016 | }, |
| 8017 | }, |
| 8018 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 8019 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8020 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8021 | }, |
| 8022 | }) |
| 8023 | |
| 8024 | testCases = append(testCases, testCase{ |
| 8025 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8026 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8027 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8028 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8029 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8030 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8031 | }, |
| 8032 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8033 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8034 | }, |
| 8035 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 8036 | flags: []string{ |
| 8037 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8038 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8039 | }, |
| 8040 | }) |
| 8041 | |
| 8042 | testCases = append(testCases, testCase{ |
| 8043 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 8044 | config: Config{ |
| 8045 | MaxVersion: VersionTLS12, |
| 8046 | ClientAuth: RequireAnyClientCert, |
| 8047 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8048 | signatureECDSAWithSHA1, |
| 8049 | }, |
| 8050 | Bugs: ProtocolBugs{ |
| 8051 | NoSignatureAlgorithms: true, |
| 8052 | }, |
| 8053 | }, |
| 8054 | flags: []string{ |
| 8055 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8056 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8057 | }, |
| 8058 | }) |
| 8059 | |
| 8060 | testCases = append(testCases, testCase{ |
| 8061 | testType: serverTest, |
| 8062 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 8063 | config: Config{ |
| 8064 | MaxVersion: VersionTLS12, |
| 8065 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8066 | signatureECDSAWithSHA1, |
| 8067 | }, |
| 8068 | Bugs: ProtocolBugs{ |
| 8069 | NoSignatureAlgorithms: true, |
| 8070 | }, |
| 8071 | }, |
| 8072 | flags: []string{ |
| 8073 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8074 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8075 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8076 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8077 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8078 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8079 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8080 | config: Config{ |
| 8081 | MaxVersion: VersionTLS13, |
| 8082 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8083 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8084 | signatureRSAPKCS1WithSHA1, |
| 8085 | }, |
| 8086 | Bugs: ProtocolBugs{ |
| 8087 | NoSignatureAlgorithms: true, |
| 8088 | }, |
| 8089 | }, |
| 8090 | flags: []string{ |
| 8091 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8092 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8093 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 8094 | shouldFail: true, |
| 8095 | // An empty CertificateRequest signature algorithm list is a |
| 8096 | // syntax error in TLS 1.3. |
| 8097 | expectedError: ":DECODE_ERROR:", |
| 8098 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8099 | }) |
| 8100 | |
| 8101 | testCases = append(testCases, testCase{ |
| 8102 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8103 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8104 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8105 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8106 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 8107 | signatureRSAPKCS1WithSHA1, |
| 8108 | }, |
| 8109 | Bugs: ProtocolBugs{ |
| 8110 | NoSignatureAlgorithms: true, |
| 8111 | }, |
| 8112 | }, |
| 8113 | shouldFail: true, |
| 8114 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8115 | }) |
| 8116 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8117 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 8118 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8119 | testCases = append(testCases, testCase{ |
| 8120 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8121 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8122 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8123 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8124 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8125 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8126 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8127 | }, |
| 8128 | Bugs: ProtocolBugs{ |
| 8129 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8130 | }, |
| 8131 | }, |
| 8132 | flags: []string{"-require-any-client-certificate"}, |
| 8133 | shouldFail: true, |
| 8134 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8135 | }) |
| 8136 | |
| 8137 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 8138 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8139 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8140 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8141 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8142 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8143 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 8144 | }, |
| 8145 | Bugs: ProtocolBugs{ |
| 8146 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8147 | }, |
| 8148 | }, |
| 8149 | shouldFail: true, |
| 8150 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8151 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8152 | testCases = append(testCases, testCase{ |
| 8153 | testType: serverTest, |
| 8154 | name: "ClientAuth-Enforced-TLS13", |
| 8155 | config: Config{ |
| 8156 | MaxVersion: VersionTLS13, |
| 8157 | Certificates: []Certificate{rsaCertificate}, |
| 8158 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8159 | signatureRSAPKCS1WithMD5, |
| 8160 | }, |
| 8161 | Bugs: ProtocolBugs{ |
| 8162 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8163 | IgnoreSignatureVersionChecks: true, |
| 8164 | }, |
| 8165 | }, |
| 8166 | flags: []string{"-require-any-client-certificate"}, |
| 8167 | shouldFail: true, |
| 8168 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8169 | }) |
| 8170 | |
| 8171 | testCases = append(testCases, testCase{ |
| 8172 | name: "ServerAuth-Enforced-TLS13", |
| 8173 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8174 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 8175 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8176 | signatureRSAPKCS1WithMD5, |
| 8177 | }, |
| 8178 | Bugs: ProtocolBugs{ |
| 8179 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8180 | IgnoreSignatureVersionChecks: true, |
| 8181 | }, |
| 8182 | }, |
| 8183 | shouldFail: true, |
| 8184 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8185 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8186 | |
| 8187 | // Test that the agreed upon digest respects the client preferences and |
| 8188 | // the server digests. |
| 8189 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8190 | name: "NoCommonAlgorithms-Digests", |
| 8191 | config: Config{ |
| 8192 | MaxVersion: VersionTLS12, |
| 8193 | ClientAuth: RequireAnyClientCert, |
| 8194 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8195 | signatureRSAPKCS1WithSHA512, |
| 8196 | signatureRSAPKCS1WithSHA1, |
| 8197 | }, |
| 8198 | }, |
| 8199 | flags: []string{ |
| 8200 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8201 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8202 | "-digest-prefs", "SHA256", |
| 8203 | }, |
| 8204 | shouldFail: true, |
| 8205 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8206 | }) |
| 8207 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8208 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8209 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8210 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8211 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8212 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8213 | signatureRSAPKCS1WithSHA512, |
| 8214 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8215 | }, |
| 8216 | }, |
| 8217 | flags: []string{ |
| 8218 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8219 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8220 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8221 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8222 | shouldFail: true, |
| 8223 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8224 | }) |
| 8225 | testCases = append(testCases, testCase{ |
| 8226 | name: "NoCommonAlgorithms-TLS13", |
| 8227 | config: Config{ |
| 8228 | MaxVersion: VersionTLS13, |
| 8229 | ClientAuth: RequireAnyClientCert, |
| 8230 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8231 | signatureRSAPSSWithSHA512, |
| 8232 | signatureRSAPSSWithSHA384, |
| 8233 | }, |
| 8234 | }, |
| 8235 | flags: []string{ |
| 8236 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8237 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8238 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 8239 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 8240 | shouldFail: true, |
| 8241 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8242 | }) |
| 8243 | testCases = append(testCases, testCase{ |
| 8244 | name: "Agree-Digest-SHA256", |
| 8245 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8246 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8247 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8248 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8249 | signatureRSAPKCS1WithSHA1, |
| 8250 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8251 | }, |
| 8252 | }, |
| 8253 | flags: []string{ |
| 8254 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8255 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8256 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8257 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8258 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8259 | }) |
| 8260 | testCases = append(testCases, testCase{ |
| 8261 | name: "Agree-Digest-SHA1", |
| 8262 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8263 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8264 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8265 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8266 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8267 | }, |
| 8268 | }, |
| 8269 | flags: []string{ |
| 8270 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8271 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8272 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8273 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8274 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8275 | }) |
| 8276 | testCases = append(testCases, testCase{ |
| 8277 | name: "Agree-Digest-Default", |
| 8278 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8279 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8280 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8281 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8282 | signatureRSAPKCS1WithSHA256, |
| 8283 | signatureECDSAWithP256AndSHA256, |
| 8284 | signatureRSAPKCS1WithSHA1, |
| 8285 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8286 | }, |
| 8287 | }, |
| 8288 | flags: []string{ |
| 8289 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8290 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8291 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 8292 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 8293 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8294 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 8295 | // Test that the signing preference list may include extra algorithms |
| 8296 | // without negotiation problems. |
| 8297 | testCases = append(testCases, testCase{ |
| 8298 | testType: serverTest, |
| 8299 | name: "FilterExtraAlgorithms", |
| 8300 | config: Config{ |
| 8301 | MaxVersion: VersionTLS12, |
| 8302 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8303 | signatureRSAPKCS1WithSHA256, |
| 8304 | }, |
| 8305 | }, |
| 8306 | flags: []string{ |
| 8307 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 8308 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 8309 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 8310 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 8311 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 8312 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 8313 | }, |
| 8314 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 8315 | }) |
| 8316 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8317 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 8318 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8319 | testCases = append(testCases, testCase{ |
| 8320 | name: "CheckLeafCurve", |
| 8321 | config: Config{ |
| 8322 | MaxVersion: VersionTLS12, |
| 8323 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 8324 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8325 | }, |
| 8326 | flags: []string{"-p384-only"}, |
| 8327 | shouldFail: true, |
| 8328 | expectedError: ":BAD_ECC_CERT:", |
| 8329 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8330 | |
| 8331 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 8332 | testCases = append(testCases, testCase{ |
| 8333 | name: "CheckLeafCurve-TLS13", |
| 8334 | config: Config{ |
| 8335 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 8336 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 8337 | }, |
| 8338 | flags: []string{"-p384-only"}, |
| 8339 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8340 | |
| 8341 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 8342 | testCases = append(testCases, testCase{ |
| 8343 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 8344 | config: Config{ |
| 8345 | MaxVersion: VersionTLS12, |
| 8346 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 8347 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8348 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8349 | signatureECDSAWithP384AndSHA384, |
| 8350 | }, |
| 8351 | }, |
| 8352 | }) |
| 8353 | |
| 8354 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 8355 | testCases = append(testCases, testCase{ |
| 8356 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 8357 | config: Config{ |
| 8358 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8359 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8360 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8361 | signatureECDSAWithP384AndSHA384, |
| 8362 | }, |
| 8363 | Bugs: ProtocolBugs{ |
| 8364 | SkipECDSACurveCheck: true, |
| 8365 | }, |
| 8366 | }, |
| 8367 | shouldFail: true, |
| 8368 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8369 | }) |
| 8370 | |
| 8371 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 8372 | // account. |
| 8373 | testCases = append(testCases, testCase{ |
| 8374 | testType: serverTest, |
| 8375 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 8376 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8377 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 8378 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 8379 | signatureECDSAWithP384AndSHA384, |
| 8380 | signatureECDSAWithP256AndSHA256, |
| 8381 | }, |
| 8382 | }, |
| 8383 | flags: []string{ |
| 8384 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 8385 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 8386 | }, |
| 8387 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 8388 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 8389 | |
| 8390 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 8391 | // server does not attempt to sign in that case. |
| 8392 | testCases = append(testCases, testCase{ |
| 8393 | testType: serverTest, |
| 8394 | name: "RSA-PSS-Large", |
| 8395 | config: Config{ |
| 8396 | MaxVersion: VersionTLS13, |
| 8397 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8398 | signatureRSAPSSWithSHA512, |
| 8399 | }, |
| 8400 | }, |
| 8401 | flags: []string{ |
| 8402 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 8403 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 8404 | }, |
| 8405 | shouldFail: true, |
| 8406 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8407 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 8408 | |
| 8409 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 8410 | testCases = append(testCases, testCase{ |
| 8411 | testType: clientTest, |
| 8412 | name: "RSA-PSS-Default-Verify", |
| 8413 | config: Config{ |
| 8414 | MaxVersion: VersionTLS12, |
| 8415 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8416 | signatureRSAPSSWithSHA256, |
| 8417 | }, |
| 8418 | }, |
| 8419 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8420 | }) |
| 8421 | |
| 8422 | testCases = append(testCases, testCase{ |
| 8423 | testType: serverTest, |
| 8424 | name: "RSA-PSS-Default-Sign", |
| 8425 | config: Config{ |
| 8426 | MaxVersion: VersionTLS12, |
| 8427 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 8428 | signatureRSAPSSWithSHA256, |
| 8429 | }, |
| 8430 | }, |
| 8431 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8432 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 8433 | |
| 8434 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 8435 | // Ed25519's signature algorithm. |
| 8436 | testCases = append(testCases, testCase{ |
| 8437 | testType: clientTest, |
| 8438 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 8439 | config: Config{ |
| 8440 | MaxVersion: VersionTLS11, |
| 8441 | Certificates: []Certificate{ed25519Certificate}, |
| 8442 | Bugs: ProtocolBugs{ |
| 8443 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8444 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8445 | }, |
| 8446 | }, |
| 8447 | flags: []string{"-enable-ed25519"}, |
| 8448 | shouldFail: true, |
| 8449 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8450 | }) |
| 8451 | testCases = append(testCases, testCase{ |
| 8452 | testType: serverTest, |
| 8453 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 8454 | config: Config{ |
| 8455 | MaxVersion: VersionTLS11, |
| 8456 | }, |
| 8457 | flags: []string{ |
| 8458 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8459 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8460 | }, |
| 8461 | shouldFail: true, |
| 8462 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8463 | }) |
| 8464 | testCases = append(testCases, testCase{ |
| 8465 | testType: serverTest, |
| 8466 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 8467 | config: Config{ |
| 8468 | MaxVersion: VersionTLS11, |
| 8469 | Certificates: []Certificate{ed25519Certificate}, |
| 8470 | Bugs: ProtocolBugs{ |
| 8471 | // Sign with Ed25519 even though it is TLS 1.1. |
| 8472 | UseLegacySigningAlgorithm: signatureEd25519, |
| 8473 | }, |
| 8474 | }, |
| 8475 | flags: []string{ |
| 8476 | "-enable-ed25519", |
| 8477 | "-require-any-client-certificate", |
| 8478 | }, |
| 8479 | shouldFail: true, |
| 8480 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 8481 | }) |
| 8482 | testCases = append(testCases, testCase{ |
| 8483 | testType: clientTest, |
| 8484 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 8485 | config: Config{ |
| 8486 | MaxVersion: VersionTLS11, |
| 8487 | ClientAuth: RequireAnyClientCert, |
| 8488 | }, |
| 8489 | flags: []string{ |
| 8490 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 8491 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 8492 | }, |
| 8493 | shouldFail: true, |
| 8494 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 8495 | }) |
| 8496 | |
| 8497 | // Test Ed25519 is not advertised by default. |
| 8498 | testCases = append(testCases, testCase{ |
| 8499 | testType: clientTest, |
| 8500 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 8501 | config: Config{ |
| 8502 | Certificates: []Certificate{ed25519Certificate}, |
| 8503 | }, |
| 8504 | shouldFail: true, |
| 8505 | expectedLocalError: "tls: no common signature algorithms", |
| 8506 | }) |
| 8507 | |
| 8508 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 8509 | // preferences. |
| 8510 | testCases = append(testCases, testCase{ |
| 8511 | testType: clientTest, |
| 8512 | name: "Ed25519DefaultDisable-NoAccept", |
| 8513 | config: Config{ |
| 8514 | Certificates: []Certificate{ed25519Certificate}, |
| 8515 | Bugs: ProtocolBugs{ |
| 8516 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8517 | }, |
| 8518 | }, |
| 8519 | shouldFail: true, |
| 8520 | expectedLocalError: "remote error: illegal parameter", |
| 8521 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8522 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 8523 | |
| 8524 | // Test that configuring verify preferences changes what the client |
| 8525 | // advertises. |
| 8526 | testCases = append(testCases, testCase{ |
| 8527 | name: "VerifyPreferences-Advertised", |
| 8528 | config: Config{ |
| 8529 | Certificates: []Certificate{rsaCertificate}, |
| 8530 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8531 | signatureRSAPSSWithSHA256, |
| 8532 | signatureRSAPSSWithSHA384, |
| 8533 | signatureRSAPSSWithSHA512, |
| 8534 | }, |
| 8535 | }, |
| 8536 | flags: []string{ |
| 8537 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8538 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8539 | }, |
| 8540 | }) |
| 8541 | |
| 8542 | // Test that the client advertises a set which the runner can find |
| 8543 | // nothing in common with. |
| 8544 | testCases = append(testCases, testCase{ |
| 8545 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 8546 | config: Config{ |
| 8547 | Certificates: []Certificate{rsaCertificate}, |
| 8548 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8549 | signatureRSAPSSWithSHA256, |
| 8550 | signatureRSAPSSWithSHA512, |
| 8551 | }, |
| 8552 | }, |
| 8553 | flags: []string{ |
| 8554 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8555 | }, |
| 8556 | shouldFail: true, |
| 8557 | expectedLocalError: "tls: no common signature algorithms", |
| 8558 | }) |
| 8559 | |
| 8560 | // Test that the client enforces its preferences when configured. |
| 8561 | testCases = append(testCases, testCase{ |
| 8562 | name: "VerifyPreferences-Enforced", |
| 8563 | config: Config{ |
| 8564 | Certificates: []Certificate{rsaCertificate}, |
| 8565 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 8566 | signatureRSAPSSWithSHA256, |
| 8567 | signatureRSAPSSWithSHA512, |
| 8568 | }, |
| 8569 | Bugs: ProtocolBugs{ |
| 8570 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 8571 | }, |
| 8572 | }, |
| 8573 | flags: []string{ |
| 8574 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 8575 | }, |
| 8576 | shouldFail: true, |
| 8577 | expectedLocalError: "remote error: illegal parameter", |
| 8578 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 8579 | }) |
| 8580 | |
| 8581 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 8582 | // boolean toggle. |
| 8583 | testCases = append(testCases, testCase{ |
| 8584 | name: "VerifyPreferences-Ed25519", |
| 8585 | config: Config{ |
| 8586 | Certificates: []Certificate{ed25519Certificate}, |
| 8587 | }, |
| 8588 | flags: []string{ |
| 8589 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 8590 | }, |
| 8591 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 8592 | } |
| 8593 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8594 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 8595 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 8596 | var timeouts = []time.Duration{ |
| 8597 | 1 * time.Second, |
| 8598 | 2 * time.Second, |
| 8599 | 4 * time.Second, |
| 8600 | 8 * time.Second, |
| 8601 | 16 * time.Second, |
| 8602 | 32 * time.Second, |
| 8603 | 60 * time.Second, |
| 8604 | 60 * time.Second, |
| 8605 | 60 * time.Second, |
| 8606 | 60 * time.Second, |
| 8607 | 60 * time.Second, |
| 8608 | 60 * time.Second, |
| 8609 | 60 * time.Second, |
| 8610 | } |
| 8611 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 8612 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 8613 | // initial timeout duration was set to 250ms. |
| 8614 | var shortTimeouts = []time.Duration{ |
| 8615 | 250 * time.Millisecond, |
| 8616 | 500 * time.Millisecond, |
| 8617 | 1 * time.Second, |
| 8618 | 2 * time.Second, |
| 8619 | 4 * time.Second, |
| 8620 | 8 * time.Second, |
| 8621 | 16 * time.Second, |
| 8622 | 32 * time.Second, |
| 8623 | 60 * time.Second, |
| 8624 | 60 * time.Second, |
| 8625 | 60 * time.Second, |
| 8626 | 60 * time.Second, |
| 8627 | 60 * time.Second, |
| 8628 | } |
| 8629 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8630 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 8631 | // These tests work by coordinating some behavior on both the shim and |
| 8632 | // the runner. |
| 8633 | // |
| 8634 | // TimeoutSchedule configures the runner to send a series of timeout |
| 8635 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 8636 | // each peer handshake flight N. The timeout opcode both simulates a |
| 8637 | // timeout in the shim and acts as a synchronization point to help the |
| 8638 | // runner bracket each handshake flight. |
| 8639 | // |
| 8640 | // We assume the shim does not read from the channel eagerly. It must |
| 8641 | // first wait until it has sent flight N and is ready to receive |
| 8642 | // handshake flight N+1. At this point, it will process the timeout |
| 8643 | // opcode. It must then immediately respond with a timeout ACK and act |
| 8644 | // as if the shim was idle for the specified amount of time. |
| 8645 | // |
| 8646 | // The runner then drops all packets received before the ACK and |
| 8647 | // continues waiting for flight N. This ordering results in one attempt |
| 8648 | // at sending flight N to be dropped. For the test to complete, the |
| 8649 | // shim must send flight N again, testing that the shim implements DTLS |
| 8650 | // retransmit on a timeout. |
| 8651 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8652 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8653 | // likely be more epochs to cross and the final message's retransmit may |
| 8654 | // be more complex. |
| 8655 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8656 | // Test that this is indeed the timeout schedule. Stress all |
| 8657 | // four patterns of handshake. |
| 8658 | for i := 1; i < len(timeouts); i++ { |
| 8659 | number := strconv.Itoa(i) |
| 8660 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8661 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8662 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8663 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8664 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8665 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8666 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8667 | }, |
| 8668 | }, |
| 8669 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8670 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8671 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8672 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8673 | protocol: dtls, |
| 8674 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8675 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8676 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8677 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8678 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8679 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8680 | }, |
| 8681 | }, |
| 8682 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8683 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8684 | }) |
| 8685 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8686 | |
| 8687 | // Test that exceeding the timeout schedule hits a read |
| 8688 | // timeout. |
| 8689 | testCases = append(testCases, testCase{ |
| 8690 | protocol: dtls, |
| 8691 | name: "DTLS-Retransmit-Timeout", |
| 8692 | config: Config{ |
| 8693 | MaxVersion: VersionTLS12, |
| 8694 | Bugs: ProtocolBugs{ |
| 8695 | TimeoutSchedule: timeouts, |
| 8696 | }, |
| 8697 | }, |
| 8698 | resumeSession: true, |
| 8699 | flags: []string{"-async"}, |
| 8700 | shouldFail: true, |
| 8701 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8702 | }) |
| 8703 | |
| 8704 | // Test that timeout handling has a fudge factor, due to API |
| 8705 | // problems. |
| 8706 | testCases = append(testCases, testCase{ |
| 8707 | protocol: dtls, |
| 8708 | name: "DTLS-Retransmit-Fudge", |
| 8709 | config: Config{ |
| 8710 | MaxVersion: VersionTLS12, |
| 8711 | Bugs: ProtocolBugs{ |
| 8712 | TimeoutSchedule: []time.Duration{ |
| 8713 | timeouts[0] - 10*time.Millisecond, |
| 8714 | }, |
| 8715 | }, |
| 8716 | }, |
| 8717 | resumeSession: true, |
| 8718 | flags: []string{"-async"}, |
| 8719 | }) |
| 8720 | |
| 8721 | // Test that the final Finished retransmitting isn't |
| 8722 | // duplicated if the peer badly fragments everything. |
| 8723 | testCases = append(testCases, testCase{ |
| 8724 | testType: serverTest, |
| 8725 | protocol: dtls, |
| 8726 | name: "DTLS-Retransmit-Fragmented", |
| 8727 | config: Config{ |
| 8728 | MaxVersion: VersionTLS12, |
| 8729 | Bugs: ProtocolBugs{ |
| 8730 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8731 | MaxHandshakeRecordLength: 2, |
| 8732 | }, |
| 8733 | }, |
| 8734 | flags: []string{"-async"}, |
| 8735 | }) |
| 8736 | |
| 8737 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8738 | testCases = append(testCases, testCase{ |
| 8739 | protocol: dtls, |
| 8740 | name: "DTLS-Retransmit-Short-Client", |
| 8741 | config: Config{ |
| 8742 | MaxVersion: VersionTLS12, |
| 8743 | Bugs: ProtocolBugs{ |
| 8744 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8745 | }, |
| 8746 | }, |
| 8747 | resumeSession: true, |
| 8748 | flags: []string{ |
| 8749 | "-async", |
| 8750 | "-initial-timeout-duration-ms", "250", |
| 8751 | }, |
| 8752 | }) |
| 8753 | testCases = append(testCases, testCase{ |
| 8754 | protocol: dtls, |
| 8755 | testType: serverTest, |
| 8756 | name: "DTLS-Retransmit-Short-Server", |
| 8757 | config: Config{ |
| 8758 | MaxVersion: VersionTLS12, |
| 8759 | Bugs: ProtocolBugs{ |
| 8760 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8761 | }, |
| 8762 | }, |
| 8763 | resumeSession: true, |
| 8764 | flags: []string{ |
| 8765 | "-async", |
| 8766 | "-initial-timeout-duration-ms", "250", |
| 8767 | }, |
| 8768 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8769 | } |
| 8770 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8771 | func addExportKeyingMaterialTests() { |
| 8772 | for _, vers := range tlsVersions { |
| 8773 | if vers.version == VersionSSL30 { |
| 8774 | continue |
| 8775 | } |
| 8776 | testCases = append(testCases, testCase{ |
| 8777 | name: "ExportKeyingMaterial-" + vers.name, |
| 8778 | config: Config{ |
| 8779 | MaxVersion: vers.version, |
| 8780 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8781 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8782 | exportKeyingMaterial: 1024, |
| 8783 | exportLabel: "label", |
| 8784 | exportContext: "context", |
| 8785 | useExportContext: true, |
| 8786 | }) |
| 8787 | testCases = append(testCases, testCase{ |
| 8788 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8789 | config: Config{ |
| 8790 | MaxVersion: vers.version, |
| 8791 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8792 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8793 | exportKeyingMaterial: 1024, |
| 8794 | }) |
| 8795 | testCases = append(testCases, testCase{ |
| 8796 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8797 | config: Config{ |
| 8798 | MaxVersion: vers.version, |
| 8799 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8800 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8801 | exportKeyingMaterial: 1024, |
| 8802 | useExportContext: true, |
| 8803 | }) |
| 8804 | testCases = append(testCases, testCase{ |
| 8805 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8806 | config: Config{ |
| 8807 | MaxVersion: vers.version, |
| 8808 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 8809 | tls13Variant: vers.tls13Variant, |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8810 | exportKeyingMaterial: 1, |
| 8811 | exportLabel: "label", |
| 8812 | exportContext: "context", |
| 8813 | useExportContext: true, |
| 8814 | }) |
| 8815 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8816 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8817 | testCases = append(testCases, testCase{ |
| 8818 | name: "ExportKeyingMaterial-SSL3", |
| 8819 | config: Config{ |
| 8820 | MaxVersion: VersionSSL30, |
| 8821 | }, |
| 8822 | exportKeyingMaterial: 1024, |
| 8823 | exportLabel: "label", |
| 8824 | exportContext: "context", |
| 8825 | useExportContext: true, |
| 8826 | shouldFail: true, |
| 8827 | expectedError: "failed to export keying material", |
| 8828 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8829 | |
| 8830 | // Exporters work during a False Start. |
| 8831 | testCases = append(testCases, testCase{ |
| 8832 | name: "ExportKeyingMaterial-FalseStart", |
| 8833 | config: Config{ |
| 8834 | MaxVersion: VersionTLS12, |
| 8835 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8836 | NextProtos: []string{"foo"}, |
| 8837 | Bugs: ProtocolBugs{ |
| 8838 | ExpectFalseStart: true, |
| 8839 | }, |
| 8840 | }, |
| 8841 | flags: []string{ |
| 8842 | "-false-start", |
| 8843 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8844 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8845 | }, |
| 8846 | shimWritesFirst: true, |
| 8847 | exportKeyingMaterial: 1024, |
| 8848 | exportLabel: "label", |
| 8849 | exportContext: "context", |
| 8850 | useExportContext: true, |
| 8851 | }) |
| 8852 | |
| 8853 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8854 | // triggering the exporter after every SSL_read call and configuring the |
| 8855 | // shim to run asynchronously. |
| 8856 | testCases = append(testCases, testCase{ |
| 8857 | name: "ExportKeyingMaterial-Renegotiate", |
| 8858 | config: Config{ |
| 8859 | MaxVersion: VersionTLS12, |
| 8860 | }, |
| 8861 | renegotiate: 1, |
| 8862 | flags: []string{ |
| 8863 | "-async", |
| 8864 | "-use-exporter-between-reads", |
| 8865 | "-renegotiate-freely", |
| 8866 | "-expect-total-renegotiations", "1", |
| 8867 | }, |
| 8868 | shouldFail: true, |
| 8869 | expectedError: "failed to export keying material", |
| 8870 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8871 | } |
| 8872 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8873 | func addTLSUniqueTests() { |
| 8874 | for _, isClient := range []bool{false, true} { |
| 8875 | for _, isResumption := range []bool{false, true} { |
| 8876 | for _, hasEMS := range []bool{false, true} { |
| 8877 | var suffix string |
| 8878 | if isResumption { |
| 8879 | suffix = "Resume-" |
| 8880 | } else { |
| 8881 | suffix = "Full-" |
| 8882 | } |
| 8883 | |
| 8884 | if hasEMS { |
| 8885 | suffix += "EMS-" |
| 8886 | } else { |
| 8887 | suffix += "NoEMS-" |
| 8888 | } |
| 8889 | |
| 8890 | if isClient { |
| 8891 | suffix += "Client" |
| 8892 | } else { |
| 8893 | suffix += "Server" |
| 8894 | } |
| 8895 | |
| 8896 | test := testCase{ |
| 8897 | name: "TLSUnique-" + suffix, |
| 8898 | testTLSUnique: true, |
| 8899 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8900 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8901 | Bugs: ProtocolBugs{ |
| 8902 | NoExtendedMasterSecret: !hasEMS, |
| 8903 | }, |
| 8904 | }, |
| 8905 | } |
| 8906 | |
| 8907 | if isResumption { |
| 8908 | test.resumeSession = true |
| 8909 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8910 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8911 | Bugs: ProtocolBugs{ |
| 8912 | NoExtendedMasterSecret: !hasEMS, |
| 8913 | }, |
| 8914 | } |
| 8915 | } |
| 8916 | |
| 8917 | if isResumption && !hasEMS { |
| 8918 | test.shouldFail = true |
| 8919 | test.expectedError = "failed to get tls-unique" |
| 8920 | } |
| 8921 | |
| 8922 | testCases = append(testCases, test) |
| 8923 | } |
| 8924 | } |
| 8925 | } |
| 8926 | } |
| 8927 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8928 | func addCustomExtensionTests() { |
| 8929 | expectedContents := "custom extension" |
| 8930 | emptyString := "" |
| 8931 | |
| 8932 | for _, isClient := range []bool{false, true} { |
| 8933 | suffix := "Server" |
| 8934 | flag := "-enable-server-custom-extension" |
| 8935 | testType := serverTest |
| 8936 | if isClient { |
| 8937 | suffix = "Client" |
| 8938 | flag = "-enable-client-custom-extension" |
| 8939 | testType = clientTest |
| 8940 | } |
| 8941 | |
| 8942 | testCases = append(testCases, testCase{ |
| 8943 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8944 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8945 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8946 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8947 | Bugs: ProtocolBugs{ |
| 8948 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8949 | ExpectedCustomExtension: &expectedContents, |
| 8950 | }, |
| 8951 | }, |
| 8952 | flags: []string{flag}, |
| 8953 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8954 | testCases = append(testCases, testCase{ |
| 8955 | testType: testType, |
| 8956 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8957 | config: Config{ |
| 8958 | MaxVersion: VersionTLS13, |
| 8959 | Bugs: ProtocolBugs{ |
| 8960 | CustomExtension: expectedContents, |
| 8961 | ExpectedCustomExtension: &expectedContents, |
| 8962 | }, |
| 8963 | }, |
| 8964 | flags: []string{flag}, |
| 8965 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8966 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 8967 | // 0-RTT is not currently supported with Custom Extensions. |
| 8968 | testCases = append(testCases, testCase{ |
| 8969 | testType: testType, |
| 8970 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 8971 | config: Config{ |
| 8972 | MaxVersion: VersionTLS13, |
| 8973 | Bugs: ProtocolBugs{ |
| 8974 | CustomExtension: expectedContents, |
| 8975 | ExpectedCustomExtension: &expectedContents, |
| 8976 | }, |
| 8977 | }, |
| 8978 | shouldFail: true, |
| 8979 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8980 | flags: []string{flag, "-enable-early-data"}, |
| 8981 | }) |
| 8982 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8983 | // If the parse callback fails, the handshake should also fail. |
| 8984 | testCases = append(testCases, testCase{ |
| 8985 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8986 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8987 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8988 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8989 | Bugs: ProtocolBugs{ |
| 8990 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8991 | ExpectedCustomExtension: &expectedContents, |
| 8992 | }, |
| 8993 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8994 | flags: []string{flag}, |
| 8995 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8996 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8997 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8998 | testCases = append(testCases, testCase{ |
| 8999 | testType: testType, |
| 9000 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 9001 | config: Config{ |
| 9002 | MaxVersion: VersionTLS13, |
| 9003 | Bugs: ProtocolBugs{ |
| 9004 | CustomExtension: expectedContents + "foo", |
| 9005 | ExpectedCustomExtension: &expectedContents, |
| 9006 | }, |
| 9007 | }, |
| 9008 | flags: []string{flag}, |
| 9009 | shouldFail: true, |
| 9010 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9011 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9012 | |
| 9013 | // If the add callback fails, the handshake should also fail. |
| 9014 | testCases = append(testCases, testCase{ |
| 9015 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9016 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9017 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9018 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9019 | Bugs: ProtocolBugs{ |
| 9020 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9021 | ExpectedCustomExtension: &expectedContents, |
| 9022 | }, |
| 9023 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9024 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9025 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9026 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9027 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9028 | testCases = append(testCases, testCase{ |
| 9029 | testType: testType, |
| 9030 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 9031 | config: Config{ |
| 9032 | MaxVersion: VersionTLS13, |
| 9033 | Bugs: ProtocolBugs{ |
| 9034 | CustomExtension: expectedContents, |
| 9035 | ExpectedCustomExtension: &expectedContents, |
| 9036 | }, |
| 9037 | }, |
| 9038 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 9039 | shouldFail: true, |
| 9040 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 9041 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9042 | |
| 9043 | // If the add callback returns zero, no extension should be |
| 9044 | // added. |
| 9045 | skipCustomExtension := expectedContents |
| 9046 | if isClient { |
| 9047 | // For the case where the client skips sending the |
| 9048 | // custom extension, the server must not “echo” it. |
| 9049 | skipCustomExtension = "" |
| 9050 | } |
| 9051 | testCases = append(testCases, testCase{ |
| 9052 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9053 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9054 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9055 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9056 | Bugs: ProtocolBugs{ |
| 9057 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9058 | ExpectedCustomExtension: &emptyString, |
| 9059 | }, |
| 9060 | }, |
| 9061 | flags: []string{flag, "-custom-extension-skip"}, |
| 9062 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9063 | testCases = append(testCases, testCase{ |
| 9064 | testType: testType, |
| 9065 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 9066 | config: Config{ |
| 9067 | MaxVersion: VersionTLS13, |
| 9068 | Bugs: ProtocolBugs{ |
| 9069 | CustomExtension: skipCustomExtension, |
| 9070 | ExpectedCustomExtension: &emptyString, |
| 9071 | }, |
| 9072 | }, |
| 9073 | flags: []string{flag, "-custom-extension-skip"}, |
| 9074 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9075 | } |
| 9076 | |
| 9077 | // The custom extension add callback should not be called if the client |
| 9078 | // doesn't send the extension. |
| 9079 | testCases = append(testCases, testCase{ |
| 9080 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9081 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9082 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9083 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 9084 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9085 | ExpectedCustomExtension: &emptyString, |
| 9086 | }, |
| 9087 | }, |
| 9088 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9089 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9090 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9091 | testCases = append(testCases, testCase{ |
| 9092 | testType: serverTest, |
| 9093 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 9094 | config: Config{ |
| 9095 | MaxVersion: VersionTLS13, |
| 9096 | Bugs: ProtocolBugs{ |
| 9097 | ExpectedCustomExtension: &emptyString, |
| 9098 | }, |
| 9099 | }, |
| 9100 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 9101 | }) |
| 9102 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9103 | // Test an unknown extension from the server. |
| 9104 | testCases = append(testCases, testCase{ |
| 9105 | testType: clientTest, |
| 9106 | name: "UnknownExtension-Client", |
| 9107 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9108 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9109 | Bugs: ProtocolBugs{ |
| 9110 | CustomExtension: expectedContents, |
| 9111 | }, |
| 9112 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9113 | shouldFail: true, |
| 9114 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9115 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 9116 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9117 | testCases = append(testCases, testCase{ |
| 9118 | testType: clientTest, |
| 9119 | name: "UnknownExtension-Client-TLS13", |
| 9120 | config: Config{ |
| 9121 | MaxVersion: VersionTLS13, |
| 9122 | Bugs: ProtocolBugs{ |
| 9123 | CustomExtension: expectedContents, |
| 9124 | }, |
| 9125 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9126 | shouldFail: true, |
| 9127 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9128 | expectedLocalError: "remote error: unsupported extension", |
| 9129 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 9130 | testCases = append(testCases, testCase{ |
| 9131 | testType: clientTest, |
| 9132 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 9133 | config: Config{ |
| 9134 | MaxVersion: VersionTLS13, |
| 9135 | Bugs: ProtocolBugs{ |
| 9136 | CustomUnencryptedExtension: expectedContents, |
| 9137 | }, |
| 9138 | }, |
| 9139 | shouldFail: true, |
| 9140 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9141 | // The shim must send an alert, but alerts at this point do not |
| 9142 | // get successfully decrypted by the runner. |
| 9143 | expectedLocalError: "local error: bad record MAC", |
| 9144 | }) |
| 9145 | testCases = append(testCases, testCase{ |
| 9146 | testType: clientTest, |
| 9147 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 9148 | config: Config{ |
| 9149 | MaxVersion: VersionTLS13, |
| 9150 | Bugs: ProtocolBugs{ |
| 9151 | SendUnencryptedALPN: "foo", |
| 9152 | }, |
| 9153 | }, |
| 9154 | flags: []string{ |
| 9155 | "-advertise-alpn", "\x03foo\x03bar", |
| 9156 | }, |
| 9157 | shouldFail: true, |
| 9158 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9159 | // The shim must send an alert, but alerts at this point do not |
| 9160 | // get successfully decrypted by the runner. |
| 9161 | expectedLocalError: "local error: bad record MAC", |
| 9162 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 9163 | |
| 9164 | // Test a known but unoffered extension from the server. |
| 9165 | testCases = append(testCases, testCase{ |
| 9166 | testType: clientTest, |
| 9167 | name: "UnofferedExtension-Client", |
| 9168 | config: Config{ |
| 9169 | MaxVersion: VersionTLS12, |
| 9170 | Bugs: ProtocolBugs{ |
| 9171 | SendALPN: "alpn", |
| 9172 | }, |
| 9173 | }, |
| 9174 | shouldFail: true, |
| 9175 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9176 | expectedLocalError: "remote error: unsupported extension", |
| 9177 | }) |
| 9178 | testCases = append(testCases, testCase{ |
| 9179 | testType: clientTest, |
| 9180 | name: "UnofferedExtension-Client-TLS13", |
| 9181 | config: Config{ |
| 9182 | MaxVersion: VersionTLS13, |
| 9183 | Bugs: ProtocolBugs{ |
| 9184 | SendALPN: "alpn", |
| 9185 | }, |
| 9186 | }, |
| 9187 | shouldFail: true, |
| 9188 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 9189 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9190 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 9191 | } |
| 9192 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9193 | func addRSAClientKeyExchangeTests() { |
| 9194 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 9195 | testCases = append(testCases, testCase{ |
| 9196 | testType: serverTest, |
| 9197 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 9198 | config: Config{ |
| 9199 | // Ensure the ClientHello version and final |
| 9200 | // version are different, to detect if the |
| 9201 | // server uses the wrong one. |
| 9202 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 9203 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9204 | Bugs: ProtocolBugs{ |
| 9205 | BadRSAClientKeyExchange: bad, |
| 9206 | }, |
| 9207 | }, |
| 9208 | shouldFail: true, |
| 9209 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9210 | }) |
| 9211 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 9212 | |
| 9213 | // The server must compare whatever was in ClientHello.version for the |
| 9214 | // RSA premaster. |
| 9215 | testCases = append(testCases, testCase{ |
| 9216 | testType: serverTest, |
| 9217 | name: "SendClientVersion-RSA", |
| 9218 | config: Config{ |
| 9219 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 9220 | Bugs: ProtocolBugs{ |
| 9221 | SendClientVersion: 0x1234, |
| 9222 | }, |
| 9223 | }, |
| 9224 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9225 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 9226 | } |
| 9227 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9228 | var testCurves = []struct { |
| 9229 | name string |
| 9230 | id CurveID |
| 9231 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 9232 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9233 | {"P-256", CurveP256}, |
| 9234 | {"P-384", CurveP384}, |
| 9235 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 9236 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9237 | } |
| 9238 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9239 | const bogusCurve = 0x1234 |
| 9240 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9241 | func addCurveTests() { |
| 9242 | for _, curve := range testCurves { |
| 9243 | testCases = append(testCases, testCase{ |
| 9244 | name: "CurveTest-Client-" + curve.name, |
| 9245 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9246 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9247 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9248 | CurvePreferences: []CurveID{curve.id}, |
| 9249 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9250 | flags: []string{ |
| 9251 | "-enable-all-curves", |
| 9252 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9253 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9254 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9255 | }) |
| 9256 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9257 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 9258 | config: Config{ |
| 9259 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9260 | CurvePreferences: []CurveID{curve.id}, |
| 9261 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9262 | flags: []string{ |
| 9263 | "-enable-all-curves", |
| 9264 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9265 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9266 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9267 | }) |
| 9268 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9269 | testType: serverTest, |
| 9270 | name: "CurveTest-Server-" + curve.name, |
| 9271 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9272 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9273 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9274 | CurvePreferences: []CurveID{curve.id}, |
| 9275 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9276 | flags: []string{ |
| 9277 | "-enable-all-curves", |
| 9278 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9279 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9280 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9281 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9282 | testCases = append(testCases, testCase{ |
| 9283 | testType: serverTest, |
| 9284 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 9285 | config: Config{ |
| 9286 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9287 | CurvePreferences: []CurveID{curve.id}, |
| 9288 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 9289 | flags: []string{ |
| 9290 | "-enable-all-curves", |
| 9291 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 9292 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9293 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9294 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9295 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9296 | |
| 9297 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9298 | testCases = append(testCases, testCase{ |
| 9299 | testType: serverTest, |
| 9300 | name: "UnknownCurve", |
| 9301 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9302 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 9303 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9304 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9305 | }, |
| 9306 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9307 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9308 | // The server must be tolerant to bogus curves. |
| 9309 | testCases = append(testCases, testCase{ |
| 9310 | testType: serverTest, |
| 9311 | name: "UnknownCurve-TLS13", |
| 9312 | config: Config{ |
| 9313 | MaxVersion: VersionTLS13, |
| 9314 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 9315 | }, |
| 9316 | }) |
| 9317 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9318 | // The server must not consider ECDHE ciphers when there are no |
| 9319 | // supported curves. |
| 9320 | testCases = append(testCases, testCase{ |
| 9321 | testType: serverTest, |
| 9322 | name: "NoSupportedCurves", |
| 9323 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9324 | MaxVersion: VersionTLS12, |
| 9325 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9326 | Bugs: ProtocolBugs{ |
| 9327 | NoSupportedCurves: true, |
| 9328 | }, |
| 9329 | }, |
| 9330 | shouldFail: true, |
| 9331 | expectedError: ":NO_SHARED_CIPHER:", |
| 9332 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9333 | testCases = append(testCases, testCase{ |
| 9334 | testType: serverTest, |
| 9335 | name: "NoSupportedCurves-TLS13", |
| 9336 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9337 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9338 | Bugs: ProtocolBugs{ |
| 9339 | NoSupportedCurves: true, |
| 9340 | }, |
| 9341 | }, |
| 9342 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9343 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9344 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9345 | |
| 9346 | // The server must fall back to another cipher when there are no |
| 9347 | // supported curves. |
| 9348 | testCases = append(testCases, testCase{ |
| 9349 | testType: serverTest, |
| 9350 | name: "NoCommonCurves", |
| 9351 | config: Config{ |
| 9352 | MaxVersion: VersionTLS12, |
| 9353 | CipherSuites: []uint16{ |
| 9354 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9355 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9356 | }, |
| 9357 | CurvePreferences: []CurveID{CurveP224}, |
| 9358 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 9359 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9360 | }) |
| 9361 | |
| 9362 | // The client must reject bogus curves and disabled curves. |
| 9363 | testCases = append(testCases, testCase{ |
| 9364 | name: "BadECDHECurve", |
| 9365 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9366 | MaxVersion: VersionTLS12, |
| 9367 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9368 | Bugs: ProtocolBugs{ |
| 9369 | SendCurve: bogusCurve, |
| 9370 | }, |
| 9371 | }, |
| 9372 | shouldFail: true, |
| 9373 | expectedError: ":WRONG_CURVE:", |
| 9374 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9375 | testCases = append(testCases, testCase{ |
| 9376 | name: "BadECDHECurve-TLS13", |
| 9377 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9378 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9379 | Bugs: ProtocolBugs{ |
| 9380 | SendCurve: bogusCurve, |
| 9381 | }, |
| 9382 | }, |
| 9383 | shouldFail: true, |
| 9384 | expectedError: ":WRONG_CURVE:", |
| 9385 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9386 | |
| 9387 | testCases = append(testCases, testCase{ |
| 9388 | name: "UnsupportedCurve", |
| 9389 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9390 | MaxVersion: VersionTLS12, |
| 9391 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9392 | CurvePreferences: []CurveID{CurveP256}, |
| 9393 | Bugs: ProtocolBugs{ |
| 9394 | IgnorePeerCurvePreferences: true, |
| 9395 | }, |
| 9396 | }, |
| 9397 | flags: []string{"-p384-only"}, |
| 9398 | shouldFail: true, |
| 9399 | expectedError: ":WRONG_CURVE:", |
| 9400 | }) |
| 9401 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9402 | testCases = append(testCases, testCase{ |
| 9403 | // TODO(davidben): Add a TLS 1.3 version where |
| 9404 | // HelloRetryRequest requests an unsupported curve. |
| 9405 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 9406 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9407 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 9408 | CurvePreferences: []CurveID{CurveP384}, |
| 9409 | Bugs: ProtocolBugs{ |
| 9410 | SendCurve: CurveP256, |
| 9411 | }, |
| 9412 | }, |
| 9413 | flags: []string{"-p384-only"}, |
| 9414 | shouldFail: true, |
| 9415 | expectedError: ":WRONG_CURVE:", |
| 9416 | }) |
| 9417 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9418 | // Test invalid curve points. |
| 9419 | testCases = append(testCases, testCase{ |
| 9420 | name: "InvalidECDHPoint-Client", |
| 9421 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9422 | MaxVersion: VersionTLS12, |
| 9423 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9424 | CurvePreferences: []CurveID{CurveP256}, |
| 9425 | Bugs: ProtocolBugs{ |
| 9426 | InvalidECDHPoint: true, |
| 9427 | }, |
| 9428 | }, |
| 9429 | shouldFail: true, |
| 9430 | expectedError: ":INVALID_ENCODING:", |
| 9431 | }) |
| 9432 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9433 | name: "InvalidECDHPoint-Client-TLS13", |
| 9434 | config: Config{ |
| 9435 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9436 | CurvePreferences: []CurveID{CurveP256}, |
| 9437 | Bugs: ProtocolBugs{ |
| 9438 | InvalidECDHPoint: true, |
| 9439 | }, |
| 9440 | }, |
| 9441 | shouldFail: true, |
| 9442 | expectedError: ":INVALID_ENCODING:", |
| 9443 | }) |
| 9444 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9445 | testType: serverTest, |
| 9446 | name: "InvalidECDHPoint-Server", |
| 9447 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 9448 | MaxVersion: VersionTLS12, |
| 9449 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9450 | CurvePreferences: []CurveID{CurveP256}, |
| 9451 | Bugs: ProtocolBugs{ |
| 9452 | InvalidECDHPoint: true, |
| 9453 | }, |
| 9454 | }, |
| 9455 | shouldFail: true, |
| 9456 | expectedError: ":INVALID_ENCODING:", |
| 9457 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9458 | testCases = append(testCases, testCase{ |
| 9459 | testType: serverTest, |
| 9460 | name: "InvalidECDHPoint-Server-TLS13", |
| 9461 | config: Config{ |
| 9462 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9463 | CurvePreferences: []CurveID{CurveP256}, |
| 9464 | Bugs: ProtocolBugs{ |
| 9465 | InvalidECDHPoint: true, |
| 9466 | }, |
| 9467 | }, |
| 9468 | shouldFail: true, |
| 9469 | expectedError: ":INVALID_ENCODING:", |
| 9470 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9471 | |
| 9472 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 9473 | testCases = append(testCases, testCase{ |
| 9474 | name: "CurveID-Resume-Client", |
| 9475 | config: Config{ |
| 9476 | MaxVersion: VersionTLS12, |
| 9477 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9478 | CurvePreferences: []CurveID{CurveX25519}, |
| 9479 | }, |
| 9480 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9481 | resumeSession: true, |
| 9482 | }) |
| 9483 | testCases = append(testCases, testCase{ |
| 9484 | testType: serverTest, |
| 9485 | name: "CurveID-Resume-Server", |
| 9486 | config: Config{ |
| 9487 | MaxVersion: VersionTLS12, |
| 9488 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 9489 | CurvePreferences: []CurveID{CurveX25519}, |
| 9490 | }, |
| 9491 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 9492 | resumeSession: true, |
| 9493 | }) |
| 9494 | |
| 9495 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 9496 | // one should be reported. |
| 9497 | testCases = append(testCases, testCase{ |
| 9498 | name: "CurveID-Resume-Client-TLS13", |
| 9499 | config: Config{ |
| 9500 | MaxVersion: VersionTLS13, |
| 9501 | CurvePreferences: []CurveID{CurveX25519}, |
| 9502 | }, |
| 9503 | resumeConfig: &Config{ |
| 9504 | MaxVersion: VersionTLS13, |
| 9505 | CurvePreferences: []CurveID{CurveP256}, |
| 9506 | }, |
| 9507 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9508 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9509 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9510 | }, |
| 9511 | resumeSession: true, |
| 9512 | }) |
| 9513 | testCases = append(testCases, testCase{ |
| 9514 | testType: serverTest, |
| 9515 | name: "CurveID-Resume-Server-TLS13", |
| 9516 | config: Config{ |
| 9517 | MaxVersion: VersionTLS13, |
| 9518 | CurvePreferences: []CurveID{CurveX25519}, |
| 9519 | }, |
| 9520 | resumeConfig: &Config{ |
| 9521 | MaxVersion: VersionTLS13, |
| 9522 | CurvePreferences: []CurveID{CurveP256}, |
| 9523 | }, |
| 9524 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 9525 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 9526 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 9527 | }, |
| 9528 | resumeSession: true, |
| 9529 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 9530 | |
| 9531 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 9532 | testCases = append(testCases, testCase{ |
| 9533 | name: "PointFormat-ServerHello-TLS12", |
| 9534 | config: Config{ |
| 9535 | MaxVersion: VersionTLS12, |
| 9536 | Bugs: ProtocolBugs{ |
| 9537 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9538 | }, |
| 9539 | }, |
| 9540 | }) |
| 9541 | testCases = append(testCases, testCase{ |
| 9542 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 9543 | config: Config{ |
| 9544 | MaxVersion: VersionTLS13, |
| 9545 | Bugs: ProtocolBugs{ |
| 9546 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 9547 | }, |
| 9548 | }, |
| 9549 | shouldFail: true, |
| 9550 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9551 | }) |
| 9552 | |
| 9553 | // Test that we tolerate unknown point formats, as long as |
| 9554 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 9555 | // check they are still functional. |
| 9556 | testCases = append(testCases, testCase{ |
| 9557 | name: "PointFormat-Client-Tolerance", |
| 9558 | config: Config{ |
| 9559 | MaxVersion: VersionTLS12, |
| 9560 | Bugs: ProtocolBugs{ |
| 9561 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9562 | }, |
| 9563 | }, |
| 9564 | }) |
| 9565 | testCases = append(testCases, testCase{ |
| 9566 | testType: serverTest, |
| 9567 | name: "PointFormat-Server-Tolerance", |
| 9568 | config: Config{ |
| 9569 | MaxVersion: VersionTLS12, |
| 9570 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9571 | Bugs: ProtocolBugs{ |
| 9572 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 9573 | }, |
| 9574 | }, |
| 9575 | }) |
| 9576 | |
| 9577 | // Test TLS 1.2 does not require the point format extension to be |
| 9578 | // present. |
| 9579 | testCases = append(testCases, testCase{ |
| 9580 | name: "PointFormat-Client-Missing", |
| 9581 | config: Config{ |
| 9582 | MaxVersion: VersionTLS12, |
| 9583 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9584 | Bugs: ProtocolBugs{ |
| 9585 | SendSupportedPointFormats: []byte{}, |
| 9586 | }, |
| 9587 | }, |
| 9588 | }) |
| 9589 | testCases = append(testCases, testCase{ |
| 9590 | testType: serverTest, |
| 9591 | name: "PointFormat-Server-Missing", |
| 9592 | config: Config{ |
| 9593 | MaxVersion: VersionTLS12, |
| 9594 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 9595 | Bugs: ProtocolBugs{ |
| 9596 | SendSupportedPointFormats: []byte{}, |
| 9597 | }, |
| 9598 | }, |
| 9599 | }) |
| 9600 | |
| 9601 | // If the point format extension is present, uncompressed points must be |
| 9602 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 9603 | testCases = append(testCases, testCase{ |
| 9604 | name: "PointFormat-Client-MissingUncompressed", |
| 9605 | config: Config{ |
| 9606 | MaxVersion: VersionTLS12, |
| 9607 | Bugs: ProtocolBugs{ |
| 9608 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9609 | }, |
| 9610 | }, |
| 9611 | shouldFail: true, |
| 9612 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9613 | }) |
| 9614 | testCases = append(testCases, testCase{ |
| 9615 | testType: serverTest, |
| 9616 | name: "PointFormat-Server-MissingUncompressed", |
| 9617 | config: Config{ |
| 9618 | MaxVersion: VersionTLS12, |
| 9619 | Bugs: ProtocolBugs{ |
| 9620 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 9621 | }, |
| 9622 | }, |
| 9623 | shouldFail: true, |
| 9624 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 9625 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 9626 | } |
| 9627 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 9628 | func addTLS13RecordTests() { |
| 9629 | testCases = append(testCases, testCase{ |
| 9630 | name: "TLS13-RecordPadding", |
| 9631 | config: Config{ |
| 9632 | MaxVersion: VersionTLS13, |
| 9633 | MinVersion: VersionTLS13, |
| 9634 | Bugs: ProtocolBugs{ |
| 9635 | RecordPadding: 10, |
| 9636 | }, |
| 9637 | }, |
| 9638 | }) |
| 9639 | |
| 9640 | testCases = append(testCases, testCase{ |
| 9641 | name: "TLS13-EmptyRecords", |
| 9642 | config: Config{ |
| 9643 | MaxVersion: VersionTLS13, |
| 9644 | MinVersion: VersionTLS13, |
| 9645 | Bugs: ProtocolBugs{ |
| 9646 | OmitRecordContents: true, |
| 9647 | }, |
| 9648 | }, |
| 9649 | shouldFail: true, |
| 9650 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9651 | }) |
| 9652 | |
| 9653 | testCases = append(testCases, testCase{ |
| 9654 | name: "TLS13-OnlyPadding", |
| 9655 | config: Config{ |
| 9656 | MaxVersion: VersionTLS13, |
| 9657 | MinVersion: VersionTLS13, |
| 9658 | Bugs: ProtocolBugs{ |
| 9659 | OmitRecordContents: true, |
| 9660 | RecordPadding: 10, |
| 9661 | }, |
| 9662 | }, |
| 9663 | shouldFail: true, |
| 9664 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9665 | }) |
| 9666 | |
| 9667 | testCases = append(testCases, testCase{ |
| 9668 | name: "TLS13-WrongOuterRecord", |
| 9669 | config: Config{ |
| 9670 | MaxVersion: VersionTLS13, |
| 9671 | MinVersion: VersionTLS13, |
| 9672 | Bugs: ProtocolBugs{ |
| 9673 | OuterRecordType: recordTypeHandshake, |
| 9674 | }, |
| 9675 | }, |
| 9676 | shouldFail: true, |
| 9677 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 9678 | }) |
| 9679 | } |
| 9680 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9681 | func addSessionTicketTests() { |
| 9682 | testCases = append(testCases, testCase{ |
| 9683 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 9684 | // mean the server changed its mind on sending a ticket. |
| 9685 | name: "SendEmptySessionTicket", |
| 9686 | config: Config{ |
| 9687 | MaxVersion: VersionTLS12, |
| 9688 | Bugs: ProtocolBugs{ |
| 9689 | SendEmptySessionTicket: true, |
| 9690 | }, |
| 9691 | }, |
| 9692 | flags: []string{"-expect-no-session"}, |
| 9693 | }) |
| 9694 | |
| 9695 | // Test that the server ignores unknown PSK modes. |
| 9696 | testCases = append(testCases, testCase{ |
| 9697 | testType: serverTest, |
| 9698 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9699 | config: Config{ |
| 9700 | MaxVersion: VersionTLS13, |
| 9701 | Bugs: ProtocolBugs{ |
| 9702 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9703 | }, |
| 9704 | }, |
| 9705 | resumeSession: true, |
| 9706 | expectedResumeVersion: VersionTLS13, |
| 9707 | }) |
| 9708 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9709 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9710 | testCases = append(testCases, testCase{ |
| 9711 | testType: serverTest, |
| 9712 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9713 | config: Config{ |
| 9714 | MaxVersion: VersionTLS13, |
| 9715 | Bugs: ProtocolBugs{ |
| 9716 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9717 | ExpectNoNewSessionTicket: true, |
| 9718 | }, |
| 9719 | }, |
| 9720 | }) |
| 9721 | |
| 9722 | // 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] | 9723 | testCases = append(testCases, testCase{ |
| 9724 | testType: serverTest, |
| 9725 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9726 | config: Config{ |
| 9727 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9728 | }, |
| 9729 | resumeConfig: &Config{ |
| 9730 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9731 | Bugs: ProtocolBugs{ |
| 9732 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9733 | }, |
| 9734 | }, |
| 9735 | resumeSession: true, |
| 9736 | expectResumeRejected: true, |
| 9737 | }) |
| 9738 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9739 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9740 | testCases = append(testCases, testCase{ |
| 9741 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9742 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9743 | config: Config{ |
| 9744 | MaxVersion: VersionTLS13, |
| 9745 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9746 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9747 | }, |
| 9748 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9749 | resumeSession: true, |
| 9750 | flags: []string{ |
| 9751 | "-resumption-delay", "10", |
| 9752 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9753 | }) |
| 9754 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9755 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9756 | testCases = append(testCases, testCase{ |
| 9757 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9758 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9759 | config: Config{ |
| 9760 | MaxVersion: VersionTLS13, |
| 9761 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9762 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9763 | }, |
| 9764 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9765 | resumeSession: true, |
| 9766 | shouldFail: true, |
| 9767 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9768 | }) |
| 9769 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9770 | // Test that the server's ticket age skew reporting works. |
| 9771 | testCases = append(testCases, testCase{ |
| 9772 | testType: serverTest, |
| 9773 | name: "TLS13-TicketAgeSkew-Forward", |
| 9774 | config: Config{ |
| 9775 | MaxVersion: VersionTLS13, |
| 9776 | Bugs: ProtocolBugs{ |
| 9777 | SendTicketAge: 15 * time.Second, |
| 9778 | }, |
| 9779 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9780 | resumeSession: true, |
| 9781 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9782 | flags: []string{ |
| 9783 | "-resumption-delay", "10", |
| 9784 | "-expect-ticket-age-skew", "5", |
| 9785 | }, |
| 9786 | }) |
| 9787 | testCases = append(testCases, testCase{ |
| 9788 | testType: serverTest, |
| 9789 | name: "TLS13-TicketAgeSkew-Backward", |
| 9790 | config: Config{ |
| 9791 | MaxVersion: VersionTLS13, |
| 9792 | Bugs: ProtocolBugs{ |
| 9793 | SendTicketAge: 5 * time.Second, |
| 9794 | }, |
| 9795 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9796 | resumeSession: true, |
| 9797 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9798 | flags: []string{ |
| 9799 | "-resumption-delay", "10", |
| 9800 | "-expect-ticket-age-skew", "-5", |
| 9801 | }, |
| 9802 | }) |
| 9803 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9804 | testCases = append(testCases, testCase{ |
| 9805 | testType: clientTest, |
| 9806 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9807 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9808 | MaxVersion: VersionTLS13, |
| 9809 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9810 | }, |
| 9811 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9812 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9813 | "-expect-early-data-info", |
| 9814 | }, |
| 9815 | }) |
| 9816 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9817 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9818 | testCases = append(testCases, testCase{ |
| 9819 | testType: clientTest, |
| 9820 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9821 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9822 | MaxVersion: VersionTLS13, |
| 9823 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9824 | }, |
| 9825 | }) |
| 9826 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9827 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9828 | testType: clientTest, |
| 9829 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9830 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9831 | MaxVersion: VersionTLS13, |
| 9832 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9833 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9834 | DuplicateTicketEarlyDataInfo: true, |
| 9835 | }, |
| 9836 | }, |
| 9837 | shouldFail: true, |
| 9838 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9839 | expectedLocalError: "remote error: illegal parameter", |
| 9840 | }) |
| 9841 | |
| 9842 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9843 | testType: serverTest, |
| 9844 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9845 | config: Config{ |
| 9846 | MaxVersion: VersionTLS13, |
| 9847 | Bugs: ProtocolBugs{ |
| 9848 | ExpectTicketEarlyDataInfo: true, |
| 9849 | }, |
| 9850 | }, |
| 9851 | flags: []string{ |
| 9852 | "-enable-early-data", |
| 9853 | }, |
| 9854 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9855 | |
| 9856 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9857 | // is honored. |
| 9858 | testCases = append(testCases, testCase{ |
| 9859 | testType: clientTest, |
| 9860 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9861 | config: Config{ |
| 9862 | MaxVersion: VersionTLS13, |
| 9863 | Bugs: ProtocolBugs{ |
| 9864 | SendTicketLifetime: 20 * time.Second, |
| 9865 | }, |
| 9866 | }, |
| 9867 | flags: []string{ |
| 9868 | "-resumption-delay", "19", |
| 9869 | }, |
| 9870 | resumeSession: true, |
| 9871 | }) |
| 9872 | testCases = append(testCases, testCase{ |
| 9873 | testType: clientTest, |
| 9874 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9875 | config: Config{ |
| 9876 | MaxVersion: VersionTLS13, |
| 9877 | Bugs: ProtocolBugs{ |
| 9878 | SendTicketLifetime: 20 * time.Second, |
| 9879 | // The client should not offer the expired session. |
| 9880 | ExpectNoTLS13PSK: true, |
| 9881 | }, |
| 9882 | }, |
| 9883 | flags: []string{ |
| 9884 | "-resumption-delay", "21", |
| 9885 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9886 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9887 | expectResumeRejected: true, |
| 9888 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9889 | } |
| 9890 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9891 | func addChangeCipherSpecTests() { |
| 9892 | // Test missing ChangeCipherSpecs. |
| 9893 | testCases = append(testCases, testCase{ |
| 9894 | name: "SkipChangeCipherSpec-Client", |
| 9895 | config: Config{ |
| 9896 | MaxVersion: VersionTLS12, |
| 9897 | Bugs: ProtocolBugs{ |
| 9898 | SkipChangeCipherSpec: true, |
| 9899 | }, |
| 9900 | }, |
| 9901 | shouldFail: true, |
| 9902 | expectedError: ":UNEXPECTED_RECORD:", |
| 9903 | }) |
| 9904 | testCases = append(testCases, testCase{ |
| 9905 | testType: serverTest, |
| 9906 | name: "SkipChangeCipherSpec-Server", |
| 9907 | config: Config{ |
| 9908 | MaxVersion: VersionTLS12, |
| 9909 | Bugs: ProtocolBugs{ |
| 9910 | SkipChangeCipherSpec: true, |
| 9911 | }, |
| 9912 | }, |
| 9913 | shouldFail: true, |
| 9914 | expectedError: ":UNEXPECTED_RECORD:", |
| 9915 | }) |
| 9916 | testCases = append(testCases, testCase{ |
| 9917 | testType: serverTest, |
| 9918 | name: "SkipChangeCipherSpec-Server-NPN", |
| 9919 | config: Config{ |
| 9920 | MaxVersion: VersionTLS12, |
| 9921 | NextProtos: []string{"bar"}, |
| 9922 | Bugs: ProtocolBugs{ |
| 9923 | SkipChangeCipherSpec: true, |
| 9924 | }, |
| 9925 | }, |
| 9926 | flags: []string{ |
| 9927 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9928 | }, |
| 9929 | shouldFail: true, |
| 9930 | expectedError: ":UNEXPECTED_RECORD:", |
| 9931 | }) |
| 9932 | |
| 9933 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 9934 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 9935 | // rejected. Test both with and without handshake packing to handle both |
| 9936 | // when the partial post-CCS message is in its own record and when it is |
| 9937 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9938 | for _, packed := range []bool{false, true} { |
| 9939 | var suffix string |
| 9940 | if packed { |
| 9941 | suffix = "-Packed" |
| 9942 | } |
| 9943 | |
| 9944 | testCases = append(testCases, testCase{ |
| 9945 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 9946 | config: Config{ |
| 9947 | MaxVersion: VersionTLS12, |
| 9948 | Bugs: ProtocolBugs{ |
| 9949 | FragmentAcrossChangeCipherSpec: true, |
| 9950 | PackHandshakeFlight: packed, |
| 9951 | }, |
| 9952 | }, |
| 9953 | shouldFail: true, |
| 9954 | expectedError: ":UNEXPECTED_RECORD:", |
| 9955 | }) |
| 9956 | testCases = append(testCases, testCase{ |
| 9957 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 9958 | config: Config{ |
| 9959 | MaxVersion: VersionTLS12, |
| 9960 | }, |
| 9961 | resumeSession: true, |
| 9962 | resumeConfig: &Config{ |
| 9963 | MaxVersion: VersionTLS12, |
| 9964 | Bugs: ProtocolBugs{ |
| 9965 | FragmentAcrossChangeCipherSpec: true, |
| 9966 | PackHandshakeFlight: packed, |
| 9967 | }, |
| 9968 | }, |
| 9969 | shouldFail: true, |
| 9970 | expectedError: ":UNEXPECTED_RECORD:", |
| 9971 | }) |
| 9972 | testCases = append(testCases, testCase{ |
| 9973 | testType: serverTest, |
| 9974 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 9975 | config: Config{ |
| 9976 | MaxVersion: VersionTLS12, |
| 9977 | Bugs: ProtocolBugs{ |
| 9978 | FragmentAcrossChangeCipherSpec: true, |
| 9979 | PackHandshakeFlight: packed, |
| 9980 | }, |
| 9981 | }, |
| 9982 | shouldFail: true, |
| 9983 | expectedError: ":UNEXPECTED_RECORD:", |
| 9984 | }) |
| 9985 | testCases = append(testCases, testCase{ |
| 9986 | testType: serverTest, |
| 9987 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 9988 | config: Config{ |
| 9989 | MaxVersion: VersionTLS12, |
| 9990 | }, |
| 9991 | resumeSession: true, |
| 9992 | resumeConfig: &Config{ |
| 9993 | MaxVersion: VersionTLS12, |
| 9994 | Bugs: ProtocolBugs{ |
| 9995 | FragmentAcrossChangeCipherSpec: true, |
| 9996 | PackHandshakeFlight: packed, |
| 9997 | }, |
| 9998 | }, |
| 9999 | shouldFail: true, |
| 10000 | expectedError: ":UNEXPECTED_RECORD:", |
| 10001 | }) |
| 10002 | testCases = append(testCases, testCase{ |
| 10003 | testType: serverTest, |
| 10004 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 10005 | config: Config{ |
| 10006 | MaxVersion: VersionTLS12, |
| 10007 | NextProtos: []string{"bar"}, |
| 10008 | Bugs: ProtocolBugs{ |
| 10009 | FragmentAcrossChangeCipherSpec: true, |
| 10010 | PackHandshakeFlight: packed, |
| 10011 | }, |
| 10012 | }, |
| 10013 | flags: []string{ |
| 10014 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 10015 | }, |
| 10016 | shouldFail: true, |
| 10017 | expectedError: ":UNEXPECTED_RECORD:", |
| 10018 | }) |
| 10019 | } |
| 10020 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 10021 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 10022 | // messages in the handshake queue. Do this by testing the server |
| 10023 | // reading the client Finished, reversing the flight so Finished comes |
| 10024 | // first. |
| 10025 | testCases = append(testCases, testCase{ |
| 10026 | protocol: dtls, |
| 10027 | testType: serverTest, |
| 10028 | name: "SendUnencryptedFinished-DTLS", |
| 10029 | config: Config{ |
| 10030 | MaxVersion: VersionTLS12, |
| 10031 | Bugs: ProtocolBugs{ |
| 10032 | SendUnencryptedFinished: true, |
| 10033 | ReverseHandshakeFragments: true, |
| 10034 | }, |
| 10035 | }, |
| 10036 | shouldFail: true, |
| 10037 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10038 | }) |
| 10039 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10040 | // Test synchronization between encryption changes and the handshake in |
| 10041 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 10042 | testCases = append(testCases, testCase{ |
| 10043 | name: "PartialEncryptedExtensionsWithServerHello", |
| 10044 | config: Config{ |
| 10045 | MaxVersion: VersionTLS13, |
| 10046 | Bugs: ProtocolBugs{ |
| 10047 | PartialEncryptedExtensionsWithServerHello: true, |
| 10048 | }, |
| 10049 | }, |
| 10050 | shouldFail: true, |
| 10051 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10052 | }) |
| 10053 | testCases = append(testCases, testCase{ |
| 10054 | testType: serverTest, |
| 10055 | name: "PartialClientFinishedWithClientHello", |
| 10056 | config: Config{ |
| 10057 | MaxVersion: VersionTLS13, |
| 10058 | Bugs: ProtocolBugs{ |
| 10059 | PartialClientFinishedWithClientHello: true, |
| 10060 | }, |
| 10061 | }, |
| 10062 | shouldFail: true, |
| 10063 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 10064 | }) |
| 10065 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10066 | // Test that early ChangeCipherSpecs are handled correctly. |
| 10067 | testCases = append(testCases, testCase{ |
| 10068 | testType: serverTest, |
| 10069 | name: "EarlyChangeCipherSpec-server-1", |
| 10070 | config: Config{ |
| 10071 | MaxVersion: VersionTLS12, |
| 10072 | Bugs: ProtocolBugs{ |
| 10073 | EarlyChangeCipherSpec: 1, |
| 10074 | }, |
| 10075 | }, |
| 10076 | shouldFail: true, |
| 10077 | expectedError: ":UNEXPECTED_RECORD:", |
| 10078 | }) |
| 10079 | testCases = append(testCases, testCase{ |
| 10080 | testType: serverTest, |
| 10081 | name: "EarlyChangeCipherSpec-server-2", |
| 10082 | config: Config{ |
| 10083 | MaxVersion: VersionTLS12, |
| 10084 | Bugs: ProtocolBugs{ |
| 10085 | EarlyChangeCipherSpec: 2, |
| 10086 | }, |
| 10087 | }, |
| 10088 | shouldFail: true, |
| 10089 | expectedError: ":UNEXPECTED_RECORD:", |
| 10090 | }) |
| 10091 | testCases = append(testCases, testCase{ |
| 10092 | protocol: dtls, |
| 10093 | name: "StrayChangeCipherSpec", |
| 10094 | config: Config{ |
| 10095 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 10096 | // that stray ChangeCipherSpec messages are |
| 10097 | // rejected. |
| 10098 | MaxVersion: VersionTLS12, |
| 10099 | Bugs: ProtocolBugs{ |
| 10100 | StrayChangeCipherSpec: true, |
| 10101 | }, |
| 10102 | }, |
| 10103 | }) |
| 10104 | |
David Benjamin | b0c761e | 2017-06-25 22:42:55 -0400 | [diff] [blame] | 10105 | // Test that reordered ChangeCipherSpecs are tolerated. |
| 10106 | testCases = append(testCases, testCase{ |
| 10107 | protocol: dtls, |
| 10108 | name: "ReorderChangeCipherSpec-DTLS-Client", |
| 10109 | config: Config{ |
| 10110 | MaxVersion: VersionTLS12, |
| 10111 | Bugs: ProtocolBugs{ |
| 10112 | ReorderChangeCipherSpec: true, |
| 10113 | }, |
| 10114 | }, |
| 10115 | resumeSession: true, |
| 10116 | }) |
| 10117 | testCases = append(testCases, testCase{ |
| 10118 | testType: serverTest, |
| 10119 | protocol: dtls, |
| 10120 | name: "ReorderChangeCipherSpec-DTLS-Server", |
| 10121 | config: Config{ |
| 10122 | MaxVersion: VersionTLS12, |
| 10123 | Bugs: ProtocolBugs{ |
| 10124 | ReorderChangeCipherSpec: true, |
| 10125 | }, |
| 10126 | }, |
| 10127 | resumeSession: true, |
| 10128 | }) |
| 10129 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 10130 | // Test that the contents of ChangeCipherSpec are checked. |
| 10131 | testCases = append(testCases, testCase{ |
| 10132 | name: "BadChangeCipherSpec-1", |
| 10133 | config: Config{ |
| 10134 | MaxVersion: VersionTLS12, |
| 10135 | Bugs: ProtocolBugs{ |
| 10136 | BadChangeCipherSpec: []byte{2}, |
| 10137 | }, |
| 10138 | }, |
| 10139 | shouldFail: true, |
| 10140 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10141 | }) |
| 10142 | testCases = append(testCases, testCase{ |
| 10143 | name: "BadChangeCipherSpec-2", |
| 10144 | config: Config{ |
| 10145 | MaxVersion: VersionTLS12, |
| 10146 | Bugs: ProtocolBugs{ |
| 10147 | BadChangeCipherSpec: []byte{1, 1}, |
| 10148 | }, |
| 10149 | }, |
| 10150 | shouldFail: true, |
| 10151 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10152 | }) |
| 10153 | testCases = append(testCases, testCase{ |
| 10154 | protocol: dtls, |
| 10155 | name: "BadChangeCipherSpec-DTLS-1", |
| 10156 | config: Config{ |
| 10157 | MaxVersion: VersionTLS12, |
| 10158 | Bugs: ProtocolBugs{ |
| 10159 | BadChangeCipherSpec: []byte{2}, |
| 10160 | }, |
| 10161 | }, |
| 10162 | shouldFail: true, |
| 10163 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10164 | }) |
| 10165 | testCases = append(testCases, testCase{ |
| 10166 | protocol: dtls, |
| 10167 | name: "BadChangeCipherSpec-DTLS-2", |
| 10168 | config: Config{ |
| 10169 | MaxVersion: VersionTLS12, |
| 10170 | Bugs: ProtocolBugs{ |
| 10171 | BadChangeCipherSpec: []byte{1, 1}, |
| 10172 | }, |
| 10173 | }, |
| 10174 | shouldFail: true, |
| 10175 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 10176 | }) |
| 10177 | } |
| 10178 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10179 | type perMessageTest struct { |
| 10180 | messageType uint8 |
| 10181 | test testCase |
| 10182 | } |
| 10183 | |
| 10184 | // makePerMessageTests returns a series of test templates which cover each |
| 10185 | // message in the TLS handshake. These may be used with bugs like |
| 10186 | // WrongMessageType to fully test a per-message bug. |
| 10187 | func makePerMessageTests() []perMessageTest { |
| 10188 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10189 | for _, protocol := range []protocol{tls, dtls} { |
| 10190 | var suffix string |
| 10191 | if protocol == dtls { |
| 10192 | suffix = "-DTLS" |
| 10193 | } |
| 10194 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10195 | ret = append(ret, perMessageTest{ |
| 10196 | messageType: typeClientHello, |
| 10197 | test: testCase{ |
| 10198 | protocol: protocol, |
| 10199 | testType: serverTest, |
| 10200 | name: "ClientHello" + suffix, |
| 10201 | config: Config{ |
| 10202 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10203 | }, |
| 10204 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10205 | }) |
| 10206 | |
| 10207 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10208 | ret = append(ret, perMessageTest{ |
| 10209 | messageType: typeHelloVerifyRequest, |
| 10210 | test: testCase{ |
| 10211 | protocol: protocol, |
| 10212 | name: "HelloVerifyRequest" + suffix, |
| 10213 | config: Config{ |
| 10214 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10215 | }, |
| 10216 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10217 | }) |
| 10218 | } |
| 10219 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10220 | ret = append(ret, perMessageTest{ |
| 10221 | messageType: typeServerHello, |
| 10222 | test: testCase{ |
| 10223 | protocol: protocol, |
| 10224 | name: "ServerHello" + suffix, |
| 10225 | config: Config{ |
| 10226 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10227 | }, |
| 10228 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10229 | }) |
| 10230 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10231 | ret = append(ret, perMessageTest{ |
| 10232 | messageType: typeCertificate, |
| 10233 | test: testCase{ |
| 10234 | protocol: protocol, |
| 10235 | name: "ServerCertificate" + suffix, |
| 10236 | config: Config{ |
| 10237 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10238 | }, |
| 10239 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10240 | }) |
| 10241 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10242 | ret = append(ret, perMessageTest{ |
| 10243 | messageType: typeCertificateStatus, |
| 10244 | test: testCase{ |
| 10245 | protocol: protocol, |
| 10246 | name: "CertificateStatus" + suffix, |
| 10247 | config: Config{ |
| 10248 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10249 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10250 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10251 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10252 | }) |
| 10253 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10254 | ret = append(ret, perMessageTest{ |
| 10255 | messageType: typeServerKeyExchange, |
| 10256 | test: testCase{ |
| 10257 | protocol: protocol, |
| 10258 | name: "ServerKeyExchange" + suffix, |
| 10259 | config: Config{ |
| 10260 | MaxVersion: VersionTLS12, |
| 10261 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10262 | }, |
| 10263 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10264 | }) |
| 10265 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10266 | ret = append(ret, perMessageTest{ |
| 10267 | messageType: typeCertificateRequest, |
| 10268 | test: testCase{ |
| 10269 | protocol: protocol, |
| 10270 | name: "CertificateRequest" + suffix, |
| 10271 | config: Config{ |
| 10272 | MaxVersion: VersionTLS12, |
| 10273 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10274 | }, |
| 10275 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10276 | }) |
| 10277 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10278 | ret = append(ret, perMessageTest{ |
| 10279 | messageType: typeServerHelloDone, |
| 10280 | test: testCase{ |
| 10281 | protocol: protocol, |
| 10282 | name: "ServerHelloDone" + suffix, |
| 10283 | config: Config{ |
| 10284 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10285 | }, |
| 10286 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10287 | }) |
| 10288 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10289 | ret = append(ret, perMessageTest{ |
| 10290 | messageType: typeCertificate, |
| 10291 | test: testCase{ |
| 10292 | testType: serverTest, |
| 10293 | protocol: protocol, |
| 10294 | name: "ClientCertificate" + suffix, |
| 10295 | config: Config{ |
| 10296 | Certificates: []Certificate{rsaCertificate}, |
| 10297 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10298 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10299 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10300 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10301 | }) |
| 10302 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10303 | ret = append(ret, perMessageTest{ |
| 10304 | messageType: typeCertificateVerify, |
| 10305 | test: testCase{ |
| 10306 | testType: serverTest, |
| 10307 | protocol: protocol, |
| 10308 | name: "CertificateVerify" + suffix, |
| 10309 | config: Config{ |
| 10310 | Certificates: []Certificate{rsaCertificate}, |
| 10311 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10312 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10313 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10314 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10315 | }) |
| 10316 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10317 | ret = append(ret, perMessageTest{ |
| 10318 | messageType: typeClientKeyExchange, |
| 10319 | test: testCase{ |
| 10320 | testType: serverTest, |
| 10321 | protocol: protocol, |
| 10322 | name: "ClientKeyExchange" + suffix, |
| 10323 | config: Config{ |
| 10324 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10325 | }, |
| 10326 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10327 | }) |
| 10328 | |
| 10329 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10330 | ret = append(ret, perMessageTest{ |
| 10331 | messageType: typeNextProtocol, |
| 10332 | test: testCase{ |
| 10333 | testType: serverTest, |
| 10334 | protocol: protocol, |
| 10335 | name: "NextProtocol" + suffix, |
| 10336 | config: Config{ |
| 10337 | MaxVersion: VersionTLS12, |
| 10338 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10339 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10340 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10341 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10342 | }) |
| 10343 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10344 | ret = append(ret, perMessageTest{ |
| 10345 | messageType: typeChannelID, |
| 10346 | test: testCase{ |
| 10347 | testType: serverTest, |
| 10348 | protocol: protocol, |
| 10349 | name: "ChannelID" + suffix, |
| 10350 | config: Config{ |
| 10351 | MaxVersion: VersionTLS12, |
| 10352 | ChannelID: channelIDKey, |
| 10353 | }, |
| 10354 | flags: []string{ |
| 10355 | "-expect-channel-id", |
| 10356 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10357 | }, |
| 10358 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10359 | }) |
| 10360 | } |
| 10361 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10362 | ret = append(ret, perMessageTest{ |
| 10363 | messageType: typeFinished, |
| 10364 | test: testCase{ |
| 10365 | testType: serverTest, |
| 10366 | protocol: protocol, |
| 10367 | name: "ClientFinished" + suffix, |
| 10368 | config: Config{ |
| 10369 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10370 | }, |
| 10371 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10372 | }) |
| 10373 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10374 | ret = append(ret, perMessageTest{ |
| 10375 | messageType: typeNewSessionTicket, |
| 10376 | test: testCase{ |
| 10377 | protocol: protocol, |
| 10378 | name: "NewSessionTicket" + suffix, |
| 10379 | config: Config{ |
| 10380 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10381 | }, |
| 10382 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10383 | }) |
| 10384 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10385 | ret = append(ret, perMessageTest{ |
| 10386 | messageType: typeFinished, |
| 10387 | test: testCase{ |
| 10388 | protocol: protocol, |
| 10389 | name: "ServerFinished" + suffix, |
| 10390 | config: Config{ |
| 10391 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10392 | }, |
| 10393 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10394 | }) |
| 10395 | |
| 10396 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10397 | |
| 10398 | ret = append(ret, perMessageTest{ |
| 10399 | messageType: typeClientHello, |
| 10400 | test: testCase{ |
| 10401 | testType: serverTest, |
| 10402 | name: "TLS13-ClientHello", |
| 10403 | config: Config{ |
| 10404 | MaxVersion: VersionTLS13, |
| 10405 | }, |
| 10406 | }, |
| 10407 | }) |
| 10408 | |
| 10409 | ret = append(ret, perMessageTest{ |
| 10410 | messageType: typeServerHello, |
| 10411 | test: testCase{ |
| 10412 | name: "TLS13-ServerHello", |
| 10413 | config: Config{ |
| 10414 | MaxVersion: VersionTLS13, |
| 10415 | }, |
| 10416 | }, |
| 10417 | }) |
| 10418 | |
| 10419 | ret = append(ret, perMessageTest{ |
| 10420 | messageType: typeEncryptedExtensions, |
| 10421 | test: testCase{ |
| 10422 | name: "TLS13-EncryptedExtensions", |
| 10423 | config: Config{ |
| 10424 | MaxVersion: VersionTLS13, |
| 10425 | }, |
| 10426 | }, |
| 10427 | }) |
| 10428 | |
| 10429 | ret = append(ret, perMessageTest{ |
| 10430 | messageType: typeCertificateRequest, |
| 10431 | test: testCase{ |
| 10432 | name: "TLS13-CertificateRequest", |
| 10433 | config: Config{ |
| 10434 | MaxVersion: VersionTLS13, |
| 10435 | ClientAuth: RequireAnyClientCert, |
| 10436 | }, |
| 10437 | }, |
| 10438 | }) |
| 10439 | |
| 10440 | ret = append(ret, perMessageTest{ |
| 10441 | messageType: typeCertificate, |
| 10442 | test: testCase{ |
| 10443 | name: "TLS13-ServerCertificate", |
| 10444 | config: Config{ |
| 10445 | MaxVersion: VersionTLS13, |
| 10446 | }, |
| 10447 | }, |
| 10448 | }) |
| 10449 | |
| 10450 | ret = append(ret, perMessageTest{ |
| 10451 | messageType: typeCertificateVerify, |
| 10452 | test: testCase{ |
| 10453 | name: "TLS13-ServerCertificateVerify", |
| 10454 | config: Config{ |
| 10455 | MaxVersion: VersionTLS13, |
| 10456 | }, |
| 10457 | }, |
| 10458 | }) |
| 10459 | |
| 10460 | ret = append(ret, perMessageTest{ |
| 10461 | messageType: typeFinished, |
| 10462 | test: testCase{ |
| 10463 | name: "TLS13-ServerFinished", |
| 10464 | config: Config{ |
| 10465 | MaxVersion: VersionTLS13, |
| 10466 | }, |
| 10467 | }, |
| 10468 | }) |
| 10469 | |
| 10470 | ret = append(ret, perMessageTest{ |
| 10471 | messageType: typeCertificate, |
| 10472 | test: testCase{ |
| 10473 | testType: serverTest, |
| 10474 | name: "TLS13-ClientCertificate", |
| 10475 | config: Config{ |
| 10476 | Certificates: []Certificate{rsaCertificate}, |
| 10477 | MaxVersion: VersionTLS13, |
| 10478 | }, |
| 10479 | flags: []string{"-require-any-client-certificate"}, |
| 10480 | }, |
| 10481 | }) |
| 10482 | |
| 10483 | ret = append(ret, perMessageTest{ |
| 10484 | messageType: typeCertificateVerify, |
| 10485 | test: testCase{ |
| 10486 | testType: serverTest, |
| 10487 | name: "TLS13-ClientCertificateVerify", |
| 10488 | config: Config{ |
| 10489 | Certificates: []Certificate{rsaCertificate}, |
| 10490 | MaxVersion: VersionTLS13, |
| 10491 | }, |
| 10492 | flags: []string{"-require-any-client-certificate"}, |
| 10493 | }, |
| 10494 | }) |
| 10495 | |
| 10496 | ret = append(ret, perMessageTest{ |
| 10497 | messageType: typeFinished, |
| 10498 | test: testCase{ |
| 10499 | testType: serverTest, |
| 10500 | name: "TLS13-ClientFinished", |
| 10501 | config: Config{ |
| 10502 | MaxVersion: VersionTLS13, |
| 10503 | }, |
| 10504 | }, |
| 10505 | }) |
| 10506 | |
| 10507 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 10508 | } |
| 10509 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10510 | func addWrongMessageTypeTests() { |
| 10511 | for _, t := range makePerMessageTests() { |
| 10512 | t.test.name = "WrongMessageType-" + t.test.name |
| 10513 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 10514 | t.test.shouldFail = true |
| 10515 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 10516 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10517 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10518 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10519 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10520 | // an unencrypted alert while the server expects |
| 10521 | // encryption, so the alert is not readable by runner. |
| 10522 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10523 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10524 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 10525 | testCases = append(testCases, t.test) |
| 10526 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 10527 | |
| 10528 | // The processing order for TLS 1.3 version negotiation is such that one |
| 10529 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 10530 | // TLS 1.2. Test that we do not do this. |
| 10531 | testCases = append(testCases, testCase{ |
| 10532 | name: "SendServerHelloAsHelloRetryRequest", |
| 10533 | config: Config{ |
| 10534 | MaxVersion: VersionTLS12, |
| 10535 | Bugs: ProtocolBugs{ |
| 10536 | SendServerHelloAsHelloRetryRequest: true, |
| 10537 | }, |
| 10538 | }, |
| 10539 | shouldFail: true, |
| 10540 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10541 | expectedLocalError: "remote error: unexpected message", |
| 10542 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10543 | } |
| 10544 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 10545 | func addTrailingMessageDataTests() { |
| 10546 | for _, t := range makePerMessageTests() { |
| 10547 | t.test.name = "TrailingMessageData-" + t.test.name |
| 10548 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 10549 | t.test.shouldFail = true |
| 10550 | t.test.expectedError = ":DECODE_ERROR:" |
| 10551 | t.test.expectedLocalError = "remote error: error decoding message" |
| 10552 | |
| 10553 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 10554 | // In TLS 1.3, a bad ServerHello means the client sends |
| 10555 | // an unencrypted alert while the server expects |
| 10556 | // encryption, so the alert is not readable by runner. |
| 10557 | t.test.expectedLocalError = "local error: bad record MAC" |
| 10558 | } |
| 10559 | |
| 10560 | if t.messageType == typeFinished { |
| 10561 | // Bad Finished messages read as the verify data having |
| 10562 | // the wrong length. |
| 10563 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 10564 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 10565 | } |
| 10566 | |
| 10567 | testCases = append(testCases, t.test) |
| 10568 | } |
| 10569 | } |
| 10570 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10571 | func addTLS13HandshakeTests() { |
| 10572 | testCases = append(testCases, testCase{ |
| 10573 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10574 | name: "NegotiatePSKResumption-TLS13", |
| 10575 | config: Config{ |
| 10576 | MaxVersion: VersionTLS13, |
| 10577 | Bugs: ProtocolBugs{ |
| 10578 | NegotiatePSKResumption: true, |
| 10579 | }, |
| 10580 | }, |
| 10581 | resumeSession: true, |
| 10582 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10583 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 10584 | }) |
| 10585 | |
| 10586 | testCases = append(testCases, testCase{ |
| 10587 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10588 | name: "MissingKeyShare-Client", |
| 10589 | config: Config{ |
| 10590 | MaxVersion: VersionTLS13, |
| 10591 | Bugs: ProtocolBugs{ |
| 10592 | MissingKeyShare: true, |
| 10593 | }, |
| 10594 | }, |
| 10595 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 10596 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10597 | }) |
| 10598 | |
| 10599 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10600 | testType: serverTest, |
| 10601 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10602 | config: Config{ |
| 10603 | MaxVersion: VersionTLS13, |
| 10604 | Bugs: ProtocolBugs{ |
| 10605 | MissingKeyShare: true, |
| 10606 | }, |
| 10607 | }, |
| 10608 | shouldFail: true, |
| 10609 | expectedError: ":MISSING_KEY_SHARE:", |
| 10610 | }) |
| 10611 | |
| 10612 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10613 | testType: serverTest, |
| 10614 | name: "DuplicateKeyShares", |
| 10615 | config: Config{ |
| 10616 | MaxVersion: VersionTLS13, |
| 10617 | Bugs: ProtocolBugs{ |
| 10618 | DuplicateKeyShares: true, |
| 10619 | }, |
| 10620 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10621 | shouldFail: true, |
| 10622 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10623 | }) |
| 10624 | |
| 10625 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10626 | testType: serverTest, |
| 10627 | name: "SkipEarlyData", |
| 10628 | config: Config{ |
| 10629 | MaxVersion: VersionTLS13, |
| 10630 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10631 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10632 | }, |
| 10633 | }, |
| 10634 | }) |
| 10635 | |
| 10636 | testCases = append(testCases, testCase{ |
| 10637 | testType: serverTest, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 10638 | name: "SkipEarlyData-TLS13Experiment", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 10639 | config: Config{ |
| 10640 | MaxVersion: VersionTLS13, |
| 10641 | TLS13Variant: TLS13Experiment, |
| 10642 | Bugs: ProtocolBugs{ |
| 10643 | SendFakeEarlyDataLength: 4, |
| 10644 | }, |
| 10645 | }, |
| 10646 | flags: []string{"-tls13-variant", "1"}, |
| 10647 | }) |
| 10648 | |
| 10649 | testCases = append(testCases, testCase{ |
| 10650 | testType: serverTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 10651 | name: "SkipEarlyData-TLS13RecordTypeExperiment", |
| 10652 | config: Config{ |
| 10653 | MaxVersion: VersionTLS13, |
| 10654 | TLS13Variant: TLS13RecordTypeExperiment, |
| 10655 | Bugs: ProtocolBugs{ |
| 10656 | SendFakeEarlyDataLength: 4, |
| 10657 | }, |
| 10658 | }, |
| 10659 | flags: []string{"-tls13-variant", "2"}, |
| 10660 | }) |
| 10661 | |
| 10662 | testCases = append(testCases, testCase{ |
| 10663 | testType: serverTest, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10664 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 10665 | config: Config{ |
| 10666 | MaxVersion: VersionTLS13, |
| 10667 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10668 | SendFakeEarlyDataLength: 4, |
| 10669 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10670 | }, |
| 10671 | }, |
| 10672 | shouldFail: true, |
| 10673 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10674 | }) |
| 10675 | |
| 10676 | testCases = append(testCases, testCase{ |
| 10677 | testType: serverTest, |
| 10678 | name: "SkipEarlyData-TooMuchData", |
| 10679 | config: Config{ |
| 10680 | MaxVersion: VersionTLS13, |
| 10681 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10682 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10683 | }, |
| 10684 | }, |
| 10685 | shouldFail: true, |
| 10686 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10687 | }) |
| 10688 | |
| 10689 | testCases = append(testCases, testCase{ |
| 10690 | testType: serverTest, |
| 10691 | name: "SkipEarlyData-Interleaved", |
| 10692 | config: Config{ |
| 10693 | MaxVersion: VersionTLS13, |
| 10694 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10695 | SendFakeEarlyDataLength: 4, |
| 10696 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10697 | }, |
| 10698 | }, |
| 10699 | shouldFail: true, |
| 10700 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 10701 | }) |
| 10702 | |
| 10703 | testCases = append(testCases, testCase{ |
| 10704 | testType: serverTest, |
| 10705 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 10706 | config: Config{ |
| 10707 | MaxVersion: VersionTLS13, |
| 10708 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10709 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10710 | }, |
| 10711 | }, |
| 10712 | shouldFail: true, |
| 10713 | expectedError: ":UNEXPECTED_RECORD:", |
| 10714 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 10715 | }) |
| 10716 | |
| 10717 | testCases = append(testCases, testCase{ |
| 10718 | testType: serverTest, |
| 10719 | name: "SkipEarlyData-HRR", |
| 10720 | config: Config{ |
| 10721 | MaxVersion: VersionTLS13, |
| 10722 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10723 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10724 | }, |
| 10725 | DefaultCurves: []CurveID{}, |
| 10726 | }, |
| 10727 | }) |
| 10728 | |
| 10729 | testCases = append(testCases, testCase{ |
| 10730 | testType: serverTest, |
| 10731 | name: "SkipEarlyData-HRR-Interleaved", |
| 10732 | config: Config{ |
| 10733 | MaxVersion: VersionTLS13, |
| 10734 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10735 | SendFakeEarlyDataLength: 4, |
| 10736 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10737 | }, |
| 10738 | DefaultCurves: []CurveID{}, |
| 10739 | }, |
| 10740 | shouldFail: true, |
| 10741 | expectedError: ":UNEXPECTED_RECORD:", |
| 10742 | }) |
| 10743 | |
| 10744 | testCases = append(testCases, testCase{ |
| 10745 | testType: serverTest, |
| 10746 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10747 | config: Config{ |
| 10748 | MaxVersion: VersionTLS13, |
| 10749 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10750 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10751 | }, |
| 10752 | DefaultCurves: []CurveID{}, |
| 10753 | }, |
| 10754 | shouldFail: true, |
| 10755 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10756 | }) |
| 10757 | |
| 10758 | // Test that skipping early data looking for cleartext correctly |
| 10759 | // processes an alert record. |
| 10760 | testCases = append(testCases, testCase{ |
| 10761 | testType: serverTest, |
| 10762 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10763 | config: Config{ |
| 10764 | MaxVersion: VersionTLS13, |
| 10765 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10766 | SendEarlyAlert: true, |
| 10767 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10768 | }, |
| 10769 | DefaultCurves: []CurveID{}, |
| 10770 | }, |
| 10771 | shouldFail: true, |
| 10772 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10773 | }) |
| 10774 | |
| 10775 | testCases = append(testCases, testCase{ |
| 10776 | testType: serverTest, |
| 10777 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10778 | config: Config{ |
| 10779 | MaxVersion: VersionTLS13, |
| 10780 | Bugs: ProtocolBugs{ |
| 10781 | SendEarlyDataOnSecondClientHello: true, |
| 10782 | }, |
| 10783 | DefaultCurves: []CurveID{}, |
| 10784 | }, |
| 10785 | shouldFail: true, |
| 10786 | expectedLocalError: "remote error: bad record MAC", |
| 10787 | }) |
| 10788 | |
| 10789 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10790 | testType: clientTest, |
| 10791 | name: "EmptyEncryptedExtensions", |
| 10792 | config: Config{ |
| 10793 | MaxVersion: VersionTLS13, |
| 10794 | Bugs: ProtocolBugs{ |
| 10795 | EmptyEncryptedExtensions: true, |
| 10796 | }, |
| 10797 | }, |
| 10798 | shouldFail: true, |
| 10799 | expectedLocalError: "remote error: error decoding message", |
| 10800 | }) |
| 10801 | |
| 10802 | testCases = append(testCases, testCase{ |
| 10803 | testType: clientTest, |
| 10804 | name: "EncryptedExtensionsWithKeyShare", |
| 10805 | config: Config{ |
| 10806 | MaxVersion: VersionTLS13, |
| 10807 | Bugs: ProtocolBugs{ |
| 10808 | EncryptedExtensionsWithKeyShare: true, |
| 10809 | }, |
| 10810 | }, |
| 10811 | shouldFail: true, |
| 10812 | expectedLocalError: "remote error: unsupported extension", |
| 10813 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10814 | |
| 10815 | testCases = append(testCases, testCase{ |
| 10816 | testType: serverTest, |
| 10817 | name: "SendHelloRetryRequest", |
| 10818 | config: Config{ |
| 10819 | MaxVersion: VersionTLS13, |
| 10820 | // Require a HelloRetryRequest for every curve. |
| 10821 | DefaultCurves: []CurveID{}, |
| 10822 | }, |
| 10823 | expectedCurveID: CurveX25519, |
| 10824 | }) |
| 10825 | |
| 10826 | testCases = append(testCases, testCase{ |
| 10827 | testType: serverTest, |
| 10828 | name: "SendHelloRetryRequest-2", |
| 10829 | config: Config{ |
| 10830 | MaxVersion: VersionTLS13, |
| 10831 | DefaultCurves: []CurveID{CurveP384}, |
| 10832 | }, |
| 10833 | // Although the ClientHello did not predict our preferred curve, |
| 10834 | // we always select it whether it is predicted or not. |
| 10835 | expectedCurveID: CurveX25519, |
| 10836 | }) |
| 10837 | |
| 10838 | testCases = append(testCases, testCase{ |
| 10839 | name: "UnknownCurve-HelloRetryRequest", |
| 10840 | config: Config{ |
| 10841 | MaxVersion: VersionTLS13, |
| 10842 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10843 | CurvePreferences: []CurveID{CurveP384}, |
| 10844 | Bugs: ProtocolBugs{ |
| 10845 | SendHelloRetryRequestCurve: bogusCurve, |
| 10846 | }, |
| 10847 | }, |
| 10848 | shouldFail: true, |
| 10849 | expectedError: ":WRONG_CURVE:", |
| 10850 | }) |
| 10851 | |
| 10852 | testCases = append(testCases, testCase{ |
| 10853 | name: "DisabledCurve-HelloRetryRequest", |
| 10854 | config: Config{ |
| 10855 | MaxVersion: VersionTLS13, |
| 10856 | CurvePreferences: []CurveID{CurveP256}, |
| 10857 | Bugs: ProtocolBugs{ |
| 10858 | IgnorePeerCurvePreferences: true, |
| 10859 | }, |
| 10860 | }, |
| 10861 | flags: []string{"-p384-only"}, |
| 10862 | shouldFail: true, |
| 10863 | expectedError: ":WRONG_CURVE:", |
| 10864 | }) |
| 10865 | |
| 10866 | testCases = append(testCases, testCase{ |
| 10867 | name: "UnnecessaryHelloRetryRequest", |
| 10868 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10869 | MaxVersion: VersionTLS13, |
| 10870 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10871 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10872 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10873 | }, |
| 10874 | }, |
| 10875 | shouldFail: true, |
| 10876 | expectedError: ":WRONG_CURVE:", |
| 10877 | }) |
| 10878 | |
| 10879 | testCases = append(testCases, testCase{ |
| 10880 | name: "SecondHelloRetryRequest", |
| 10881 | config: Config{ |
| 10882 | MaxVersion: VersionTLS13, |
| 10883 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10884 | CurvePreferences: []CurveID{CurveP384}, |
| 10885 | Bugs: ProtocolBugs{ |
| 10886 | SecondHelloRetryRequest: true, |
| 10887 | }, |
| 10888 | }, |
| 10889 | shouldFail: true, |
| 10890 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10891 | }) |
| 10892 | |
| 10893 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10894 | name: "HelloRetryRequest-Empty", |
| 10895 | config: Config{ |
| 10896 | MaxVersion: VersionTLS13, |
| 10897 | Bugs: ProtocolBugs{ |
| 10898 | AlwaysSendHelloRetryRequest: true, |
| 10899 | }, |
| 10900 | }, |
| 10901 | shouldFail: true, |
| 10902 | expectedError: ":DECODE_ERROR:", |
| 10903 | }) |
| 10904 | |
| 10905 | testCases = append(testCases, testCase{ |
| 10906 | name: "HelloRetryRequest-DuplicateCurve", |
| 10907 | config: Config{ |
| 10908 | MaxVersion: VersionTLS13, |
| 10909 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 10910 | // configuration. Assert this ExpectMissingKeyShare. |
| 10911 | CurvePreferences: []CurveID{CurveP384}, |
| 10912 | Bugs: ProtocolBugs{ |
| 10913 | ExpectMissingKeyShare: true, |
| 10914 | DuplicateHelloRetryRequestExtensions: true, |
| 10915 | }, |
| 10916 | }, |
| 10917 | shouldFail: true, |
| 10918 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10919 | expectedLocalError: "remote error: illegal parameter", |
| 10920 | }) |
| 10921 | |
| 10922 | testCases = append(testCases, testCase{ |
| 10923 | name: "HelloRetryRequest-Cookie", |
| 10924 | config: Config{ |
| 10925 | MaxVersion: VersionTLS13, |
| 10926 | Bugs: ProtocolBugs{ |
| 10927 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10928 | }, |
| 10929 | }, |
| 10930 | }) |
| 10931 | |
| 10932 | testCases = append(testCases, testCase{ |
| 10933 | name: "HelloRetryRequest-DuplicateCookie", |
| 10934 | config: Config{ |
| 10935 | MaxVersion: VersionTLS13, |
| 10936 | Bugs: ProtocolBugs{ |
| 10937 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10938 | DuplicateHelloRetryRequestExtensions: true, |
| 10939 | }, |
| 10940 | }, |
| 10941 | shouldFail: true, |
| 10942 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10943 | expectedLocalError: "remote error: illegal parameter", |
| 10944 | }) |
| 10945 | |
| 10946 | testCases = append(testCases, testCase{ |
| 10947 | name: "HelloRetryRequest-EmptyCookie", |
| 10948 | config: Config{ |
| 10949 | MaxVersion: VersionTLS13, |
| 10950 | Bugs: ProtocolBugs{ |
| 10951 | SendHelloRetryRequestCookie: []byte{}, |
| 10952 | }, |
| 10953 | }, |
| 10954 | shouldFail: true, |
| 10955 | expectedError: ":DECODE_ERROR:", |
| 10956 | }) |
| 10957 | |
| 10958 | testCases = append(testCases, testCase{ |
| 10959 | name: "HelloRetryRequest-Cookie-Curve", |
| 10960 | config: Config{ |
| 10961 | MaxVersion: VersionTLS13, |
| 10962 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10963 | CurvePreferences: []CurveID{CurveP384}, |
| 10964 | Bugs: ProtocolBugs{ |
| 10965 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10966 | ExpectMissingKeyShare: true, |
| 10967 | }, |
| 10968 | }, |
| 10969 | }) |
| 10970 | |
| 10971 | testCases = append(testCases, testCase{ |
| 10972 | name: "HelloRetryRequest-Unknown", |
| 10973 | config: Config{ |
| 10974 | MaxVersion: VersionTLS13, |
| 10975 | Bugs: ProtocolBugs{ |
| 10976 | CustomHelloRetryRequestExtension: "extension", |
| 10977 | }, |
| 10978 | }, |
| 10979 | shouldFail: true, |
| 10980 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10981 | expectedLocalError: "remote error: unsupported extension", |
| 10982 | }) |
| 10983 | |
| 10984 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10985 | testType: serverTest, |
| 10986 | name: "SecondClientHelloMissingKeyShare", |
| 10987 | config: Config{ |
| 10988 | MaxVersion: VersionTLS13, |
| 10989 | DefaultCurves: []CurveID{}, |
| 10990 | Bugs: ProtocolBugs{ |
| 10991 | SecondClientHelloMissingKeyShare: true, |
| 10992 | }, |
| 10993 | }, |
| 10994 | shouldFail: true, |
| 10995 | expectedError: ":MISSING_KEY_SHARE:", |
| 10996 | }) |
| 10997 | |
| 10998 | testCases = append(testCases, testCase{ |
| 10999 | testType: serverTest, |
| 11000 | name: "SecondClientHelloWrongCurve", |
| 11001 | config: Config{ |
| 11002 | MaxVersion: VersionTLS13, |
| 11003 | DefaultCurves: []CurveID{}, |
| 11004 | Bugs: ProtocolBugs{ |
| 11005 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 11006 | }, |
| 11007 | }, |
| 11008 | shouldFail: true, |
| 11009 | expectedError: ":WRONG_CURVE:", |
| 11010 | }) |
| 11011 | |
| 11012 | testCases = append(testCases, testCase{ |
| 11013 | name: "HelloRetryRequestVersionMismatch", |
| 11014 | config: Config{ |
| 11015 | MaxVersion: VersionTLS13, |
| 11016 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11017 | CurvePreferences: []CurveID{CurveP384}, |
| 11018 | Bugs: ProtocolBugs{ |
| 11019 | SendServerHelloVersion: 0x0305, |
| 11020 | }, |
| 11021 | }, |
| 11022 | shouldFail: true, |
| 11023 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11024 | }) |
| 11025 | |
| 11026 | testCases = append(testCases, testCase{ |
| 11027 | name: "HelloRetryRequestCurveMismatch", |
| 11028 | config: Config{ |
| 11029 | MaxVersion: VersionTLS13, |
| 11030 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11031 | CurvePreferences: []CurveID{CurveP384}, |
| 11032 | Bugs: ProtocolBugs{ |
| 11033 | // Send P-384 (correct) in the HelloRetryRequest. |
| 11034 | SendHelloRetryRequestCurve: CurveP384, |
| 11035 | // But send P-256 in the ServerHello. |
| 11036 | SendCurve: CurveP256, |
| 11037 | }, |
| 11038 | }, |
| 11039 | shouldFail: true, |
| 11040 | expectedError: ":WRONG_CURVE:", |
| 11041 | }) |
| 11042 | |
| 11043 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 11044 | // without sending it. |
| 11045 | testCases = append(testCases, testCase{ |
| 11046 | name: "SkipHelloRetryRequest", |
| 11047 | config: Config{ |
| 11048 | MaxVersion: VersionTLS13, |
| 11049 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 11050 | CurvePreferences: []CurveID{CurveP384}, |
| 11051 | Bugs: ProtocolBugs{ |
| 11052 | SkipHelloRetryRequest: true, |
| 11053 | }, |
| 11054 | }, |
| 11055 | shouldFail: true, |
| 11056 | expectedError: ":WRONG_CURVE:", |
| 11057 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 11058 | |
| 11059 | testCases = append(testCases, testCase{ |
| 11060 | name: "TLS13-RequestContextInHandshake", |
| 11061 | config: Config{ |
| 11062 | MaxVersion: VersionTLS13, |
| 11063 | MinVersion: VersionTLS13, |
| 11064 | ClientAuth: RequireAnyClientCert, |
| 11065 | Bugs: ProtocolBugs{ |
| 11066 | SendRequestContext: []byte("request context"), |
| 11067 | }, |
| 11068 | }, |
| 11069 | flags: []string{ |
| 11070 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11071 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 11072 | }, |
| 11073 | shouldFail: true, |
| 11074 | expectedError: ":DECODE_ERROR:", |
| 11075 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 11076 | |
| 11077 | testCases = append(testCases, testCase{ |
| 11078 | testType: serverTest, |
| 11079 | name: "TLS13-TrailingKeyShareData", |
| 11080 | config: Config{ |
| 11081 | MaxVersion: VersionTLS13, |
| 11082 | Bugs: ProtocolBugs{ |
| 11083 | TrailingKeyShareData: true, |
| 11084 | }, |
| 11085 | }, |
| 11086 | shouldFail: true, |
| 11087 | expectedError: ":DECODE_ERROR:", |
| 11088 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 11089 | |
| 11090 | testCases = append(testCases, testCase{ |
| 11091 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 11092 | config: Config{ |
| 11093 | MaxVersion: VersionTLS13, |
| 11094 | Bugs: ProtocolBugs{ |
| 11095 | AlwaysSelectPSKIdentity: true, |
| 11096 | }, |
| 11097 | }, |
| 11098 | shouldFail: true, |
| 11099 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11100 | }) |
| 11101 | |
| 11102 | testCases = append(testCases, testCase{ |
| 11103 | name: "TLS13-InvalidPSKIdentity", |
| 11104 | config: Config{ |
| 11105 | MaxVersion: VersionTLS13, |
| 11106 | Bugs: ProtocolBugs{ |
| 11107 | SelectPSKIdentityOnResume: 1, |
| 11108 | }, |
| 11109 | }, |
| 11110 | resumeSession: true, |
| 11111 | shouldFail: true, |
| 11112 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 11113 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11114 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11115 | testCases = append(testCases, testCase{ |
| 11116 | testType: serverTest, |
| 11117 | name: "TLS13-ExtraPSKIdentity", |
| 11118 | config: Config{ |
| 11119 | MaxVersion: VersionTLS13, |
| 11120 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 11121 | ExtraPSKIdentity: true, |
| 11122 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 11123 | }, |
| 11124 | }, |
| 11125 | resumeSession: true, |
| 11126 | }) |
| 11127 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 11128 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 11129 | testCases = append(testCases, testCase{ |
| 11130 | name: "TLS13-CustomTicketExtension", |
| 11131 | config: Config{ |
| 11132 | MaxVersion: VersionTLS13, |
| 11133 | Bugs: ProtocolBugs{ |
| 11134 | CustomTicketExtension: "1234", |
| 11135 | }, |
| 11136 | }, |
| 11137 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11138 | |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11139 | for _, noSessionID := range []bool{false, true} { |
| 11140 | prefix := "TLS13Experiment" |
| 11141 | variant := TLS13Experiment |
| 11142 | if noSessionID { |
| 11143 | prefix = "TLS13NoSessionIDExperiment" |
| 11144 | variant = TLS13NoSessionIDExperiment |
| 11145 | } |
| 11146 | |
| 11147 | // Test that enabling a TLS 1.3 variant does not interfere with |
| 11148 | // TLS 1.2 session ID resumption. |
| 11149 | testCases = append(testCases, testCase{ |
| 11150 | testType: clientTest, |
| 11151 | name: prefix + "-ResumeTLS12SessionID", |
| 11152 | config: Config{ |
| 11153 | MaxVersion: VersionTLS12, |
| 11154 | SessionTicketsDisabled: true, |
| 11155 | }, |
| 11156 | resumeSession: true, |
| 11157 | flags: []string{"-tls13-variant", strconv.Itoa(variant)}, |
| 11158 | }) |
| 11159 | |
| 11160 | // Test that the server correctly echoes back session IDs of |
| 11161 | // various lengths. |
| 11162 | testCases = append(testCases, testCase{ |
| 11163 | testType: serverTest, |
| 11164 | name: prefix + "-EmptySessionID", |
| 11165 | config: Config{ |
| 11166 | MaxVersion: VersionTLS13, |
| 11167 | Bugs: ProtocolBugs{ |
| 11168 | SendClientHelloSessionID: []byte{}, |
| 11169 | }, |
| 11170 | }, |
| 11171 | tls13Variant: variant, |
| 11172 | }) |
| 11173 | |
| 11174 | testCases = append(testCases, testCase{ |
| 11175 | testType: serverTest, |
| 11176 | name: prefix + "-ShortSessionID", |
| 11177 | config: Config{ |
| 11178 | MaxVersion: VersionTLS13, |
| 11179 | Bugs: ProtocolBugs{ |
| 11180 | SendClientHelloSessionID: make([]byte, 16), |
| 11181 | }, |
| 11182 | }, |
| 11183 | tls13Variant: variant, |
| 11184 | }) |
| 11185 | |
| 11186 | testCases = append(testCases, testCase{ |
| 11187 | testType: serverTest, |
| 11188 | name: prefix + "-FullSessionID", |
| 11189 | config: Config{ |
| 11190 | MaxVersion: VersionTLS13, |
| 11191 | Bugs: ProtocolBugs{ |
| 11192 | SendClientHelloSessionID: make([]byte, 32), |
| 11193 | }, |
| 11194 | }, |
| 11195 | tls13Variant: variant, |
| 11196 | }) |
| 11197 | } |
| 11198 | |
| 11199 | // Test that the client sends a fake session ID in TLS13Experiment. |
| 11200 | testCases = append(testCases, testCase{ |
| 11201 | testType: clientTest, |
| 11202 | name: "TLS13Experiment-RequireSessionID", |
| 11203 | config: Config{ |
| 11204 | MaxVersion: VersionTLS13, |
| 11205 | Bugs: ProtocolBugs{ |
| 11206 | ExpectClientHelloSessionID: true, |
| 11207 | }, |
| 11208 | }, |
| 11209 | tls13Variant: TLS13Experiment, |
| 11210 | }) |
| 11211 | |
| 11212 | // Test that the client does not send a fake session ID in |
| 11213 | // TLS13NoSessionIDExperiment. |
| 11214 | testCases = append(testCases, testCase{ |
| 11215 | testType: clientTest, |
| 11216 | name: "TLS13NoSessionIDExperiment-RequireEmptySessionID", |
| 11217 | config: Config{ |
| 11218 | MaxVersion: VersionTLS13, |
| 11219 | Bugs: ProtocolBugs{ |
| 11220 | ExpectEmptyClientHelloSessionID: true, |
| 11221 | }, |
| 11222 | }, |
| 11223 | tls13Variant: TLS13NoSessionIDExperiment, |
| 11224 | }) |
| 11225 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11226 | testCases = append(testCases, testCase{ |
| 11227 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11228 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11229 | config: Config{ |
| 11230 | MaxVersion: VersionTLS13, |
| 11231 | MaxEarlyDataSize: 16384, |
| 11232 | }, |
| 11233 | resumeConfig: &Config{ |
| 11234 | MaxVersion: VersionTLS13, |
| 11235 | MaxEarlyDataSize: 16384, |
| 11236 | Bugs: ProtocolBugs{ |
| 11237 | AlwaysRejectEarlyData: true, |
| 11238 | }, |
| 11239 | }, |
| 11240 | resumeSession: true, |
| 11241 | flags: []string{ |
| 11242 | "-enable-early-data", |
| 11243 | "-expect-early-data-info", |
| 11244 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11245 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11246 | }, |
| 11247 | }) |
| 11248 | |
| 11249 | testCases = append(testCases, testCase{ |
| 11250 | testType: clientTest, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11251 | name: "TLS13Experiment-EarlyData-Reject-Client", |
| 11252 | config: Config{ |
| 11253 | MaxVersion: VersionTLS13, |
| 11254 | MaxEarlyDataSize: 16384, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11255 | }, |
| 11256 | resumeConfig: &Config{ |
| 11257 | MaxVersion: VersionTLS13, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11258 | MaxEarlyDataSize: 16384, |
| 11259 | Bugs: ProtocolBugs{ |
| 11260 | AlwaysRejectEarlyData: true, |
| 11261 | }, |
| 11262 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11263 | tls13Variant: TLS13Experiment, |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11264 | resumeSession: true, |
| 11265 | flags: []string{ |
| 11266 | "-enable-early-data", |
| 11267 | "-expect-early-data-info", |
| 11268 | "-expect-reject-early-data", |
| 11269 | "-on-resume-shim-writes-first", |
Steven Valdez | 520e122 | 2017-06-13 12:45:25 -0400 | [diff] [blame] | 11270 | }, |
| 11271 | }) |
| 11272 | |
| 11273 | testCases = append(testCases, testCase{ |
| 11274 | testType: clientTest, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11275 | name: "TLS13RecordTypeExperiment-EarlyData-Reject-Client", |
| 11276 | config: Config{ |
| 11277 | MaxVersion: VersionTLS13, |
| 11278 | MaxEarlyDataSize: 16384, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11279 | }, |
| 11280 | resumeConfig: &Config{ |
| 11281 | MaxVersion: VersionTLS13, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11282 | MaxEarlyDataSize: 16384, |
| 11283 | Bugs: ProtocolBugs{ |
| 11284 | AlwaysRejectEarlyData: true, |
| 11285 | }, |
| 11286 | }, |
Steven Valdez | 0e4a448 | 2017-07-17 11:12:34 -0400 | [diff] [blame] | 11287 | tls13Variant: TLS13RecordTypeExperiment, |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11288 | resumeSession: true, |
| 11289 | flags: []string{ |
| 11290 | "-enable-early-data", |
| 11291 | "-expect-early-data-info", |
| 11292 | "-expect-reject-early-data", |
| 11293 | "-on-resume-shim-writes-first", |
Steven Valdez | dbe0158 | 2017-07-14 10:39:28 -0400 | [diff] [blame] | 11294 | }, |
| 11295 | }) |
| 11296 | |
| 11297 | testCases = append(testCases, testCase{ |
| 11298 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11299 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 11300 | config: Config{ |
| 11301 | MaxVersion: VersionTLS13, |
| 11302 | MaxEarlyDataSize: 16384, |
| 11303 | Certificates: []Certificate{rsaCertificate}, |
| 11304 | }, |
| 11305 | resumeConfig: &Config{ |
| 11306 | MaxVersion: VersionTLS13, |
| 11307 | MaxEarlyDataSize: 16384, |
| 11308 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 11309 | SessionTicketsDisabled: true, |
| 11310 | }, |
| 11311 | resumeSession: true, |
| 11312 | expectResumeRejected: true, |
| 11313 | flags: []string{ |
| 11314 | "-enable-early-data", |
| 11315 | "-expect-early-data-info", |
| 11316 | "-expect-reject-early-data", |
| 11317 | "-on-resume-shim-writes-first", |
| 11318 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11319 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 11320 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 11321 | // Session tickets are disabled, so the runner will not send a ticket. |
| 11322 | "-on-retry-expect-no-session", |
| 11323 | }, |
| 11324 | }) |
| 11325 | |
| 11326 | testCases = append(testCases, testCase{ |
| 11327 | testType: clientTest, |
| 11328 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11329 | config: Config{ |
| 11330 | MaxVersion: VersionTLS13, |
| 11331 | MaxEarlyDataSize: 16384, |
| 11332 | }, |
| 11333 | resumeConfig: &Config{ |
| 11334 | MaxVersion: VersionTLS13, |
| 11335 | MaxEarlyDataSize: 16384, |
| 11336 | Bugs: ProtocolBugs{ |
| 11337 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11338 | }, |
| 11339 | }, |
| 11340 | resumeSession: true, |
| 11341 | flags: []string{ |
| 11342 | "-enable-early-data", |
| 11343 | "-expect-early-data-info", |
| 11344 | "-expect-reject-early-data", |
| 11345 | }, |
| 11346 | }) |
| 11347 | |
| 11348 | // The client must check the server does not send the early_data |
| 11349 | // extension while rejecting the session. |
| 11350 | testCases = append(testCases, testCase{ |
| 11351 | testType: clientTest, |
| 11352 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 11353 | config: Config{ |
| 11354 | MaxVersion: VersionTLS13, |
| 11355 | MaxEarlyDataSize: 16384, |
| 11356 | }, |
| 11357 | resumeConfig: &Config{ |
| 11358 | MaxVersion: VersionTLS13, |
| 11359 | SessionTicketsDisabled: true, |
| 11360 | Bugs: ProtocolBugs{ |
| 11361 | SendEarlyDataExtension: true, |
| 11362 | }, |
| 11363 | }, |
| 11364 | resumeSession: true, |
| 11365 | flags: []string{ |
| 11366 | "-enable-early-data", |
| 11367 | "-expect-early-data-info", |
| 11368 | }, |
| 11369 | shouldFail: true, |
| 11370 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11371 | }) |
| 11372 | |
| 11373 | // The client must fail with a dedicated error code if the server |
| 11374 | // responds with TLS 1.2 when offering 0-RTT. |
| 11375 | testCases = append(testCases, testCase{ |
| 11376 | testType: clientTest, |
| 11377 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 11378 | config: Config{ |
| 11379 | MaxVersion: VersionTLS13, |
| 11380 | MaxEarlyDataSize: 16384, |
| 11381 | }, |
| 11382 | resumeConfig: &Config{ |
| 11383 | MaxVersion: VersionTLS12, |
| 11384 | }, |
| 11385 | resumeSession: true, |
| 11386 | flags: []string{ |
| 11387 | "-enable-early-data", |
| 11388 | "-expect-early-data-info", |
| 11389 | }, |
| 11390 | shouldFail: true, |
| 11391 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 11392 | }) |
| 11393 | |
| 11394 | // Test that the client rejects an (unsolicited) early_data extension if |
| 11395 | // the server sent an HRR. |
| 11396 | testCases = append(testCases, testCase{ |
| 11397 | testType: clientTest, |
| 11398 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 11399 | config: Config{ |
| 11400 | MaxVersion: VersionTLS13, |
| 11401 | MaxEarlyDataSize: 16384, |
| 11402 | }, |
| 11403 | resumeConfig: &Config{ |
| 11404 | MaxVersion: VersionTLS13, |
| 11405 | MaxEarlyDataSize: 16384, |
| 11406 | Bugs: ProtocolBugs{ |
| 11407 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 11408 | SendEarlyDataExtension: true, |
| 11409 | }, |
| 11410 | }, |
| 11411 | resumeSession: true, |
| 11412 | flags: []string{ |
| 11413 | "-enable-early-data", |
| 11414 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11415 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11416 | }, |
| 11417 | shouldFail: true, |
| 11418 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 11419 | }) |
| 11420 | |
| 11421 | fooString := "foo" |
| 11422 | barString := "bar" |
| 11423 | |
| 11424 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 11425 | // that changed it. |
| 11426 | testCases = append(testCases, testCase{ |
| 11427 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11428 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11429 | config: Config{ |
| 11430 | MaxVersion: VersionTLS13, |
| 11431 | MaxEarlyDataSize: 16384, |
| 11432 | Bugs: ProtocolBugs{ |
| 11433 | ALPNProtocol: &fooString, |
| 11434 | }, |
| 11435 | }, |
| 11436 | resumeConfig: &Config{ |
| 11437 | MaxVersion: VersionTLS13, |
| 11438 | MaxEarlyDataSize: 16384, |
| 11439 | Bugs: ProtocolBugs{ |
| 11440 | ALPNProtocol: &barString, |
| 11441 | }, |
| 11442 | }, |
| 11443 | resumeSession: true, |
| 11444 | flags: []string{ |
| 11445 | "-advertise-alpn", "\x03foo\x03bar", |
| 11446 | "-enable-early-data", |
| 11447 | "-expect-early-data-info", |
| 11448 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11449 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11450 | "-on-resume-expect-alpn", "foo", |
| 11451 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11452 | }, |
| 11453 | }) |
| 11454 | |
| 11455 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11456 | // ALPN was omitted from the first connection. |
| 11457 | testCases = append(testCases, testCase{ |
| 11458 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11459 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11460 | config: Config{ |
| 11461 | MaxVersion: VersionTLS13, |
| 11462 | MaxEarlyDataSize: 16384, |
| 11463 | }, |
| 11464 | resumeConfig: &Config{ |
| 11465 | MaxVersion: VersionTLS13, |
| 11466 | MaxEarlyDataSize: 16384, |
| 11467 | NextProtos: []string{"foo"}, |
| 11468 | }, |
| 11469 | resumeSession: true, |
| 11470 | flags: []string{ |
| 11471 | "-advertise-alpn", "\x03foo\x03bar", |
| 11472 | "-enable-early-data", |
| 11473 | "-expect-early-data-info", |
| 11474 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11475 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11476 | "-on-resume-expect-alpn", "", |
| 11477 | "-on-retry-expect-alpn", "foo", |
| 11478 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11479 | }, |
| 11480 | }) |
| 11481 | |
| 11482 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 11483 | // ALPN was omitted from the second connection. |
| 11484 | testCases = append(testCases, testCase{ |
| 11485 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11486 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11487 | config: Config{ |
| 11488 | MaxVersion: VersionTLS13, |
| 11489 | MaxEarlyDataSize: 16384, |
| 11490 | NextProtos: []string{"foo"}, |
| 11491 | }, |
| 11492 | resumeConfig: &Config{ |
| 11493 | MaxVersion: VersionTLS13, |
| 11494 | MaxEarlyDataSize: 16384, |
| 11495 | }, |
| 11496 | resumeSession: true, |
| 11497 | flags: []string{ |
| 11498 | "-advertise-alpn", "\x03foo\x03bar", |
| 11499 | "-enable-early-data", |
| 11500 | "-expect-early-data-info", |
| 11501 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11502 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11503 | "-on-resume-expect-alpn", "foo", |
| 11504 | "-on-retry-expect-alpn", "", |
| 11505 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11506 | }, |
| 11507 | }) |
| 11508 | |
| 11509 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 11510 | testCases = append(testCases, testCase{ |
| 11511 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11512 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11513 | config: Config{ |
| 11514 | MaxVersion: VersionTLS13, |
| 11515 | MaxEarlyDataSize: 16384, |
| 11516 | Bugs: ProtocolBugs{ |
| 11517 | ALPNProtocol: &fooString, |
| 11518 | }, |
| 11519 | }, |
| 11520 | resumeConfig: &Config{ |
| 11521 | MaxVersion: VersionTLS13, |
| 11522 | MaxEarlyDataSize: 16384, |
| 11523 | Bugs: ProtocolBugs{ |
| 11524 | AlwaysAcceptEarlyData: true, |
| 11525 | ALPNProtocol: &barString, |
| 11526 | }, |
| 11527 | }, |
| 11528 | resumeSession: true, |
| 11529 | flags: []string{ |
| 11530 | "-advertise-alpn", "\x03foo\x03bar", |
| 11531 | "-enable-early-data", |
| 11532 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11533 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 11534 | "-on-resume-expect-alpn", "foo", |
| 11535 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11536 | }, |
| 11537 | shouldFail: true, |
| 11538 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 11539 | }) |
| 11540 | |
| 11541 | // Test that the server correctly rejects 0-RTT when the previous |
| 11542 | // session did not allow early data on resumption. |
| 11543 | testCases = append(testCases, testCase{ |
| 11544 | testType: serverTest, |
| 11545 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 11546 | config: Config{ |
| 11547 | MaxVersion: VersionTLS13, |
| 11548 | }, |
| 11549 | resumeConfig: &Config{ |
| 11550 | MaxVersion: VersionTLS13, |
| 11551 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11552 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11553 | ExpectEarlyDataAccepted: false, |
| 11554 | }, |
| 11555 | }, |
| 11556 | resumeSession: true, |
| 11557 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11558 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11559 | "-expect-reject-early-data", |
| 11560 | }, |
| 11561 | }) |
| 11562 | |
| 11563 | // Test that we reject early data where ALPN is omitted from the first |
| 11564 | // connection. |
| 11565 | testCases = append(testCases, testCase{ |
| 11566 | testType: serverTest, |
| 11567 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 11568 | config: Config{ |
| 11569 | MaxVersion: VersionTLS13, |
| 11570 | NextProtos: []string{}, |
| 11571 | }, |
| 11572 | resumeConfig: &Config{ |
| 11573 | MaxVersion: VersionTLS13, |
| 11574 | NextProtos: []string{"foo"}, |
| 11575 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11576 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11577 | ExpectEarlyDataAccepted: false, |
| 11578 | }, |
| 11579 | }, |
| 11580 | resumeSession: true, |
| 11581 | flags: []string{ |
| 11582 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11583 | "-on-initial-select-alpn", "", |
| 11584 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11585 | }, |
| 11586 | }) |
| 11587 | |
| 11588 | // Test that we reject early data where ALPN is omitted from the second |
| 11589 | // connection. |
| 11590 | testCases = append(testCases, testCase{ |
| 11591 | testType: serverTest, |
| 11592 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 11593 | config: Config{ |
| 11594 | MaxVersion: VersionTLS13, |
| 11595 | NextProtos: []string{"foo"}, |
| 11596 | }, |
| 11597 | resumeConfig: &Config{ |
| 11598 | MaxVersion: VersionTLS13, |
| 11599 | NextProtos: []string{}, |
| 11600 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11601 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11602 | ExpectEarlyDataAccepted: false, |
| 11603 | }, |
| 11604 | }, |
| 11605 | resumeSession: true, |
| 11606 | flags: []string{ |
| 11607 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11608 | "-on-initial-select-alpn", "foo", |
| 11609 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11610 | }, |
| 11611 | }) |
| 11612 | |
| 11613 | // Test that we reject early data with mismatched ALPN. |
| 11614 | testCases = append(testCases, testCase{ |
| 11615 | testType: serverTest, |
| 11616 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 11617 | config: Config{ |
| 11618 | MaxVersion: VersionTLS13, |
| 11619 | NextProtos: []string{"foo"}, |
| 11620 | }, |
| 11621 | resumeConfig: &Config{ |
| 11622 | MaxVersion: VersionTLS13, |
| 11623 | NextProtos: []string{"bar"}, |
| 11624 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11625 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11626 | ExpectEarlyDataAccepted: false, |
| 11627 | }, |
| 11628 | }, |
| 11629 | resumeSession: true, |
| 11630 | flags: []string{ |
| 11631 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11632 | "-on-initial-select-alpn", "foo", |
| 11633 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 11634 | }, |
| 11635 | }) |
| 11636 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11637 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 11638 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11639 | testCases = append(testCases, testCase{ |
| 11640 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11641 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11642 | config: Config{ |
| 11643 | MaxVersion: VersionTLS13, |
| 11644 | MaxEarlyDataSize: 16384, |
| 11645 | RequestChannelID: true, |
| 11646 | }, |
| 11647 | resumeSession: true, |
| 11648 | expectChannelID: true, |
| 11649 | shouldFail: true, |
| 11650 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 11651 | flags: []string{ |
| 11652 | "-enable-early-data", |
| 11653 | "-expect-early-data-info", |
| 11654 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11655 | }, |
| 11656 | }) |
| 11657 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11658 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11659 | // to decline 0-RTT. |
| 11660 | testCases = append(testCases, testCase{ |
| 11661 | testType: clientTest, |
| 11662 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 11663 | config: Config{ |
| 11664 | MaxVersion: VersionTLS13, |
| 11665 | MaxEarlyDataSize: 16384, |
| 11666 | RequestChannelID: true, |
| 11667 | Bugs: ProtocolBugs{ |
| 11668 | AlwaysRejectEarlyData: true, |
| 11669 | }, |
| 11670 | }, |
| 11671 | resumeSession: true, |
| 11672 | expectChannelID: true, |
| 11673 | flags: []string{ |
| 11674 | "-enable-early-data", |
| 11675 | "-expect-early-data-info", |
| 11676 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11677 | "-expect-reject-early-data", |
| 11678 | }, |
| 11679 | }) |
| 11680 | |
| 11681 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 11682 | // to decline Channel ID. |
| 11683 | testCases = append(testCases, testCase{ |
| 11684 | testType: clientTest, |
| 11685 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 11686 | config: Config{ |
| 11687 | MaxVersion: VersionTLS13, |
| 11688 | MaxEarlyDataSize: 16384, |
| 11689 | }, |
| 11690 | resumeSession: true, |
| 11691 | flags: []string{ |
| 11692 | "-enable-early-data", |
| 11693 | "-expect-early-data-info", |
| 11694 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 11695 | "-expect-accept-early-data", |
| 11696 | }, |
| 11697 | }) |
| 11698 | |
| 11699 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 11700 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11701 | testCases = append(testCases, testCase{ |
| 11702 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11703 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11704 | config: Config{ |
| 11705 | MaxVersion: VersionTLS13, |
| 11706 | ChannelID: channelIDKey, |
| 11707 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11708 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 11709 | ExpectEarlyDataAccepted: false, |
| 11710 | }, |
| 11711 | }, |
| 11712 | resumeSession: true, |
| 11713 | expectChannelID: true, |
| 11714 | flags: []string{ |
| 11715 | "-enable-early-data", |
| 11716 | "-expect-reject-early-data", |
| 11717 | "-expect-channel-id", |
| 11718 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 11719 | }, |
| 11720 | }) |
| 11721 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 11722 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 11723 | // if not offered Channel ID. |
| 11724 | testCases = append(testCases, testCase{ |
| 11725 | testType: serverTest, |
| 11726 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 11727 | config: Config{ |
| 11728 | MaxVersion: VersionTLS13, |
| 11729 | Bugs: ProtocolBugs{ |
| 11730 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11731 | ExpectEarlyDataAccepted: true, |
| 11732 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11733 | }, |
| 11734 | }, |
| 11735 | resumeSession: true, |
| 11736 | expectChannelID: false, |
| 11737 | flags: []string{ |
| 11738 | "-enable-early-data", |
| 11739 | "-expect-accept-early-data", |
| 11740 | "-enable-channel-id", |
| 11741 | }, |
| 11742 | }) |
| 11743 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11744 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 11745 | // The subsequent records should fail to decrypt. |
| 11746 | testCases = append(testCases, testCase{ |
| 11747 | testType: serverTest, |
| 11748 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 11749 | config: Config{ |
| 11750 | MaxVersion: VersionTLS13, |
| 11751 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11752 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 11753 | ExpectEarlyDataAccepted: true, |
| 11754 | SkipEndOfEarlyData: true, |
| 11755 | }, |
| 11756 | }, |
| 11757 | resumeSession: true, |
| 11758 | flags: []string{"-enable-early-data"}, |
| 11759 | shouldFail: true, |
| 11760 | expectedLocalError: "remote error: bad record MAC", |
| 11761 | expectedError: ":BAD_DECRYPT:", |
| 11762 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 11763 | |
| 11764 | testCases = append(testCases, testCase{ |
| 11765 | testType: serverTest, |
| 11766 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 11767 | config: Config{ |
| 11768 | MaxVersion: VersionTLS13, |
| 11769 | }, |
| 11770 | resumeConfig: &Config{ |
| 11771 | MaxVersion: VersionTLS13, |
| 11772 | Bugs: ProtocolBugs{ |
| 11773 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11774 | SendStrayEarlyHandshake: true, |
| 11775 | ExpectEarlyDataAccepted: true}, |
| 11776 | }, |
| 11777 | resumeSession: true, |
| 11778 | shouldFail: true, |
| 11779 | expectedError: ":UNEXPECTED_RECORD:", |
| 11780 | expectedLocalError: "remote error: unexpected message", |
| 11781 | flags: []string{ |
| 11782 | "-enable-early-data", |
| 11783 | }, |
| 11784 | }) |
David Benjamin | d9cbb53 | 2017-07-07 13:17:19 -0400 | [diff] [blame] | 11785 | |
| 11786 | // Test that the client reports TLS 1.3 as the version while sending |
| 11787 | // early data. |
| 11788 | testCases = append(testCases, testCase{ |
| 11789 | testType: clientTest, |
| 11790 | name: "TLS13-EarlyData-Client-VersionAPI", |
| 11791 | config: Config{ |
| 11792 | MaxVersion: VersionTLS13, |
| 11793 | MaxEarlyDataSize: 16384, |
| 11794 | }, |
| 11795 | resumeSession: true, |
| 11796 | flags: []string{ |
| 11797 | "-enable-early-data", |
| 11798 | "-expect-early-data-info", |
| 11799 | "-expect-accept-early-data", |
| 11800 | "-expect-version", strconv.Itoa(VersionTLS13), |
| 11801 | }, |
| 11802 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11803 | } |
| 11804 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11805 | func addTLS13CipherPreferenceTests() { |
| 11806 | // Test that client preference is honored if the shim has AES hardware |
| 11807 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 11808 | testCases = append(testCases, testCase{ |
| 11809 | testType: serverTest, |
| 11810 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 11811 | config: Config{ |
| 11812 | MaxVersion: VersionTLS13, |
| 11813 | CipherSuites: []uint16{ |
| 11814 | TLS_CHACHA20_POLY1305_SHA256, |
| 11815 | TLS_AES_128_GCM_SHA256, |
| 11816 | }, |
| 11817 | }, |
| 11818 | flags: []string{ |
| 11819 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11820 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11821 | }, |
| 11822 | }) |
| 11823 | |
| 11824 | testCases = append(testCases, testCase{ |
| 11825 | testType: serverTest, |
| 11826 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 11827 | config: Config{ |
| 11828 | MaxVersion: VersionTLS13, |
| 11829 | CipherSuites: []uint16{ |
| 11830 | TLS_AES_128_GCM_SHA256, |
| 11831 | TLS_CHACHA20_POLY1305_SHA256, |
| 11832 | }, |
| 11833 | }, |
| 11834 | flags: []string{ |
| 11835 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11836 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11837 | }, |
| 11838 | }) |
| 11839 | |
| 11840 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 11841 | // whether it has AES hardware. |
| 11842 | testCases = append(testCases, testCase{ |
| 11843 | name: "TLS13-CipherPreference-Client", |
| 11844 | config: Config{ |
| 11845 | MaxVersion: VersionTLS13, |
| 11846 | // Use the client cipher order. (This is the default but |
| 11847 | // is listed to be explicit.) |
| 11848 | PreferServerCipherSuites: false, |
| 11849 | }, |
| 11850 | flags: []string{ |
| 11851 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 11852 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 11853 | }, |
| 11854 | }) |
| 11855 | } |
| 11856 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11857 | func addPeekTests() { |
| 11858 | // Test SSL_peek works, including on empty records. |
| 11859 | testCases = append(testCases, testCase{ |
| 11860 | name: "Peek-Basic", |
| 11861 | sendEmptyRecords: 1, |
| 11862 | flags: []string{"-peek-then-read"}, |
| 11863 | }) |
| 11864 | |
| 11865 | // Test SSL_peek can drive the initial handshake. |
| 11866 | testCases = append(testCases, testCase{ |
| 11867 | name: "Peek-ImplicitHandshake", |
| 11868 | flags: []string{ |
| 11869 | "-peek-then-read", |
| 11870 | "-implicit-handshake", |
| 11871 | }, |
| 11872 | }) |
| 11873 | |
| 11874 | // Test SSL_peek can discover and drive a renegotiation. |
| 11875 | testCases = append(testCases, testCase{ |
| 11876 | name: "Peek-Renegotiate", |
| 11877 | config: Config{ |
| 11878 | MaxVersion: VersionTLS12, |
| 11879 | }, |
| 11880 | renegotiate: 1, |
| 11881 | flags: []string{ |
| 11882 | "-peek-then-read", |
| 11883 | "-renegotiate-freely", |
| 11884 | "-expect-total-renegotiations", "1", |
| 11885 | }, |
| 11886 | }) |
| 11887 | |
| 11888 | // Test SSL_peek can discover a close_notify. |
| 11889 | testCases = append(testCases, testCase{ |
| 11890 | name: "Peek-Shutdown", |
| 11891 | config: Config{ |
| 11892 | Bugs: ProtocolBugs{ |
| 11893 | ExpectCloseNotify: true, |
| 11894 | }, |
| 11895 | }, |
| 11896 | flags: []string{ |
| 11897 | "-peek-then-read", |
| 11898 | "-check-close-notify", |
| 11899 | }, |
| 11900 | }) |
| 11901 | |
| 11902 | // Test SSL_peek can discover an alert. |
| 11903 | testCases = append(testCases, testCase{ |
| 11904 | name: "Peek-Alert", |
| 11905 | config: Config{ |
| 11906 | Bugs: ProtocolBugs{ |
| 11907 | SendSpuriousAlert: alertRecordOverflow, |
| 11908 | }, |
| 11909 | }, |
| 11910 | flags: []string{"-peek-then-read"}, |
| 11911 | shouldFail: true, |
| 11912 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 11913 | }) |
| 11914 | |
| 11915 | // Test SSL_peek can handle KeyUpdate. |
| 11916 | testCases = append(testCases, testCase{ |
| 11917 | name: "Peek-KeyUpdate", |
| 11918 | config: Config{ |
| 11919 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11920 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 11921 | sendKeyUpdates: 1, |
| 11922 | keyUpdateRequest: keyUpdateNotRequested, |
| 11923 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11924 | }) |
| 11925 | } |
| 11926 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11927 | func addRecordVersionTests() { |
| 11928 | for _, ver := range tlsVersions { |
| 11929 | // Test that the record version is enforced. |
| 11930 | testCases = append(testCases, testCase{ |
| 11931 | name: "CheckRecordVersion-" + ver.name, |
| 11932 | config: Config{ |
| 11933 | MinVersion: ver.version, |
| 11934 | MaxVersion: ver.version, |
| 11935 | Bugs: ProtocolBugs{ |
| 11936 | SendRecordVersion: 0x03ff, |
| 11937 | }, |
| 11938 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11939 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11940 | shouldFail: true, |
| 11941 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11942 | }) |
| 11943 | |
| 11944 | // Test that the ClientHello may use any record version, for |
| 11945 | // compatibility reasons. |
| 11946 | testCases = append(testCases, testCase{ |
| 11947 | testType: serverTest, |
| 11948 | name: "LooseInitialRecordVersion-" + ver.name, |
| 11949 | config: Config{ |
| 11950 | MinVersion: ver.version, |
| 11951 | MaxVersion: ver.version, |
| 11952 | Bugs: ProtocolBugs{ |
| 11953 | SendInitialRecordVersion: 0x03ff, |
| 11954 | }, |
| 11955 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11956 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11957 | }) |
| 11958 | |
| 11959 | // Test that garbage ClientHello record versions are rejected. |
| 11960 | testCases = append(testCases, testCase{ |
| 11961 | testType: serverTest, |
| 11962 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 11963 | config: Config{ |
| 11964 | MinVersion: ver.version, |
| 11965 | MaxVersion: ver.version, |
| 11966 | Bugs: ProtocolBugs{ |
| 11967 | SendInitialRecordVersion: 0xffff, |
| 11968 | }, |
| 11969 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11970 | tls13Variant: ver.tls13Variant, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11971 | shouldFail: true, |
| 11972 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11973 | }) |
| 11974 | } |
| 11975 | } |
| 11976 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11977 | func addCertificateTests() { |
| 11978 | // Test that a certificate chain with intermediate may be sent and |
| 11979 | // received as both client and server. |
| 11980 | for _, ver := range tlsVersions { |
| 11981 | testCases = append(testCases, testCase{ |
| 11982 | testType: clientTest, |
| 11983 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 11984 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11985 | MinVersion: ver.version, |
| 11986 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11987 | Certificates: []Certificate{rsaChainCertificate}, |
| 11988 | ClientAuth: RequireAnyClientCert, |
| 11989 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 11990 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11991 | expectPeerCertificate: &rsaChainCertificate, |
| 11992 | flags: []string{ |
| 11993 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11994 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11995 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11996 | }, |
| 11997 | }) |
| 11998 | |
| 11999 | testCases = append(testCases, testCase{ |
| 12000 | testType: serverTest, |
| 12001 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 12002 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 12003 | MinVersion: ver.version, |
| 12004 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12005 | Certificates: []Certificate{rsaChainCertificate}, |
| 12006 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12007 | tls13Variant: ver.tls13Variant, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12008 | expectPeerCertificate: &rsaChainCertificate, |
| 12009 | flags: []string{ |
| 12010 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12011 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 12012 | "-require-any-client-certificate", |
| 12013 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 12014 | }, |
| 12015 | }) |
| 12016 | } |
| 12017 | } |
| 12018 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12019 | func addRetainOnlySHA256ClientCertTests() { |
| 12020 | for _, ver := range tlsVersions { |
| 12021 | // Test that enabling |
| 12022 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 12023 | // actually requesting a client certificate is a no-op. |
| 12024 | testCases = append(testCases, testCase{ |
| 12025 | testType: serverTest, |
| 12026 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 12027 | config: Config{ |
| 12028 | MinVersion: ver.version, |
| 12029 | MaxVersion: ver.version, |
| 12030 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12031 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12032 | flags: []string{ |
| 12033 | "-retain-only-sha256-client-cert-initial", |
| 12034 | "-retain-only-sha256-client-cert-resume", |
| 12035 | }, |
| 12036 | resumeSession: true, |
| 12037 | }) |
| 12038 | |
| 12039 | // Test that when retaining only a SHA-256 certificate is |
| 12040 | // enabled, the hash appears as expected. |
| 12041 | testCases = append(testCases, testCase{ |
| 12042 | testType: serverTest, |
| 12043 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 12044 | config: Config{ |
| 12045 | MinVersion: ver.version, |
| 12046 | MaxVersion: ver.version, |
| 12047 | Certificates: []Certificate{rsaCertificate}, |
| 12048 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12049 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12050 | flags: []string{ |
| 12051 | "-verify-peer", |
| 12052 | "-retain-only-sha256-client-cert-initial", |
| 12053 | "-retain-only-sha256-client-cert-resume", |
| 12054 | "-expect-sha256-client-cert-initial", |
| 12055 | "-expect-sha256-client-cert-resume", |
| 12056 | }, |
| 12057 | resumeSession: true, |
| 12058 | }) |
| 12059 | |
| 12060 | // Test that when the config changes from on to off, a |
| 12061 | // resumption is rejected because the server now wants the full |
| 12062 | // certificate chain. |
| 12063 | testCases = append(testCases, testCase{ |
| 12064 | testType: serverTest, |
| 12065 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 12066 | config: Config{ |
| 12067 | MinVersion: ver.version, |
| 12068 | MaxVersion: ver.version, |
| 12069 | Certificates: []Certificate{rsaCertificate}, |
| 12070 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12071 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12072 | flags: []string{ |
| 12073 | "-verify-peer", |
| 12074 | "-retain-only-sha256-client-cert-initial", |
| 12075 | "-expect-sha256-client-cert-initial", |
| 12076 | }, |
| 12077 | resumeSession: true, |
| 12078 | expectResumeRejected: true, |
| 12079 | }) |
| 12080 | |
| 12081 | // Test that when the config changes from off to on, a |
| 12082 | // resumption is rejected because the server now wants just the |
| 12083 | // hash. |
| 12084 | testCases = append(testCases, testCase{ |
| 12085 | testType: serverTest, |
| 12086 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 12087 | config: Config{ |
| 12088 | MinVersion: ver.version, |
| 12089 | MaxVersion: ver.version, |
| 12090 | Certificates: []Certificate{rsaCertificate}, |
| 12091 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12092 | tls13Variant: ver.tls13Variant, |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12093 | flags: []string{ |
| 12094 | "-verify-peer", |
| 12095 | "-retain-only-sha256-client-cert-resume", |
| 12096 | "-expect-sha256-client-cert-resume", |
| 12097 | }, |
| 12098 | resumeSession: true, |
| 12099 | expectResumeRejected: true, |
| 12100 | }) |
| 12101 | } |
| 12102 | } |
| 12103 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12104 | func addECDSAKeyUsageTests() { |
| 12105 | p256 := elliptic.P256() |
| 12106 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 12107 | if err != nil { |
| 12108 | panic(err) |
| 12109 | } |
| 12110 | |
| 12111 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 12112 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 12113 | if err != nil { |
| 12114 | panic(err) |
| 12115 | } |
| 12116 | |
| 12117 | template := x509.Certificate{ |
| 12118 | SerialNumber: serialNumber, |
| 12119 | Subject: pkix.Name{ |
| 12120 | Organization: []string{"Acme Co"}, |
| 12121 | }, |
| 12122 | NotBefore: time.Now(), |
| 12123 | NotAfter: time.Now(), |
| 12124 | |
| 12125 | // An ECC certificate with only the keyAgreement key usgae may |
| 12126 | // be used with ECDH, but not ECDSA. |
| 12127 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 12128 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 12129 | BasicConstraintsValid: true, |
| 12130 | } |
| 12131 | |
| 12132 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 12133 | if err != nil { |
| 12134 | panic(err) |
| 12135 | } |
| 12136 | |
| 12137 | cert := Certificate{ |
| 12138 | Certificate: [][]byte{derBytes}, |
| 12139 | PrivateKey: priv, |
| 12140 | } |
| 12141 | |
| 12142 | for _, ver := range tlsVersions { |
| 12143 | if ver.version < VersionTLS12 { |
| 12144 | continue |
| 12145 | } |
| 12146 | |
| 12147 | testCases = append(testCases, testCase{ |
| 12148 | testType: clientTest, |
| 12149 | name: "ECDSAKeyUsage-" + ver.name, |
| 12150 | config: Config{ |
| 12151 | MinVersion: ver.version, |
| 12152 | MaxVersion: ver.version, |
| 12153 | Certificates: []Certificate{cert}, |
| 12154 | }, |
David Benjamin | a502239 | 2017-07-10 17:40:39 -0400 | [diff] [blame] | 12155 | tls13Variant: ver.tls13Variant, |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12156 | shouldFail: true, |
| 12157 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 12158 | }) |
| 12159 | } |
| 12160 | } |
| 12161 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12162 | func addExtraHandshakeTests() { |
| 12163 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 12164 | // to ensure there is no transport I/O. |
| 12165 | testCases = append(testCases, testCase{ |
| 12166 | testType: clientTest, |
| 12167 | name: "ExtraHandshake-Client-TLS12", |
| 12168 | config: Config{ |
| 12169 | MinVersion: VersionTLS12, |
| 12170 | MaxVersion: VersionTLS12, |
| 12171 | }, |
| 12172 | flags: []string{ |
| 12173 | "-async", |
| 12174 | "-no-op-extra-handshake", |
| 12175 | }, |
| 12176 | }) |
| 12177 | testCases = append(testCases, testCase{ |
| 12178 | testType: serverTest, |
| 12179 | name: "ExtraHandshake-Server-TLS12", |
| 12180 | config: Config{ |
| 12181 | MinVersion: VersionTLS12, |
| 12182 | MaxVersion: VersionTLS12, |
| 12183 | }, |
| 12184 | flags: []string{ |
| 12185 | "-async", |
| 12186 | "-no-op-extra-handshake", |
| 12187 | }, |
| 12188 | }) |
| 12189 | testCases = append(testCases, testCase{ |
| 12190 | testType: clientTest, |
| 12191 | name: "ExtraHandshake-Client-TLS13", |
| 12192 | config: Config{ |
| 12193 | MinVersion: VersionTLS13, |
| 12194 | MaxVersion: VersionTLS13, |
| 12195 | }, |
| 12196 | flags: []string{ |
| 12197 | "-async", |
| 12198 | "-no-op-extra-handshake", |
| 12199 | }, |
| 12200 | }) |
| 12201 | testCases = append(testCases, testCase{ |
| 12202 | testType: serverTest, |
| 12203 | name: "ExtraHandshake-Server-TLS13", |
| 12204 | config: Config{ |
| 12205 | MinVersion: VersionTLS13, |
| 12206 | MaxVersion: VersionTLS13, |
| 12207 | }, |
| 12208 | flags: []string{ |
| 12209 | "-async", |
| 12210 | "-no-op-extra-handshake", |
| 12211 | }, |
| 12212 | }) |
| 12213 | |
| 12214 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 12215 | testCases = append(testCases, testCase{ |
| 12216 | testType: serverTest, |
| 12217 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 12218 | config: Config{ |
| 12219 | MaxVersion: VersionTLS13, |
| 12220 | MinVersion: VersionTLS13, |
| 12221 | Bugs: ProtocolBugs{ |
| 12222 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 12223 | ExpectEarlyDataAccepted: true, |
| 12224 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 12225 | }, |
| 12226 | }, |
| 12227 | messageCount: 2, |
| 12228 | resumeSession: true, |
| 12229 | flags: []string{ |
| 12230 | "-async", |
| 12231 | "-enable-early-data", |
| 12232 | "-expect-accept-early-data", |
| 12233 | "-no-op-extra-handshake", |
| 12234 | }, |
| 12235 | }) |
| 12236 | |
| 12237 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 12238 | // Start. We test this by handshaking twice and asserting the False |
| 12239 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 12240 | // how the test works. |
| 12241 | testCases = append(testCases, testCase{ |
| 12242 | testType: clientTest, |
| 12243 | name: "ExtraHandshake-FalseStart", |
| 12244 | config: Config{ |
| 12245 | MaxVersion: VersionTLS12, |
| 12246 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 12247 | NextProtos: []string{"foo"}, |
| 12248 | Bugs: ProtocolBugs{ |
| 12249 | ExpectFalseStart: true, |
| 12250 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 12251 | }, |
| 12252 | }, |
| 12253 | flags: []string{ |
| 12254 | "-handshake-twice", |
| 12255 | "-false-start", |
| 12256 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 12257 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12258 | }, |
| 12259 | shimWritesFirst: true, |
| 12260 | shouldFail: true, |
| 12261 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 12262 | expectedLocalError: "tls: peer did not false start: EOF", |
| 12263 | }) |
| 12264 | } |
| 12265 | |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12266 | // Test that omitted and empty extensions blocks are tolerated. |
| 12267 | func addOmitExtensionsTests() { |
| 12268 | for _, ver := range tlsVersions { |
| 12269 | if ver.version > VersionTLS12 { |
| 12270 | continue |
| 12271 | } |
| 12272 | |
| 12273 | testCases = append(testCases, testCase{ |
| 12274 | testType: serverTest, |
| 12275 | name: "OmitExtensions-ClientHello-" + ver.name, |
| 12276 | config: Config{ |
| 12277 | MinVersion: ver.version, |
| 12278 | MaxVersion: ver.version, |
| 12279 | SessionTicketsDisabled: true, |
| 12280 | Bugs: ProtocolBugs{ |
| 12281 | OmitExtensions: true, |
| 12282 | }, |
| 12283 | }, |
| 12284 | }) |
| 12285 | |
| 12286 | testCases = append(testCases, testCase{ |
| 12287 | testType: serverTest, |
| 12288 | name: "EmptyExtensions-ClientHello-" + ver.name, |
| 12289 | config: Config{ |
| 12290 | MinVersion: ver.version, |
| 12291 | MaxVersion: ver.version, |
| 12292 | SessionTicketsDisabled: true, |
| 12293 | Bugs: ProtocolBugs{ |
| 12294 | EmptyExtensions: true, |
| 12295 | }, |
| 12296 | }, |
| 12297 | }) |
| 12298 | |
| 12299 | testCases = append(testCases, testCase{ |
| 12300 | testType: clientTest, |
| 12301 | name: "OmitExtensions-ServerHello-" + ver.name, |
| 12302 | config: Config{ |
| 12303 | MinVersion: ver.version, |
| 12304 | MaxVersion: ver.version, |
| 12305 | SessionTicketsDisabled: true, |
| 12306 | Bugs: ProtocolBugs{ |
| 12307 | OmitExtensions: true, |
| 12308 | // Disable all ServerHello extensions so |
| 12309 | // OmitExtensions works. |
| 12310 | NoExtendedMasterSecret: true, |
| 12311 | NoRenegotiationInfo: true, |
| 12312 | }, |
| 12313 | }, |
| 12314 | }) |
| 12315 | |
| 12316 | testCases = append(testCases, testCase{ |
| 12317 | testType: clientTest, |
| 12318 | name: "EmptyExtensions-ServerHello-" + ver.name, |
| 12319 | config: Config{ |
| 12320 | MinVersion: ver.version, |
| 12321 | MaxVersion: ver.version, |
| 12322 | SessionTicketsDisabled: true, |
| 12323 | Bugs: ProtocolBugs{ |
| 12324 | EmptyExtensions: true, |
| 12325 | // Disable all ServerHello extensions so |
| 12326 | // EmptyExtensions works. |
| 12327 | NoExtendedMasterSecret: true, |
| 12328 | NoRenegotiationInfo: true, |
| 12329 | }, |
| 12330 | }, |
| 12331 | }) |
| 12332 | } |
| 12333 | } |
| 12334 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12335 | 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] | 12336 | defer wg.Done() |
| 12337 | |
| 12338 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12339 | var err error |
| 12340 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12341 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12342 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 12343 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12344 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12345 | if err != nil { |
| 12346 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 12347 | } |
| 12348 | break |
| 12349 | } |
| 12350 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12351 | } else if *repeatUntilFailure { |
| 12352 | for err == nil { |
| 12353 | statusChan <- statusMsg{test: test, started: true} |
| 12354 | err = runTest(test, shimPath, -1) |
| 12355 | } |
| 12356 | } else { |
| 12357 | statusChan <- statusMsg{test: test, started: true} |
| 12358 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 12359 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12360 | statusChan <- statusMsg{test: test, err: err} |
| 12361 | } |
| 12362 | } |
| 12363 | |
| 12364 | type statusMsg struct { |
| 12365 | test *testCase |
| 12366 | started bool |
| 12367 | err error |
| 12368 | } |
| 12369 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12370 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12371 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12372 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12373 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12374 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12375 | if !*pipe { |
| 12376 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 12377 | var erase string |
| 12378 | for i := 0; i < lineLen; i++ { |
| 12379 | erase += "\b \b" |
| 12380 | } |
| 12381 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12382 | } |
| 12383 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12384 | if msg.started { |
| 12385 | started++ |
| 12386 | } else { |
| 12387 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12388 | |
| 12389 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12390 | if msg.err == errUnimplemented { |
| 12391 | if *pipe { |
| 12392 | // Print each test instead of a status line. |
| 12393 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 12394 | } |
| 12395 | unimplemented++ |
| 12396 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 12397 | } else { |
| 12398 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 12399 | failed++ |
| 12400 | testOutput.addResult(msg.test.name, "FAIL") |
| 12401 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12402 | } else { |
| 12403 | if *pipe { |
| 12404 | // Print each test instead of a status line. |
| 12405 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 12406 | } |
| 12407 | testOutput.addResult(msg.test.name, "PASS") |
| 12408 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12409 | } |
| 12410 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12411 | if !*pipe { |
| 12412 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12413 | 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] | 12414 | lineLen = len(line) |
| 12415 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12416 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12417 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12418 | |
| 12419 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12420 | } |
| 12421 | |
| 12422 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12423 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12424 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 12425 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12426 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12427 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12428 | addCipherSuiteTests() |
| 12429 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12430 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 12431 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 12432 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 12433 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 12434 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 12435 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 12436 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 12437 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 12438 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 12439 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 12440 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 12441 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 12442 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 12443 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 12444 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 12445 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 12446 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 12447 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 12448 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 12449 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 12450 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 12451 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 12452 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 12453 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 12454 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 12455 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 12456 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 12457 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 12458 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 12459 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 12460 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 12461 | addExtraHandshakeTests() |
David Benjamin | b853f31 | 2017-07-14 18:40:34 -0400 | [diff] [blame] | 12462 | addOmitExtensionsTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12463 | |
| 12464 | var wg sync.WaitGroup |
| 12465 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12466 | statusChan := make(chan statusMsg, *numWorkers) |
| 12467 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12468 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12469 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12470 | if len(*shimConfigFile) != 0 { |
| 12471 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 12472 | if err != nil { |
| 12473 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 12474 | os.Exit(1) |
| 12475 | } |
| 12476 | |
| 12477 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 12478 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 12479 | os.Exit(1) |
| 12480 | } |
| 12481 | } |
| 12482 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12483 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12484 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12485 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12486 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 12487 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12488 | } |
| 12489 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12490 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12491 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12492 | matched := true |
| 12493 | if len(*testToRun) != 0 { |
| 12494 | var err error |
| 12495 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 12496 | if err != nil { |
| 12497 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 12498 | os.Exit(1) |
| 12499 | } |
| 12500 | } |
| 12501 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12502 | if !*includeDisabled { |
| 12503 | for pattern := range shimConfig.DisabledTests { |
| 12504 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 12505 | if err != nil { |
| 12506 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 12507 | os.Exit(1) |
| 12508 | } |
| 12509 | |
| 12510 | if isDisabled { |
| 12511 | matched = false |
| 12512 | break |
| 12513 | } |
| 12514 | } |
| 12515 | } |
| 12516 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12517 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12518 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 12519 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 12520 | |
| 12521 | // Only run one test if repeating until failure. |
| 12522 | if *repeatUntilFailure { |
| 12523 | break |
| 12524 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12525 | } |
| 12526 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 12527 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12528 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 12529 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 12530 | os.Exit(1) |
| 12531 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12532 | |
| 12533 | close(testChan) |
| 12534 | wg.Wait() |
| 12535 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12536 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12537 | |
| 12538 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 12539 | |
| 12540 | if *jsonOutput != "" { |
| 12541 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 12542 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 12543 | } |
| 12544 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12545 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 12546 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 12547 | os.Exit(1) |
| 12548 | } |
| 12549 | |
| 12550 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 12551 | os.Exit(1) |
| 12552 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 12553 | } |