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 | |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 266 | // encodeDERValues encodes a series of bytestrings in comma-separated-hex form. |
| 267 | func encodeDERValues(values [][]byte) string { |
| 268 | var ret string |
| 269 | for i, v := range values { |
| 270 | if i > 0 { |
| 271 | ret += "," |
| 272 | } |
| 273 | ret += hex.EncodeToString(v) |
| 274 | } |
| 275 | |
| 276 | return ret |
| 277 | } |
| 278 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 279 | type testType int |
| 280 | |
| 281 | const ( |
| 282 | clientTest testType = iota |
| 283 | serverTest |
| 284 | ) |
| 285 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 286 | type protocol int |
| 287 | |
| 288 | const ( |
| 289 | tls protocol = iota |
| 290 | dtls |
| 291 | ) |
| 292 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 293 | const ( |
| 294 | alpn = 1 |
| 295 | npn = 2 |
| 296 | ) |
| 297 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 298 | type testCase struct { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 299 | testType testType |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 300 | protocol protocol |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 301 | name string |
| 302 | config Config |
| 303 | shouldFail bool |
| 304 | expectedError string |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 305 | // expectedLocalError, if not empty, contains a substring that must be |
| 306 | // found in the local error. |
| 307 | expectedLocalError string |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 308 | // expectedVersion, if non-zero, specifies the TLS version that must be |
| 309 | // negotiated. |
| 310 | expectedVersion uint16 |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 311 | // expectedResumeVersion, if non-zero, specifies the TLS version that |
| 312 | // must be negotiated on resumption. If zero, expectedVersion is used. |
| 313 | expectedResumeVersion uint16 |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 314 | // expectedCipher, if non-zero, specifies the TLS cipher suite that |
| 315 | // should be negotiated. |
| 316 | expectedCipher uint16 |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 317 | // expectChannelID controls whether the connection should have |
| 318 | // negotiated a Channel ID with channelIDKey. |
| 319 | expectChannelID bool |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 320 | // expectedNextProto controls whether the connection should |
| 321 | // negotiate a next protocol via NPN or ALPN. |
| 322 | expectedNextProto string |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 323 | // expectNoNextProto, if true, means that no next protocol should be |
| 324 | // negotiated. |
| 325 | expectNoNextProto bool |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 326 | // expectedNextProtoType, if non-zero, is the expected next |
| 327 | // protocol negotiation mechanism. |
| 328 | expectedNextProtoType int |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 329 | // expectedSRTPProtectionProfile is the DTLS-SRTP profile that |
| 330 | // should be negotiated. If zero, none should be negotiated. |
| 331 | expectedSRTPProtectionProfile uint16 |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 332 | // expectedOCSPResponse, if not nil, is the expected OCSP response to be received. |
| 333 | expectedOCSPResponse []uint8 |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 334 | // expectedSCTList, if not nil, is the expected SCT list to be received. |
| 335 | expectedSCTList []uint8 |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 336 | // expectedPeerSignatureAlgorithm, if not zero, is the signature |
| 337 | // algorithm that the peer should have used in the handshake. |
| 338 | expectedPeerSignatureAlgorithm signatureAlgorithm |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 339 | // expectedCurveID, if not zero, is the curve that the handshake should |
| 340 | // have used. |
| 341 | expectedCurveID CurveID |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 342 | // messageLen is the length, in bytes, of the test message that will be |
| 343 | // sent. |
| 344 | messageLen int |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 345 | // messageCount is the number of test messages that will be sent. |
| 346 | messageCount int |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 347 | // certFile is the path to the certificate to use for the server. |
| 348 | certFile string |
| 349 | // keyFile is the path to the private key to use for the server. |
| 350 | keyFile string |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 351 | // resumeSession controls whether a second connection should be tested |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 352 | // which attempts to resume the first session. |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 353 | resumeSession bool |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 354 | // resumeRenewedSession controls whether a third connection should be |
| 355 | // tested which attempts to resume the second connection's session. |
| 356 | resumeRenewedSession bool |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 357 | // expectResumeRejected, if true, specifies that the attempted |
| 358 | // resumption must be rejected by the client. This is only valid for a |
| 359 | // serverTest. |
| 360 | expectResumeRejected bool |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 361 | // resumeConfig, if not nil, points to a Config to be used on |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 362 | // resumption. Unless newSessionsOnResume is set, |
| 363 | // SessionTicketKey, ServerSessionCache, and |
| 364 | // ClientSessionCache are copied from the initial connection's |
| 365 | // config. If nil, the initial connection's config is used. |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 366 | resumeConfig *Config |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 367 | // newSessionsOnResume, if true, will cause resumeConfig to |
| 368 | // use a different session resumption context. |
| 369 | newSessionsOnResume bool |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 370 | // noSessionCache, if true, will cause the server to run without a |
| 371 | // session cache. |
| 372 | noSessionCache bool |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 373 | // sendPrefix sends a prefix on the socket before actually performing a |
| 374 | // handshake. |
| 375 | sendPrefix string |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 376 | // shimWritesFirst controls whether the shim sends an initial "hello" |
| 377 | // message before doing a roundtrip with the runner. |
| 378 | shimWritesFirst bool |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 379 | // readWithUnfinishedWrite behaves like shimWritesFirst, but the shim |
| 380 | // does not complete the write until responding to the first runner |
| 381 | // message. |
| 382 | readWithUnfinishedWrite bool |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 383 | // shimShutsDown, if true, runs a test where the shim shuts down the |
| 384 | // connection immediately after the handshake rather than echoing |
| 385 | // messages from the runner. |
| 386 | shimShutsDown bool |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 387 | // renegotiate indicates the number of times the connection should be |
| 388 | // renegotiated during the exchange. |
| 389 | renegotiate int |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 390 | // sendHalfHelloRequest, if true, causes the server to send half a |
| 391 | // HelloRequest when the handshake completes. |
| 392 | sendHalfHelloRequest bool |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 393 | // renegotiateCiphers is a list of ciphersuite ids that will be |
| 394 | // switched in just before renegotiation. |
| 395 | renegotiateCiphers []uint16 |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 396 | // replayWrites, if true, configures the underlying transport |
| 397 | // to replay every write it makes in DTLS tests. |
| 398 | replayWrites bool |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 399 | // damageFirstWrite, if true, configures the underlying transport to |
| 400 | // damage the final byte of the first application data write. |
| 401 | damageFirstWrite bool |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 402 | // exportKeyingMaterial, if non-zero, configures the test to exchange |
| 403 | // keying material and verify they match. |
| 404 | exportKeyingMaterial int |
| 405 | exportLabel string |
| 406 | exportContext string |
| 407 | useExportContext bool |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 408 | // flags, if not empty, contains a list of command-line flags that will |
| 409 | // be passed to the shim program. |
| 410 | flags []string |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 411 | // testTLSUnique, if true, causes the shim to send the tls-unique value |
| 412 | // which will be compared against the expected value. |
| 413 | testTLSUnique bool |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 414 | // sendEmptyRecords is the number of consecutive empty records to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 415 | // before each test message. |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 416 | sendEmptyRecords int |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 417 | // sendWarningAlerts is the number of consecutive warning alerts to send |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 418 | // before each test message. |
David Benjamin | 24f346d | 2015-06-06 03:28:08 -0400 | [diff] [blame] | 419 | sendWarningAlerts int |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 420 | // sendBogusAlertType, if true, causes a bogus alert of invalid type to |
| 421 | // be sent before each test message. |
| 422 | sendBogusAlertType bool |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 423 | // sendKeyUpdates is the number of consecutive key updates to send |
| 424 | // before and after the test message. |
| 425 | sendKeyUpdates int |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 426 | // keyUpdateRequest is the KeyUpdateRequest value to send in KeyUpdate messages. |
| 427 | keyUpdateRequest byte |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 428 | // expectMessageDropped, if true, means the test message is expected to |
| 429 | // be dropped by the client rather than echoed back. |
| 430 | expectMessageDropped bool |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 431 | // expectPeerCertificate, if not nil, is the certificate chain the peer |
| 432 | // is expected to send. |
| 433 | expectPeerCertificate *Certificate |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 434 | // shimPrefix is the prefix that the shim will send to the server. |
| 435 | shimPrefix string |
| 436 | // resumeShimPrefix is the prefix that the shim will send to the server on a |
| 437 | // resumption. |
| 438 | resumeShimPrefix string |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 441 | var testCases []testCase |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 442 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 443 | func writeTranscript(test *testCase, num int, data []byte) { |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 444 | if len(data) == 0 { |
| 445 | return |
| 446 | } |
| 447 | |
| 448 | protocol := "tls" |
| 449 | if test.protocol == dtls { |
| 450 | protocol = "dtls" |
| 451 | } |
| 452 | |
| 453 | side := "client" |
| 454 | if test.testType == serverTest { |
| 455 | side = "server" |
| 456 | } |
| 457 | |
| 458 | dir := path.Join(*transcriptDir, protocol, side) |
| 459 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 460 | fmt.Fprintf(os.Stderr, "Error making %s: %s\n", dir, err) |
| 461 | return |
| 462 | } |
| 463 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 464 | name := fmt.Sprintf("%s-%d", test.name, num) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 465 | if err := ioutil.WriteFile(path.Join(dir, name), data, 0644); err != nil { |
| 466 | fmt.Fprintf(os.Stderr, "Error writing %s: %s\n", name, err) |
| 467 | } |
| 468 | } |
| 469 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 470 | // A timeoutConn implements an idle timeout on each Read and Write operation. |
| 471 | type timeoutConn struct { |
| 472 | net.Conn |
| 473 | timeout time.Duration |
| 474 | } |
| 475 | |
| 476 | func (t *timeoutConn) Read(b []byte) (int, error) { |
| 477 | if err := t.SetReadDeadline(time.Now().Add(t.timeout)); err != nil { |
| 478 | return 0, err |
| 479 | } |
| 480 | return t.Conn.Read(b) |
| 481 | } |
| 482 | |
| 483 | func (t *timeoutConn) Write(b []byte) (int, error) { |
| 484 | if err := t.SetWriteDeadline(time.Now().Add(t.timeout)); err != nil { |
| 485 | return 0, err |
| 486 | } |
| 487 | return t.Conn.Write(b) |
| 488 | } |
| 489 | |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 490 | func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, num int) error { |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 491 | if !test.noSessionCache { |
| 492 | if config.ClientSessionCache == nil { |
| 493 | config.ClientSessionCache = NewLRUClientSessionCache(1) |
| 494 | } |
| 495 | if config.ServerSessionCache == nil { |
| 496 | config.ServerSessionCache = NewLRUServerSessionCache(1) |
| 497 | } |
| 498 | } |
| 499 | if test.testType == clientTest { |
| 500 | if len(config.Certificates) == 0 { |
| 501 | config.Certificates = []Certificate{rsaCertificate} |
| 502 | } |
| 503 | } else { |
| 504 | // Supply a ServerName to ensure a constant session cache key, |
| 505 | // rather than falling back to net.Conn.RemoteAddr. |
| 506 | if len(config.ServerName) == 0 { |
| 507 | config.ServerName = "test" |
| 508 | } |
| 509 | } |
| 510 | if *fuzzer { |
| 511 | config.Bugs.NullAllCiphers = true |
| 512 | } |
David Benjamin | 01a9057 | 2016-09-22 00:11:43 -0400 | [diff] [blame] | 513 | if *deterministic { |
| 514 | config.Time = func() time.Time { return time.Unix(1234, 1234) } |
| 515 | } |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 516 | |
David Benjamin | 01784b4 | 2016-06-07 18:00:52 -0400 | [diff] [blame] | 517 | conn = &timeoutConn{conn, *idleTimeout} |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 518 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 519 | if test.protocol == dtls { |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 520 | config.Bugs.PacketAdaptor = newPacketAdaptor(conn) |
| 521 | conn = config.Bugs.PacketAdaptor |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 522 | } |
| 523 | |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 524 | if *flagDebug || len(*transcriptDir) != 0 { |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 525 | local, peer := "client", "server" |
| 526 | if test.testType == clientTest { |
| 527 | local, peer = peer, local |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 528 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 529 | connDebug := &recordingConn{ |
| 530 | Conn: conn, |
| 531 | isDatagram: test.protocol == dtls, |
| 532 | local: local, |
| 533 | peer: peer, |
| 534 | } |
| 535 | conn = connDebug |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 536 | if *flagDebug { |
| 537 | defer connDebug.WriteTo(os.Stdout) |
| 538 | } |
| 539 | if len(*transcriptDir) != 0 { |
| 540 | defer func() { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 541 | writeTranscript(test, num, connDebug.Transcript()) |
David Benjamin | 9867b7d | 2016-03-01 23:25:48 -0500 | [diff] [blame] | 542 | }() |
| 543 | } |
David Benjamin | ebda9b3 | 2015-11-02 15:33:18 -0500 | [diff] [blame] | 544 | |
| 545 | if config.Bugs.PacketAdaptor != nil { |
| 546 | config.Bugs.PacketAdaptor.debug = connDebug |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if test.replayWrites { |
| 551 | conn = newReplayAdaptor(conn) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 552 | } |
| 553 | |
David Benjamin | 3ed5977 | 2016-03-08 12:50:21 -0500 | [diff] [blame] | 554 | var connDamage *damageAdaptor |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 555 | if test.damageFirstWrite { |
| 556 | connDamage = newDamageAdaptor(conn) |
| 557 | conn = connDamage |
| 558 | } |
| 559 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 560 | if test.sendPrefix != "" { |
| 561 | if _, err := conn.Write([]byte(test.sendPrefix)); err != nil { |
| 562 | return err |
| 563 | } |
David Benjamin | 98e882e | 2014-08-08 13:24:34 -0400 | [diff] [blame] | 564 | } |
| 565 | |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 566 | var tlsConn *Conn |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 567 | if test.testType == clientTest { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 568 | if test.protocol == dtls { |
| 569 | tlsConn = DTLSServer(conn, config) |
| 570 | } else { |
| 571 | tlsConn = Server(conn, config) |
| 572 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 573 | } else { |
| 574 | config.InsecureSkipVerify = true |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 575 | if test.protocol == dtls { |
| 576 | tlsConn = DTLSClient(conn, config) |
| 577 | } else { |
| 578 | tlsConn = Client(conn, config) |
| 579 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 580 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 581 | defer tlsConn.Close() |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 582 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 583 | if err := tlsConn.Handshake(); err != nil { |
| 584 | return err |
| 585 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 586 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 587 | // TODO(davidben): move all per-connection expectations into a dedicated |
| 588 | // expectations struct that can be specified separately for the two |
| 589 | // legs. |
| 590 | expectedVersion := test.expectedVersion |
| 591 | if isResume && test.expectedResumeVersion != 0 { |
| 592 | expectedVersion = test.expectedResumeVersion |
| 593 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 594 | connState := tlsConn.ConnectionState() |
| 595 | if vers := connState.Version; expectedVersion != 0 && vers != expectedVersion { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 596 | return fmt.Errorf("got version %x, expected %x", vers, expectedVersion) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 597 | } |
| 598 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 599 | if cipher := connState.CipherSuite; test.expectedCipher != 0 && cipher != test.expectedCipher { |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 600 | return fmt.Errorf("got cipher %x, expected %x", cipher, test.expectedCipher) |
| 601 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 602 | if didResume := connState.DidResume; isResume && didResume == test.expectResumeRejected { |
| 603 | return fmt.Errorf("didResume is %t, but we expected the opposite", didResume) |
| 604 | } |
David Benjamin | 90da8c8 | 2015-04-20 14:57:57 -0400 | [diff] [blame] | 605 | |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 606 | if test.expectChannelID { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 607 | channelID := connState.ChannelID |
David Benjamin | a08e49d | 2014-08-24 01:46:07 -0400 | [diff] [blame] | 608 | if channelID == nil { |
| 609 | return fmt.Errorf("no channel ID negotiated") |
| 610 | } |
| 611 | if channelID.Curve != channelIDKey.Curve || |
| 612 | channelIDKey.X.Cmp(channelIDKey.X) != 0 || |
| 613 | channelIDKey.Y.Cmp(channelIDKey.Y) != 0 { |
| 614 | return fmt.Errorf("incorrect channel ID") |
| 615 | } |
| 616 | } |
| 617 | |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 618 | if expected := test.expectedNextProto; expected != "" { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 619 | if actual := connState.NegotiatedProtocol; actual != expected { |
David Benjamin | ae2888f | 2014-09-06 12:58:58 -0400 | [diff] [blame] | 620 | return fmt.Errorf("next proto mismatch: got %s, wanted %s", actual, expected) |
| 621 | } |
| 622 | } |
| 623 | |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 624 | if test.expectNoNextProto { |
| 625 | if actual := connState.NegotiatedProtocol; actual != "" { |
| 626 | return fmt.Errorf("got unexpected next proto %s", actual) |
| 627 | } |
| 628 | } |
| 629 | |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 630 | if test.expectedNextProtoType != 0 { |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 631 | if (test.expectedNextProtoType == alpn) != connState.NegotiatedProtocolFromALPN { |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 632 | return fmt.Errorf("next proto type mismatch") |
| 633 | } |
| 634 | } |
| 635 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 636 | if p := connState.SRTPProtectionProfile; p != test.expectedSRTPProtectionProfile { |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 637 | return fmt.Errorf("SRTP profile mismatch: got %d, wanted %d", p, test.expectedSRTPProtectionProfile) |
| 638 | } |
| 639 | |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 640 | if test.expectedOCSPResponse != nil && !bytes.Equal(test.expectedOCSPResponse, tlsConn.OCSPResponse()) { |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 641 | 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] | 642 | } |
| 643 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 644 | if test.expectedSCTList != nil && !bytes.Equal(test.expectedSCTList, connState.SCTList) { |
| 645 | return fmt.Errorf("SCT list mismatch") |
| 646 | } |
| 647 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 648 | if expected := test.expectedPeerSignatureAlgorithm; expected != 0 && expected != connState.PeerSignatureAlgorithm { |
| 649 | 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] | 650 | } |
| 651 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 652 | if expected := test.expectedCurveID; expected != 0 && expected != connState.CurveID { |
| 653 | return fmt.Errorf("expected peer to use curve %04x, but got %04x", expected, connState.CurveID) |
| 654 | } |
| 655 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 656 | if test.expectPeerCertificate != nil { |
| 657 | if len(connState.PeerCertificates) != len(test.expectPeerCertificate.Certificate) { |
| 658 | return fmt.Errorf("expected peer to send %d certificates, but got %d", len(connState.PeerCertificates), len(test.expectPeerCertificate.Certificate)) |
| 659 | } |
| 660 | for i, cert := range connState.PeerCertificates { |
| 661 | if !bytes.Equal(cert.Raw, test.expectPeerCertificate.Certificate[i]) { |
| 662 | return fmt.Errorf("peer certificate %d did not match", i+1) |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 667 | if test.exportKeyingMaterial > 0 { |
| 668 | actual := make([]byte, test.exportKeyingMaterial) |
| 669 | if _, err := io.ReadFull(tlsConn, actual); err != nil { |
| 670 | return err |
| 671 | } |
| 672 | expected, err := tlsConn.ExportKeyingMaterial(test.exportKeyingMaterial, []byte(test.exportLabel), []byte(test.exportContext), test.useExportContext) |
| 673 | if err != nil { |
| 674 | return err |
| 675 | } |
| 676 | if !bytes.Equal(actual, expected) { |
| 677 | return fmt.Errorf("keying material mismatch") |
| 678 | } |
| 679 | } |
| 680 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 681 | if test.testTLSUnique { |
| 682 | var peersValue [12]byte |
| 683 | if _, err := io.ReadFull(tlsConn, peersValue[:]); err != nil { |
| 684 | return err |
| 685 | } |
| 686 | expected := tlsConn.ConnectionState().TLSUnique |
| 687 | if !bytes.Equal(peersValue[:], expected) { |
| 688 | return fmt.Errorf("tls-unique mismatch: peer sent %x, but %x was expected", peersValue[:], expected) |
| 689 | } |
| 690 | } |
| 691 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 692 | if test.sendHalfHelloRequest { |
| 693 | tlsConn.SendHalfHelloRequest() |
| 694 | } |
| 695 | |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 696 | shimPrefix := test.shimPrefix |
| 697 | if isResume { |
| 698 | shimPrefix = test.resumeShimPrefix |
| 699 | } |
| 700 | if test.shimWritesFirst || test.readWithUnfinishedWrite { |
| 701 | shimPrefix = "hello" |
| 702 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 703 | if test.renegotiate > 0 { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 704 | // If readWithUnfinishedWrite is set, the shim prefix will be |
| 705 | // available later. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 706 | if shimPrefix != "" && !test.readWithUnfinishedWrite { |
| 707 | var buf = make([]byte, len(shimPrefix)) |
| 708 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 709 | if err != nil { |
| 710 | return err |
| 711 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 712 | if string(buf) != shimPrefix { |
| 713 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 714 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 715 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 716 | } |
| 717 | |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 718 | if test.renegotiateCiphers != nil { |
| 719 | config.CipherSuites = test.renegotiateCiphers |
| 720 | } |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 721 | for i := 0; i < test.renegotiate; i++ { |
| 722 | if err := tlsConn.Renegotiate(); err != nil { |
| 723 | return err |
| 724 | } |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 725 | } |
| 726 | } else if test.renegotiateCiphers != nil { |
| 727 | panic("renegotiateCiphers without renegotiate") |
| 728 | } |
| 729 | |
David Benjamin | 5fa3eba | 2015-01-22 16:35:40 -0500 | [diff] [blame] | 730 | if test.damageFirstWrite { |
| 731 | connDamage.setDamage(true) |
| 732 | tlsConn.Write([]byte("DAMAGED WRITE")) |
| 733 | connDamage.setDamage(false) |
| 734 | } |
| 735 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 736 | messageLen := test.messageLen |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 737 | if messageLen < 0 { |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 738 | if test.protocol == dtls { |
| 739 | return fmt.Errorf("messageLen < 0 not supported for DTLS tests") |
| 740 | } |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 741 | // Read until EOF. |
| 742 | _, err := io.Copy(ioutil.Discard, tlsConn) |
| 743 | return err |
| 744 | } |
David Benjamin | 4417d05 | 2015-04-05 04:17:25 -0400 | [diff] [blame] | 745 | if messageLen == 0 { |
| 746 | messageLen = 32 |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 747 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 748 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 749 | messageCount := test.messageCount |
| 750 | if messageCount == 0 { |
| 751 | messageCount = 1 |
David Benjamin | a8ebe22 | 2015-06-06 03:04:39 -0400 | [diff] [blame] | 752 | } |
| 753 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 754 | for j := 0; j < messageCount; j++ { |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 755 | for i := 0; i < test.sendKeyUpdates; i++ { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 756 | tlsConn.SendKeyUpdate(test.keyUpdateRequest) |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 757 | } |
| 758 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 759 | for i := 0; i < test.sendEmptyRecords; i++ { |
| 760 | tlsConn.Write(nil) |
| 761 | } |
| 762 | |
| 763 | for i := 0; i < test.sendWarningAlerts; i++ { |
| 764 | tlsConn.SendAlert(alertLevelWarning, alertUnexpectedMessage) |
| 765 | } |
| 766 | |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 767 | if test.sendBogusAlertType { |
| 768 | tlsConn.SendAlert(0x42, alertUnexpectedMessage) |
| 769 | } |
| 770 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 771 | testMessage := make([]byte, messageLen) |
| 772 | for i := range testMessage { |
| 773 | testMessage[i] = 0x42 ^ byte(j) |
| 774 | } |
| 775 | tlsConn.Write(testMessage) |
| 776 | |
| 777 | // Consume the shim prefix if needed. |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 778 | if shimPrefix != "" { |
| 779 | var buf = make([]byte, len(shimPrefix)) |
| 780 | _, err := io.ReadFull(tlsConn, buf) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 781 | if err != nil { |
| 782 | return err |
| 783 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 784 | if string(buf) != shimPrefix { |
| 785 | return fmt.Errorf("bad initial message %v vs %v", string(buf), shimPrefix) |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 786 | } |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 787 | shimPrefix = "" |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 788 | } |
| 789 | |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 790 | if test.shimShutsDown || test.expectMessageDropped { |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 791 | // The shim will not respond. |
| 792 | continue |
| 793 | } |
| 794 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 795 | // Process the KeyUpdate ACK. However many KeyUpdates the runner |
| 796 | // sends, the shim should respond only once. |
| 797 | if test.sendKeyUpdates > 0 && test.keyUpdateRequest == keyUpdateRequested { |
| 798 | if err := tlsConn.ReadKeyUpdateACK(); err != nil { |
| 799 | return err |
| 800 | } |
| 801 | } |
| 802 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 803 | buf := make([]byte, len(testMessage)) |
| 804 | if test.protocol == dtls { |
| 805 | bufTmp := make([]byte, len(buf)+1) |
| 806 | n, err := tlsConn.Read(bufTmp) |
| 807 | if err != nil { |
| 808 | return err |
| 809 | } |
| 810 | if n != len(buf) { |
| 811 | return fmt.Errorf("bad reply; length mismatch (%d vs %d)", n, len(buf)) |
| 812 | } |
| 813 | copy(buf, bufTmp) |
| 814 | } else { |
| 815 | _, err := io.ReadFull(tlsConn, buf) |
| 816 | if err != nil { |
| 817 | return err |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | for i, v := range buf { |
| 822 | if v != testMessage[i]^0xff { |
| 823 | return fmt.Errorf("bad reply contents at byte %d", i) |
| 824 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 825 | } |
| 826 | } |
| 827 | |
| 828 | return nil |
| 829 | } |
| 830 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 831 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 832 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 833 | if dbAttach { |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 834 | 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] | 835 | } |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 836 | valgrindArgs = append(valgrindArgs, path) |
| 837 | valgrindArgs = append(valgrindArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 838 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 839 | return exec.Command("valgrind", valgrindArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 840 | } |
| 841 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 842 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 843 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 844 | xtermArgs = append(xtermArgs, path) |
| 845 | xtermArgs = append(xtermArgs, args...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 846 | |
David Benjamin | 325b5c3 | 2014-07-01 19:40:31 -0400 | [diff] [blame] | 847 | return exec.Command("xterm", xtermArgs...) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 848 | } |
| 849 | |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 850 | func lldbOf(path string, args ...string) *exec.Cmd { |
| 851 | xtermArgs := []string{"-e", "lldb", "--"} |
| 852 | xtermArgs = append(xtermArgs, path) |
| 853 | xtermArgs = append(xtermArgs, args...) |
| 854 | |
| 855 | return exec.Command("xterm", xtermArgs...) |
| 856 | } |
| 857 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 858 | var ( |
| 859 | errMoreMallocs = errors.New("child process did not exhaust all allocation calls") |
| 860 | errUnimplemented = errors.New("child process does not implement needed flags") |
| 861 | ) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 862 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 863 | // accept accepts a connection from listener, unless waitChan signals a process |
| 864 | // exit first. |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 865 | func acceptOrWait(listener *net.TCPListener, waitChan chan error) (net.Conn, error) { |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 866 | type connOrError struct { |
| 867 | conn net.Conn |
| 868 | err error |
| 869 | } |
| 870 | connChan := make(chan connOrError, 1) |
| 871 | go func() { |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 872 | listener.SetDeadline(time.Now().Add(*idleTimeout)) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 873 | conn, err := listener.Accept() |
| 874 | connChan <- connOrError{conn, err} |
| 875 | close(connChan) |
| 876 | }() |
| 877 | select { |
| 878 | case result := <-connChan: |
| 879 | return result.conn, result.err |
| 880 | case childErr := <-waitChan: |
| 881 | waitChan <- childErr |
| 882 | return nil, fmt.Errorf("child exited early: %s", childErr) |
| 883 | } |
| 884 | } |
| 885 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 886 | func translateExpectedError(errorStr string) string { |
| 887 | if translated, ok := shimConfig.ErrorMap[errorStr]; ok { |
| 888 | return translated |
| 889 | } |
| 890 | |
| 891 | if *looseErrors { |
| 892 | return "" |
| 893 | } |
| 894 | |
| 895 | return errorStr |
| 896 | } |
| 897 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 898 | func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 899 | // Help debugging panics on the Go side. |
| 900 | defer func() { |
| 901 | if r := recover(); r != nil { |
| 902 | fmt.Fprintf(os.Stderr, "Test '%s' panicked.\n", test.name) |
| 903 | panic(r) |
| 904 | } |
| 905 | }() |
| 906 | |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 907 | if !test.shouldFail && (len(test.expectedError) > 0 || len(test.expectedLocalError) > 0) { |
| 908 | panic("Error expected without shouldFail in " + test.name) |
| 909 | } |
| 910 | |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 911 | if test.expectResumeRejected && !test.resumeSession { |
| 912 | panic("expectResumeRejected without resumeSession in " + test.name) |
| 913 | } |
| 914 | |
Adam Langley | 33b1d4f | 2016-12-07 15:03:45 -0800 | [diff] [blame] | 915 | for _, ver := range tlsVersions { |
| 916 | if !strings.Contains("-"+test.name+"-", "-"+ver.name+"-") { |
| 917 | continue |
| 918 | } |
| 919 | |
| 920 | if test.config.MaxVersion != 0 || test.config.MinVersion != 0 || test.expectedVersion != 0 { |
| 921 | continue |
| 922 | } |
| 923 | |
| 924 | 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)) |
| 925 | } |
| 926 | |
Matthew Braithwaite | 2d04cf0 | 2017-05-19 18:13:25 -0700 | [diff] [blame] | 927 | listener, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv6loopback}) |
| 928 | if err != nil { |
| 929 | listener, err = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IP{127, 0, 0, 1}}) |
| 930 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 931 | if err != nil { |
| 932 | panic(err) |
| 933 | } |
| 934 | defer func() { |
| 935 | if listener != nil { |
| 936 | listener.Close() |
| 937 | } |
| 938 | }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 939 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 940 | flags := []string{"-port", strconv.Itoa(listener.Addr().(*net.TCPAddr).Port)} |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 941 | if test.testType == serverTest { |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 942 | flags = append(flags, "-server") |
| 943 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 944 | flags = append(flags, "-key-file") |
| 945 | if test.keyFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 946 | flags = append(flags, path.Join(*resourceDir, rsaKeyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 947 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 948 | flags = append(flags, path.Join(*resourceDir, test.keyFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | flags = append(flags, "-cert-file") |
| 952 | if test.certFile == "" { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 953 | flags = append(flags, path.Join(*resourceDir, rsaCertificateFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 954 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 955 | flags = append(flags, path.Join(*resourceDir, test.certFile)) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 956 | } |
| 957 | } |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 958 | |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 959 | if test.protocol == dtls { |
| 960 | flags = append(flags, "-dtls") |
| 961 | } |
| 962 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 963 | var resumeCount int |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 964 | if test.resumeSession { |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 965 | resumeCount++ |
| 966 | if test.resumeRenewedSession { |
| 967 | resumeCount++ |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | if resumeCount > 0 { |
| 972 | flags = append(flags, "-resume-count", strconv.Itoa(resumeCount)) |
David Benjamin | 5a593af | 2014-08-11 19:51:50 -0400 | [diff] [blame] | 973 | } |
| 974 | |
David Benjamin | e58c4f5 | 2014-08-24 03:47:07 -0400 | [diff] [blame] | 975 | if test.shimWritesFirst { |
| 976 | flags = append(flags, "-shim-writes-first") |
| 977 | } |
| 978 | |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 979 | if test.readWithUnfinishedWrite { |
| 980 | flags = append(flags, "-read-with-unfinished-write") |
| 981 | } |
| 982 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 983 | if test.shimShutsDown { |
| 984 | flags = append(flags, "-shim-shuts-down") |
| 985 | } |
| 986 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 987 | if test.exportKeyingMaterial > 0 { |
| 988 | flags = append(flags, "-export-keying-material", strconv.Itoa(test.exportKeyingMaterial)) |
| 989 | flags = append(flags, "-export-label", test.exportLabel) |
| 990 | flags = append(flags, "-export-context", test.exportContext) |
| 991 | if test.useExportContext { |
| 992 | flags = append(flags, "-use-export-context") |
| 993 | } |
| 994 | } |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 995 | if test.expectResumeRejected { |
| 996 | flags = append(flags, "-expect-session-miss") |
| 997 | } |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 998 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 999 | if test.testTLSUnique { |
| 1000 | flags = append(flags, "-tls-unique") |
| 1001 | } |
| 1002 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1003 | flags = append(flags, test.flags...) |
| 1004 | |
| 1005 | var shim *exec.Cmd |
| 1006 | if *useValgrind { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1007 | shim = valgrindOf(false, shimPath, flags...) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 1008 | } else if *useGDB { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1009 | shim = gdbOf(shimPath, flags...) |
David Benjamin | d16bf34 | 2015-12-18 00:53:12 -0500 | [diff] [blame] | 1010 | } else if *useLLDB { |
| 1011 | shim = lldbOf(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1012 | } else { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1013 | shim = exec.Command(shimPath, flags...) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1014 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1015 | shim.Stdin = os.Stdin |
| 1016 | var stdoutBuf, stderrBuf bytes.Buffer |
| 1017 | shim.Stdout = &stdoutBuf |
| 1018 | shim.Stderr = &stderrBuf |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1019 | if mallocNumToFail >= 0 { |
David Benjamin | 9e128b0 | 2015-02-09 13:13:09 -0500 | [diff] [blame] | 1020 | shim.Env = os.Environ() |
| 1021 | 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] | 1022 | if *mallocTestDebug { |
David Benjamin | 184494d | 2015-06-12 18:23:47 -0400 | [diff] [blame] | 1023 | shim.Env = append(shim.Env, "MALLOC_BREAK_ON_FAIL=1") |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1024 | } |
| 1025 | shim.Env = append(shim.Env, "_MALLOC_CHECK=1") |
| 1026 | } |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 1027 | |
| 1028 | if err := shim.Start(); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1029 | panic(err) |
| 1030 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1031 | waitChan := make(chan error, 1) |
| 1032 | go func() { waitChan <- shim.Wait() }() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1033 | |
| 1034 | config := test.config |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1035 | |
David Benjamin | 7a4aaa4 | 2016-09-20 17:58:14 -0400 | [diff] [blame] | 1036 | if *deterministic { |
| 1037 | config.Rand = &deterministicRand{} |
| 1038 | } |
| 1039 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1040 | conn, err := acceptOrWait(listener, waitChan) |
| 1041 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 1042 | err = doExchange(test, &config, conn, false /* not a resumption */, 0) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1043 | conn.Close() |
| 1044 | } |
David Benjamin | 65ea8ff | 2014-11-23 03:01:00 -0500 | [diff] [blame] | 1045 | |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 1046 | for i := 0; err == nil && i < resumeCount; i++ { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1047 | var resumeConfig Config |
| 1048 | if test.resumeConfig != nil { |
| 1049 | resumeConfig = *test.resumeConfig |
David Benjamin | e54af06 | 2016-08-08 19:21:18 -0400 | [diff] [blame] | 1050 | if !test.newSessionsOnResume { |
David Benjamin | fe8eb9a | 2014-11-17 03:19:02 -0500 | [diff] [blame] | 1051 | resumeConfig.SessionTicketKey = config.SessionTicketKey |
| 1052 | resumeConfig.ClientSessionCache = config.ClientSessionCache |
| 1053 | resumeConfig.ServerSessionCache = config.ServerSessionCache |
| 1054 | } |
David Benjamin | 2e045a9 | 2016-06-08 13:09:56 -0400 | [diff] [blame] | 1055 | resumeConfig.Rand = config.Rand |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 1056 | } else { |
| 1057 | resumeConfig = config |
| 1058 | } |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1059 | var connResume net.Conn |
| 1060 | connResume, err = acceptOrWait(listener, waitChan) |
| 1061 | if err == nil { |
David Benjamin | c07afb7 | 2016-09-22 10:18:58 -0400 | [diff] [blame] | 1062 | err = doExchange(test, &resumeConfig, connResume, true /* resumption */, i+1) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1063 | connResume.Close() |
| 1064 | } |
David Benjamin | 1d5c83e | 2014-07-22 19:20:02 -0400 | [diff] [blame] | 1065 | } |
| 1066 | |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1067 | // Close the listener now. This is to avoid hangs should the shim try to |
| 1068 | // open more connections than expected. |
| 1069 | listener.Close() |
| 1070 | listener = nil |
| 1071 | |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1072 | var shimKilledLock sync.Mutex |
| 1073 | var shimKilled bool |
| 1074 | waitTimeout := time.AfterFunc(*idleTimeout, func() { |
| 1075 | shimKilledLock.Lock() |
| 1076 | shimKilled = true |
| 1077 | shimKilledLock.Unlock() |
| 1078 | shim.Process.Kill() |
| 1079 | }) |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 1080 | childErr := <-waitChan |
David Benjamin | 4d1f4ba | 2017-05-08 15:54:39 -0400 | [diff] [blame] | 1081 | waitTimeout.Stop() |
| 1082 | shimKilledLock.Lock() |
| 1083 | if shimKilled && err == nil { |
| 1084 | err = errors.New("timeout waiting for the shim to exit.") |
| 1085 | } |
| 1086 | shimKilledLock.Unlock() |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1087 | var isValgrindError bool |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1088 | if exitError, ok := childErr.(*exec.ExitError); ok { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1089 | switch exitError.Sys().(syscall.WaitStatus).ExitStatus() { |
| 1090 | case 88: |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1091 | return errMoreMallocs |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 1092 | case 89: |
| 1093 | return errUnimplemented |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1094 | case 99: |
| 1095 | isValgrindError = true |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 1096 | } |
| 1097 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1098 | |
David Benjamin | 9bea349 | 2016-03-02 10:59:16 -0500 | [diff] [blame] | 1099 | // Account for Windows line endings. |
| 1100 | stdout := strings.Replace(string(stdoutBuf.Bytes()), "\r\n", "\n", -1) |
| 1101 | stderr := strings.Replace(string(stderrBuf.Bytes()), "\r\n", "\n", -1) |
David Benjamin | ff3a149 | 2016-03-02 10:12:06 -0500 | [diff] [blame] | 1102 | |
| 1103 | // Separate the errors from the shim and those from tools like |
| 1104 | // AddressSanitizer. |
| 1105 | var extraStderr string |
| 1106 | if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { |
| 1107 | stderr = stderrParts[0] |
| 1108 | extraStderr = stderrParts[1] |
| 1109 | } |
| 1110 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1111 | failed := err != nil || childErr != nil |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1112 | expectedError := translateExpectedError(test.expectedError) |
| 1113 | correctFailure := len(expectedError) == 0 || strings.Contains(stderr, expectedError) |
EKR | 173bf93 | 2016-07-29 15:52:49 +0200 | [diff] [blame] | 1114 | |
Adam Langley | ac61fa3 | 2014-06-23 12:03:11 -0700 | [diff] [blame] | 1115 | localError := "none" |
| 1116 | if err != nil { |
| 1117 | localError = err.Error() |
| 1118 | } |
| 1119 | if len(test.expectedLocalError) != 0 { |
| 1120 | correctFailure = correctFailure && strings.Contains(localError, test.expectedLocalError) |
| 1121 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1122 | |
| 1123 | if failed != test.shouldFail || failed && !correctFailure { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1124 | childError := "none" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1125 | if childErr != nil { |
| 1126 | childError = childErr.Error() |
| 1127 | } |
| 1128 | |
| 1129 | var msg string |
| 1130 | switch { |
| 1131 | case failed && !test.shouldFail: |
| 1132 | msg = "unexpected failure" |
| 1133 | case !failed && test.shouldFail: |
| 1134 | msg = "unexpected success" |
| 1135 | case failed && !correctFailure: |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 1136 | msg = "bad error (wanted '" + expectedError + "' / '" + test.expectedLocalError + "')" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1137 | default: |
| 1138 | panic("internal error") |
| 1139 | } |
| 1140 | |
David Benjamin | 9aafb64 | 2016-09-20 19:36:53 -0400 | [diff] [blame] | 1141 | 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] | 1142 | } |
| 1143 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1144 | if len(extraStderr) > 0 || (!failed && len(stderr) > 0) { |
Adam Langley | c88f245 | 2017-04-27 14:15:37 -0700 | [diff] [blame] | 1145 | return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1146 | } |
| 1147 | |
David Benjamin | d2ba889 | 2016-09-20 19:41:04 -0400 | [diff] [blame] | 1148 | if *useValgrind && isValgrindError { |
| 1149 | return fmt.Errorf("valgrind error:\n%s\n%s", stderr, extraStderr) |
| 1150 | } |
| 1151 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1152 | return nil |
| 1153 | } |
| 1154 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1155 | type tlsVersion struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1156 | name string |
| 1157 | version uint16 |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 1158 | // excludeFlag is the legacy shim flag to disable the version. |
| 1159 | excludeFlag string |
| 1160 | hasDTLS bool |
| 1161 | // shimTLS and shimDTLS are values the shim uses to refer to these |
| 1162 | // versions in TLS and DTLS, respectively. |
| 1163 | shimTLS, shimDTLS int |
| 1164 | } |
| 1165 | |
| 1166 | func (vers tlsVersion) shimFlag(protocol protocol) string { |
| 1167 | if protocol == dtls { |
| 1168 | return strconv.Itoa(vers.shimDTLS) |
| 1169 | } |
| 1170 | return strconv.Itoa(vers.shimTLS) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1171 | } |
| 1172 | |
| 1173 | var tlsVersions = []tlsVersion{ |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 1174 | {"SSL3", VersionSSL30, "-no-ssl3", false, VersionSSL30, 0}, |
| 1175 | {"TLS1", VersionTLS10, "-no-tls1", true, VersionTLS10, VersionDTLS10}, |
| 1176 | {"TLS11", VersionTLS11, "-no-tls11", false, VersionTLS11, 0}, |
| 1177 | {"TLS12", VersionTLS12, "-no-tls12", true, VersionTLS12, VersionDTLS12}, |
| 1178 | {"TLS13", VersionTLS13, "-no-tls13", false, VersionTLS13, 0}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1179 | } |
| 1180 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1181 | type testCipherSuite struct { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1182 | name string |
| 1183 | id uint16 |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | var testCipherSuites = []testCipherSuite{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1187 | {"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1188 | {"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1189 | {"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1190 | {"AES128-SHA256", TLS_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1191 | {"AES256-GCM", TLS_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1192 | {"AES256-SHA", TLS_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1193 | {"AES256-SHA256", TLS_RSA_WITH_AES_256_CBC_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1194 | {"ECDHE-ECDSA-AES128-GCM", TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 1195 | {"ECDHE-ECDSA-AES128-SHA", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1196 | {"ECDHE-ECDSA-AES128-SHA256", TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256}, |
| 1197 | {"ECDHE-ECDSA-AES256-GCM", TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1198 | {"ECDHE-ECDSA-AES256-SHA", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1199 | {"ECDHE-ECDSA-AES256-SHA384", TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1200 | {"ECDHE-ECDSA-CHACHA20-POLY1305", TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1201 | {"ECDHE-RSA-AES128-GCM", TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1202 | {"ECDHE-RSA-AES128-SHA", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1203 | {"ECDHE-RSA-AES128-SHA256", TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256}, |
David Benjamin | f4e5c4e | 2014-08-02 17:35:45 -0400 | [diff] [blame] | 1204 | {"ECDHE-RSA-AES256-GCM", TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1205 | {"ECDHE-RSA-AES256-SHA", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1206 | {"ECDHE-RSA-AES256-SHA384", TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384}, |
David Benjamin | 13414b3 | 2015-12-09 23:02:39 -0500 | [diff] [blame] | 1207 | {"ECDHE-RSA-CHACHA20-POLY1305", TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 1208 | {"PSK-AES128-CBC-SHA", TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 1209 | {"PSK-AES256-CBC-SHA", TLS_PSK_WITH_AES_256_CBC_SHA}, |
Adam Langley | 85bc560 | 2015-06-09 09:54:04 -0700 | [diff] [blame] | 1210 | {"ECDHE-PSK-AES128-CBC-SHA", TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 1211 | {"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] | 1212 | {"ECDHE-PSK-CHACHA20-POLY1305", TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256}, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1213 | {"AEAD-CHACHA20-POLY1305", TLS_CHACHA20_POLY1305_SHA256}, |
| 1214 | {"AEAD-AES128-GCM-SHA256", TLS_AES_128_GCM_SHA256}, |
| 1215 | {"AEAD-AES256-GCM-SHA384", TLS_AES_256_GCM_SHA384}, |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1216 | {"NULL-SHA", TLS_RSA_WITH_NULL_SHA}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1217 | } |
| 1218 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1219 | func hasComponent(suiteName, component string) bool { |
| 1220 | return strings.Contains("-"+suiteName+"-", "-"+component+"-") |
| 1221 | } |
| 1222 | |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1223 | func isTLS12Only(suiteName string) bool { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1224 | return hasComponent(suiteName, "GCM") || |
| 1225 | hasComponent(suiteName, "SHA256") || |
David Benjamin | e9a80ff | 2015-04-07 00:46:46 -0400 | [diff] [blame] | 1226 | hasComponent(suiteName, "SHA384") || |
| 1227 | hasComponent(suiteName, "POLY1305") |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1228 | } |
| 1229 | |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1230 | func isTLS13Suite(suiteName string) bool { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1231 | return strings.HasPrefix(suiteName, "AEAD-") |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1232 | } |
| 1233 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 1234 | func isDTLSCipher(suiteName string) bool { |
Matt Braithwaite | af09675 | 2015-09-02 19:48:16 -0700 | [diff] [blame] | 1235 | return !hasComponent(suiteName, "RC4") && !hasComponent(suiteName, "NULL") |
David Benjamin | f7768e4 | 2014-08-31 02:06:47 -0400 | [diff] [blame] | 1236 | } |
| 1237 | |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 1238 | func bigFromHex(hex string) *big.Int { |
| 1239 | ret, ok := new(big.Int).SetString(hex, 16) |
| 1240 | if !ok { |
| 1241 | panic("failed to parse hex number 0x" + hex) |
| 1242 | } |
| 1243 | return ret |
| 1244 | } |
| 1245 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1246 | func addBasicTests() { |
| 1247 | basicTests := []testCase{ |
| 1248 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1249 | name: "NoFallbackSCSV", |
| 1250 | config: Config{ |
| 1251 | Bugs: ProtocolBugs{ |
| 1252 | FailIfNotFallbackSCSV: true, |
| 1253 | }, |
| 1254 | }, |
| 1255 | shouldFail: true, |
| 1256 | expectedLocalError: "no fallback SCSV found", |
| 1257 | }, |
| 1258 | { |
| 1259 | name: "SendFallbackSCSV", |
| 1260 | config: Config{ |
| 1261 | Bugs: ProtocolBugs{ |
| 1262 | FailIfNotFallbackSCSV: true, |
| 1263 | }, |
| 1264 | }, |
| 1265 | flags: []string{"-fallback-scsv"}, |
| 1266 | }, |
| 1267 | { |
| 1268 | name: "ClientCertificateTypes", |
| 1269 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1270 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1271 | ClientAuth: RequestClientCert, |
| 1272 | ClientCertificateTypes: []byte{ |
| 1273 | CertTypeDSSSign, |
| 1274 | CertTypeRSASign, |
| 1275 | CertTypeECDSASign, |
| 1276 | }, |
| 1277 | }, |
| 1278 | flags: []string{ |
| 1279 | "-expect-certificate-types", |
| 1280 | base64.StdEncoding.EncodeToString([]byte{ |
| 1281 | CertTypeDSSSign, |
| 1282 | CertTypeRSASign, |
| 1283 | CertTypeECDSASign, |
| 1284 | }), |
| 1285 | }, |
| 1286 | }, |
| 1287 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1288 | name: "UnauthenticatedECDH", |
| 1289 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1290 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1291 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1292 | Bugs: ProtocolBugs{ |
| 1293 | UnauthenticatedECDH: true, |
| 1294 | }, |
| 1295 | }, |
| 1296 | shouldFail: true, |
| 1297 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1298 | }, |
| 1299 | { |
| 1300 | name: "SkipCertificateStatus", |
| 1301 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1302 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1303 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1304 | Bugs: ProtocolBugs{ |
| 1305 | SkipCertificateStatus: true, |
| 1306 | }, |
| 1307 | }, |
| 1308 | flags: []string{ |
| 1309 | "-enable-ocsp-stapling", |
| 1310 | }, |
| 1311 | }, |
| 1312 | { |
| 1313 | name: "SkipServerKeyExchange", |
| 1314 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1315 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1316 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1317 | Bugs: ProtocolBugs{ |
| 1318 | SkipServerKeyExchange: true, |
| 1319 | }, |
| 1320 | }, |
| 1321 | shouldFail: true, |
| 1322 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1323 | }, |
| 1324 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1325 | testType: serverTest, |
| 1326 | name: "Alert", |
| 1327 | config: Config{ |
| 1328 | Bugs: ProtocolBugs{ |
| 1329 | SendSpuriousAlert: alertRecordOverflow, |
| 1330 | }, |
| 1331 | }, |
| 1332 | shouldFail: true, |
| 1333 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1334 | }, |
| 1335 | { |
| 1336 | protocol: dtls, |
| 1337 | testType: serverTest, |
| 1338 | name: "Alert-DTLS", |
| 1339 | config: Config{ |
| 1340 | Bugs: ProtocolBugs{ |
| 1341 | SendSpuriousAlert: alertRecordOverflow, |
| 1342 | }, |
| 1343 | }, |
| 1344 | shouldFail: true, |
| 1345 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1346 | }, |
| 1347 | { |
| 1348 | testType: serverTest, |
| 1349 | name: "FragmentAlert", |
| 1350 | config: Config{ |
| 1351 | Bugs: ProtocolBugs{ |
| 1352 | FragmentAlert: true, |
| 1353 | SendSpuriousAlert: alertRecordOverflow, |
| 1354 | }, |
| 1355 | }, |
| 1356 | shouldFail: true, |
| 1357 | expectedError: ":BAD_ALERT:", |
| 1358 | }, |
| 1359 | { |
| 1360 | protocol: dtls, |
| 1361 | testType: serverTest, |
| 1362 | name: "FragmentAlert-DTLS", |
| 1363 | config: Config{ |
| 1364 | Bugs: ProtocolBugs{ |
| 1365 | FragmentAlert: true, |
| 1366 | SendSpuriousAlert: alertRecordOverflow, |
| 1367 | }, |
| 1368 | }, |
| 1369 | shouldFail: true, |
| 1370 | expectedError: ":BAD_ALERT:", |
| 1371 | }, |
| 1372 | { |
| 1373 | testType: serverTest, |
David Benjamin | 0d3a8c6 | 2016-03-11 22:25:18 -0500 | [diff] [blame] | 1374 | name: "DoubleAlert", |
| 1375 | config: Config{ |
| 1376 | Bugs: ProtocolBugs{ |
| 1377 | DoubleAlert: true, |
| 1378 | SendSpuriousAlert: alertRecordOverflow, |
| 1379 | }, |
| 1380 | }, |
| 1381 | shouldFail: true, |
| 1382 | expectedError: ":BAD_ALERT:", |
| 1383 | }, |
| 1384 | { |
| 1385 | protocol: dtls, |
| 1386 | testType: serverTest, |
| 1387 | name: "DoubleAlert-DTLS", |
| 1388 | config: Config{ |
| 1389 | Bugs: ProtocolBugs{ |
| 1390 | DoubleAlert: true, |
| 1391 | SendSpuriousAlert: alertRecordOverflow, |
| 1392 | }, |
| 1393 | }, |
| 1394 | shouldFail: true, |
| 1395 | expectedError: ":BAD_ALERT:", |
| 1396 | }, |
| 1397 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1398 | name: "SkipNewSessionTicket", |
| 1399 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1400 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1401 | Bugs: ProtocolBugs{ |
| 1402 | SkipNewSessionTicket: true, |
| 1403 | }, |
| 1404 | }, |
| 1405 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1406 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1407 | }, |
| 1408 | { |
| 1409 | testType: serverTest, |
| 1410 | name: "FallbackSCSV", |
| 1411 | config: Config{ |
| 1412 | MaxVersion: VersionTLS11, |
| 1413 | Bugs: ProtocolBugs{ |
| 1414 | SendFallbackSCSV: true, |
| 1415 | }, |
| 1416 | }, |
David Benjamin | 56cadc3 | 2016-12-16 19:54:11 -0500 | [diff] [blame] | 1417 | shouldFail: true, |
| 1418 | expectedError: ":INAPPROPRIATE_FALLBACK:", |
| 1419 | expectedLocalError: "remote error: inappropriate fallback", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1420 | }, |
| 1421 | { |
| 1422 | testType: serverTest, |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1423 | name: "FallbackSCSV-VersionMatch-TLS13", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1424 | config: Config{ |
David Benjamin | b442dee | 2016-12-19 22:15:08 -0500 | [diff] [blame] | 1425 | MaxVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1426 | Bugs: ProtocolBugs{ |
| 1427 | SendFallbackSCSV: true, |
| 1428 | }, |
| 1429 | }, |
| 1430 | }, |
| 1431 | { |
| 1432 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1433 | name: "FallbackSCSV-VersionMatch-TLS12", |
| 1434 | config: Config{ |
| 1435 | MaxVersion: VersionTLS12, |
| 1436 | Bugs: ProtocolBugs{ |
| 1437 | SendFallbackSCSV: true, |
| 1438 | }, |
| 1439 | }, |
| 1440 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 1441 | }, |
| 1442 | { |
| 1443 | testType: serverTest, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1444 | name: "FragmentedClientVersion", |
| 1445 | config: Config{ |
| 1446 | Bugs: ProtocolBugs{ |
| 1447 | MaxHandshakeRecordLength: 1, |
| 1448 | FragmentClientVersion: true, |
| 1449 | }, |
| 1450 | }, |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1451 | expectedVersion: VersionTLS13, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1452 | }, |
| 1453 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1454 | testType: serverTest, |
| 1455 | name: "HttpGET", |
| 1456 | sendPrefix: "GET / HTTP/1.0\n", |
| 1457 | shouldFail: true, |
| 1458 | expectedError: ":HTTP_REQUEST:", |
| 1459 | }, |
| 1460 | { |
| 1461 | testType: serverTest, |
| 1462 | name: "HttpPOST", |
| 1463 | sendPrefix: "POST / HTTP/1.0\n", |
| 1464 | shouldFail: true, |
| 1465 | expectedError: ":HTTP_REQUEST:", |
| 1466 | }, |
| 1467 | { |
| 1468 | testType: serverTest, |
| 1469 | name: "HttpHEAD", |
| 1470 | sendPrefix: "HEAD / HTTP/1.0\n", |
| 1471 | shouldFail: true, |
| 1472 | expectedError: ":HTTP_REQUEST:", |
| 1473 | }, |
| 1474 | { |
| 1475 | testType: serverTest, |
| 1476 | name: "HttpPUT", |
| 1477 | sendPrefix: "PUT / HTTP/1.0\n", |
| 1478 | shouldFail: true, |
| 1479 | expectedError: ":HTTP_REQUEST:", |
| 1480 | }, |
| 1481 | { |
| 1482 | testType: serverTest, |
| 1483 | name: "HttpCONNECT", |
| 1484 | sendPrefix: "CONNECT www.google.com:443 HTTP/1.0\n", |
| 1485 | shouldFail: true, |
| 1486 | expectedError: ":HTTPS_PROXY_REQUEST:", |
| 1487 | }, |
| 1488 | { |
| 1489 | testType: serverTest, |
| 1490 | name: "Garbage", |
| 1491 | sendPrefix: "blah", |
| 1492 | shouldFail: true, |
David Benjamin | 97760d5 | 2015-07-24 23:02:49 -0400 | [diff] [blame] | 1493 | expectedError: ":WRONG_VERSION_NUMBER:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1494 | }, |
| 1495 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1496 | name: "RSAEphemeralKey", |
| 1497 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1498 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1499 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 1500 | Bugs: ProtocolBugs{ |
| 1501 | RSAEphemeralKey: true, |
| 1502 | }, |
| 1503 | }, |
| 1504 | shouldFail: true, |
| 1505 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 1506 | }, |
| 1507 | { |
| 1508 | name: "DisableEverything", |
Steven Valdez | 4f94b1c | 2016-05-24 12:31:07 -0400 | [diff] [blame] | 1509 | flags: []string{"-no-tls13", "-no-tls12", "-no-tls11", "-no-tls1", "-no-ssl3"}, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1510 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1511 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1512 | }, |
| 1513 | { |
| 1514 | protocol: dtls, |
| 1515 | name: "DisableEverything-DTLS", |
| 1516 | flags: []string{"-no-tls12", "-no-tls1"}, |
| 1517 | shouldFail: true, |
David Benjamin | 3cfeb95 | 2017-03-01 16:48:38 -0500 | [diff] [blame] | 1518 | expectedError: ":NO_SUPPORTED_VERSIONS_ENABLED:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1519 | }, |
| 1520 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1521 | protocol: dtls, |
| 1522 | testType: serverTest, |
| 1523 | name: "MTU", |
| 1524 | config: Config{ |
| 1525 | Bugs: ProtocolBugs{ |
| 1526 | MaxPacketLength: 256, |
| 1527 | }, |
| 1528 | }, |
| 1529 | flags: []string{"-mtu", "256"}, |
| 1530 | }, |
| 1531 | { |
| 1532 | protocol: dtls, |
| 1533 | testType: serverTest, |
| 1534 | name: "MTUExceeded", |
| 1535 | config: Config{ |
| 1536 | Bugs: ProtocolBugs{ |
| 1537 | MaxPacketLength: 255, |
| 1538 | }, |
| 1539 | }, |
| 1540 | flags: []string{"-mtu", "256"}, |
| 1541 | shouldFail: true, |
| 1542 | expectedLocalError: "dtls: exceeded maximum packet length", |
| 1543 | }, |
| 1544 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1545 | name: "EmptyCertificateList", |
| 1546 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1547 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1548 | Bugs: ProtocolBugs{ |
| 1549 | EmptyCertificateList: true, |
| 1550 | }, |
| 1551 | }, |
| 1552 | shouldFail: true, |
| 1553 | expectedError: ":DECODE_ERROR:", |
| 1554 | }, |
| 1555 | { |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1556 | name: "EmptyCertificateList-TLS13", |
| 1557 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 1558 | MaxVersion: VersionTLS13, |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1559 | Bugs: ProtocolBugs{ |
| 1560 | EmptyCertificateList: true, |
| 1561 | }, |
| 1562 | }, |
| 1563 | shouldFail: true, |
David Benjamin | 4087df9 | 2016-08-01 20:16:31 -0400 | [diff] [blame] | 1564 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
David Benjamin | 9ec1c75 | 2016-07-14 12:45:01 -0400 | [diff] [blame] | 1565 | }, |
| 1566 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1567 | name: "TLSFatalBadPackets", |
| 1568 | damageFirstWrite: true, |
| 1569 | shouldFail: true, |
| 1570 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 1571 | }, |
| 1572 | { |
| 1573 | protocol: dtls, |
| 1574 | name: "DTLSIgnoreBadPackets", |
| 1575 | damageFirstWrite: true, |
| 1576 | }, |
| 1577 | { |
| 1578 | protocol: dtls, |
| 1579 | name: "DTLSIgnoreBadPackets-Async", |
| 1580 | damageFirstWrite: true, |
| 1581 | flags: []string{"-async"}, |
| 1582 | }, |
| 1583 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1584 | name: "AppDataBeforeHandshake", |
| 1585 | config: Config{ |
| 1586 | Bugs: ProtocolBugs{ |
| 1587 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1588 | }, |
| 1589 | }, |
| 1590 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1591 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1592 | }, |
| 1593 | { |
| 1594 | name: "AppDataBeforeHandshake-Empty", |
| 1595 | config: Config{ |
| 1596 | Bugs: ProtocolBugs{ |
| 1597 | AppDataBeforeHandshake: []byte{}, |
| 1598 | }, |
| 1599 | }, |
| 1600 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1601 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1602 | }, |
| 1603 | { |
| 1604 | protocol: dtls, |
| 1605 | name: "AppDataBeforeHandshake-DTLS", |
| 1606 | config: Config{ |
| 1607 | Bugs: ProtocolBugs{ |
| 1608 | AppDataBeforeHandshake: []byte("TEST MESSAGE"), |
| 1609 | }, |
| 1610 | }, |
| 1611 | shouldFail: true, |
| 1612 | expectedError: ":UNEXPECTED_RECORD:", |
| 1613 | }, |
| 1614 | { |
| 1615 | protocol: dtls, |
| 1616 | name: "AppDataBeforeHandshake-DTLS-Empty", |
| 1617 | config: Config{ |
| 1618 | Bugs: ProtocolBugs{ |
| 1619 | AppDataBeforeHandshake: []byte{}, |
| 1620 | }, |
| 1621 | }, |
| 1622 | shouldFail: true, |
| 1623 | expectedError: ":UNEXPECTED_RECORD:", |
| 1624 | }, |
| 1625 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1626 | name: "AppDataAfterChangeCipherSpec", |
| 1627 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1628 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1629 | Bugs: ProtocolBugs{ |
| 1630 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1631 | }, |
| 1632 | }, |
| 1633 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1634 | expectedError: ":UNEXPECTED_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1635 | }, |
| 1636 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1637 | name: "AppDataAfterChangeCipherSpec-Empty", |
| 1638 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1639 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1640 | Bugs: ProtocolBugs{ |
| 1641 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1642 | }, |
| 1643 | }, |
| 1644 | shouldFail: true, |
David Benjamin | a41280d | 2015-11-26 02:16:49 -0500 | [diff] [blame] | 1645 | expectedError: ":UNEXPECTED_RECORD:", |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1646 | }, |
| 1647 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1648 | protocol: dtls, |
| 1649 | name: "AppDataAfterChangeCipherSpec-DTLS", |
| 1650 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1651 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1652 | Bugs: ProtocolBugs{ |
| 1653 | AppDataAfterChangeCipherSpec: []byte("TEST MESSAGE"), |
| 1654 | }, |
| 1655 | }, |
| 1656 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1657 | // application data. |
| 1658 | }, |
| 1659 | { |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1660 | protocol: dtls, |
| 1661 | name: "AppDataAfterChangeCipherSpec-DTLS-Empty", |
| 1662 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1663 | MaxVersion: VersionTLS12, |
David Benjamin | 4cf369b | 2015-08-22 01:35:43 -0400 | [diff] [blame] | 1664 | Bugs: ProtocolBugs{ |
| 1665 | AppDataAfterChangeCipherSpec: []byte{}, |
| 1666 | }, |
| 1667 | }, |
| 1668 | // BoringSSL's DTLS implementation will drop the out-of-order |
| 1669 | // application data. |
| 1670 | }, |
| 1671 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1672 | name: "AlertAfterChangeCipherSpec", |
| 1673 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1674 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1675 | Bugs: ProtocolBugs{ |
| 1676 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1677 | }, |
| 1678 | }, |
| 1679 | shouldFail: true, |
| 1680 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1681 | }, |
| 1682 | { |
| 1683 | protocol: dtls, |
| 1684 | name: "AlertAfterChangeCipherSpec-DTLS", |
| 1685 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1686 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1687 | Bugs: ProtocolBugs{ |
| 1688 | AlertAfterChangeCipherSpec: alertRecordOverflow, |
| 1689 | }, |
| 1690 | }, |
| 1691 | shouldFail: true, |
| 1692 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 1693 | }, |
| 1694 | { |
| 1695 | protocol: dtls, |
| 1696 | name: "ReorderHandshakeFragments-Small-DTLS", |
| 1697 | config: Config{ |
| 1698 | Bugs: ProtocolBugs{ |
| 1699 | ReorderHandshakeFragments: true, |
| 1700 | // Small enough that every handshake message is |
| 1701 | // fragmented. |
| 1702 | MaxHandshakeRecordLength: 2, |
| 1703 | }, |
| 1704 | }, |
| 1705 | }, |
| 1706 | { |
| 1707 | protocol: dtls, |
| 1708 | name: "ReorderHandshakeFragments-Large-DTLS", |
| 1709 | config: Config{ |
| 1710 | Bugs: ProtocolBugs{ |
| 1711 | ReorderHandshakeFragments: true, |
| 1712 | // Large enough that no handshake message is |
| 1713 | // fragmented. |
| 1714 | MaxHandshakeRecordLength: 2048, |
| 1715 | }, |
| 1716 | }, |
| 1717 | }, |
| 1718 | { |
| 1719 | protocol: dtls, |
| 1720 | name: "MixCompleteMessageWithFragments-DTLS", |
| 1721 | config: Config{ |
| 1722 | Bugs: ProtocolBugs{ |
| 1723 | ReorderHandshakeFragments: true, |
| 1724 | MixCompleteMessageWithFragments: true, |
| 1725 | MaxHandshakeRecordLength: 2, |
| 1726 | }, |
| 1727 | }, |
| 1728 | }, |
| 1729 | { |
| 1730 | name: "SendInvalidRecordType", |
| 1731 | config: Config{ |
| 1732 | Bugs: ProtocolBugs{ |
| 1733 | SendInvalidRecordType: true, |
| 1734 | }, |
| 1735 | }, |
| 1736 | shouldFail: true, |
| 1737 | expectedError: ":UNEXPECTED_RECORD:", |
| 1738 | }, |
| 1739 | { |
| 1740 | protocol: dtls, |
| 1741 | name: "SendInvalidRecordType-DTLS", |
| 1742 | config: Config{ |
| 1743 | Bugs: ProtocolBugs{ |
| 1744 | SendInvalidRecordType: true, |
| 1745 | }, |
| 1746 | }, |
| 1747 | shouldFail: true, |
| 1748 | expectedError: ":UNEXPECTED_RECORD:", |
| 1749 | }, |
| 1750 | { |
| 1751 | name: "FalseStart-SkipServerSecondLeg", |
| 1752 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1753 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1754 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1755 | NextProtos: []string{"foo"}, |
| 1756 | Bugs: ProtocolBugs{ |
| 1757 | SkipNewSessionTicket: true, |
| 1758 | SkipChangeCipherSpec: true, |
| 1759 | SkipFinished: true, |
| 1760 | ExpectFalseStart: true, |
| 1761 | }, |
| 1762 | }, |
| 1763 | flags: []string{ |
| 1764 | "-false-start", |
| 1765 | "-handshake-never-done", |
| 1766 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1767 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1768 | }, |
| 1769 | shimWritesFirst: true, |
| 1770 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1771 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1772 | }, |
| 1773 | { |
| 1774 | name: "FalseStart-SkipServerSecondLeg-Implicit", |
| 1775 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1776 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1777 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1778 | NextProtos: []string{"foo"}, |
| 1779 | Bugs: ProtocolBugs{ |
| 1780 | SkipNewSessionTicket: true, |
| 1781 | SkipChangeCipherSpec: true, |
| 1782 | SkipFinished: true, |
| 1783 | }, |
| 1784 | }, |
| 1785 | flags: []string{ |
| 1786 | "-implicit-handshake", |
| 1787 | "-false-start", |
| 1788 | "-handshake-never-done", |
| 1789 | "-advertise-alpn", "\x03foo", |
| 1790 | }, |
| 1791 | shouldFail: true, |
David Benjamin | 5aaaa98 | 2017-06-22 15:03:18 -0400 | [diff] [blame] | 1792 | expectedError: ":APPLICATION_DATA_INSTEAD_OF_HANDSHAKE:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1793 | }, |
| 1794 | { |
| 1795 | testType: serverTest, |
| 1796 | name: "FailEarlyCallback", |
| 1797 | flags: []string{"-fail-early-callback"}, |
| 1798 | shouldFail: true, |
| 1799 | expectedError: ":CONNECTION_REJECTED:", |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 1800 | expectedLocalError: "remote error: handshake failure", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1801 | }, |
| 1802 | { |
David Benjamin | b8d74f5 | 2016-11-14 22:02:50 +0900 | [diff] [blame] | 1803 | name: "FailCertCallback-Client-TLS12", |
| 1804 | config: Config{ |
| 1805 | MaxVersion: VersionTLS12, |
| 1806 | ClientAuth: RequestClientCert, |
| 1807 | }, |
| 1808 | flags: []string{"-fail-cert-callback"}, |
| 1809 | shouldFail: true, |
| 1810 | expectedError: ":CERT_CB_ERROR:", |
| 1811 | expectedLocalError: "remote error: internal error", |
| 1812 | }, |
| 1813 | { |
| 1814 | testType: serverTest, |
| 1815 | name: "FailCertCallback-Server-TLS12", |
| 1816 | config: Config{ |
| 1817 | MaxVersion: VersionTLS12, |
| 1818 | }, |
| 1819 | flags: []string{"-fail-cert-callback"}, |
| 1820 | shouldFail: true, |
| 1821 | expectedError: ":CERT_CB_ERROR:", |
| 1822 | expectedLocalError: "remote error: internal error", |
| 1823 | }, |
| 1824 | { |
| 1825 | name: "FailCertCallback-Client-TLS13", |
| 1826 | config: Config{ |
| 1827 | MaxVersion: VersionTLS13, |
| 1828 | ClientAuth: RequestClientCert, |
| 1829 | }, |
| 1830 | flags: []string{"-fail-cert-callback"}, |
| 1831 | shouldFail: true, |
| 1832 | expectedError: ":CERT_CB_ERROR:", |
| 1833 | expectedLocalError: "remote error: internal error", |
| 1834 | }, |
| 1835 | { |
| 1836 | testType: serverTest, |
| 1837 | name: "FailCertCallback-Server-TLS13", |
| 1838 | config: Config{ |
| 1839 | MaxVersion: VersionTLS13, |
| 1840 | }, |
| 1841 | flags: []string{"-fail-cert-callback"}, |
| 1842 | shouldFail: true, |
| 1843 | expectedError: ":CERT_CB_ERROR:", |
| 1844 | expectedLocalError: "remote error: internal error", |
| 1845 | }, |
| 1846 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1847 | protocol: dtls, |
| 1848 | name: "FragmentMessageTypeMismatch-DTLS", |
| 1849 | config: Config{ |
| 1850 | Bugs: ProtocolBugs{ |
| 1851 | MaxHandshakeRecordLength: 2, |
| 1852 | FragmentMessageTypeMismatch: true, |
| 1853 | }, |
| 1854 | }, |
| 1855 | shouldFail: true, |
| 1856 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1857 | }, |
| 1858 | { |
| 1859 | protocol: dtls, |
| 1860 | name: "FragmentMessageLengthMismatch-DTLS", |
| 1861 | config: Config{ |
| 1862 | Bugs: ProtocolBugs{ |
| 1863 | MaxHandshakeRecordLength: 2, |
| 1864 | FragmentMessageLengthMismatch: true, |
| 1865 | }, |
| 1866 | }, |
| 1867 | shouldFail: true, |
| 1868 | expectedError: ":FRAGMENT_MISMATCH:", |
| 1869 | }, |
| 1870 | { |
| 1871 | protocol: dtls, |
| 1872 | name: "SplitFragments-Header-DTLS", |
| 1873 | config: Config{ |
| 1874 | Bugs: ProtocolBugs{ |
| 1875 | SplitFragments: 2, |
| 1876 | }, |
| 1877 | }, |
| 1878 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1879 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1880 | }, |
| 1881 | { |
| 1882 | protocol: dtls, |
| 1883 | name: "SplitFragments-Boundary-DTLS", |
| 1884 | config: Config{ |
| 1885 | Bugs: ProtocolBugs{ |
| 1886 | SplitFragments: dtlsRecordHeaderLen, |
| 1887 | }, |
| 1888 | }, |
| 1889 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1890 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1891 | }, |
| 1892 | { |
| 1893 | protocol: dtls, |
| 1894 | name: "SplitFragments-Body-DTLS", |
| 1895 | config: Config{ |
| 1896 | Bugs: ProtocolBugs{ |
| 1897 | SplitFragments: dtlsRecordHeaderLen + 1, |
| 1898 | }, |
| 1899 | }, |
| 1900 | shouldFail: true, |
David Benjamin | c660417 | 2016-06-02 16:38:35 -0400 | [diff] [blame] | 1901 | expectedError: ":BAD_HANDSHAKE_RECORD:", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1902 | }, |
| 1903 | { |
| 1904 | protocol: dtls, |
| 1905 | name: "SendEmptyFragments-DTLS", |
| 1906 | config: Config{ |
| 1907 | Bugs: ProtocolBugs{ |
| 1908 | SendEmptyFragments: true, |
| 1909 | }, |
| 1910 | }, |
| 1911 | }, |
| 1912 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1913 | name: "BadFinished-Client", |
| 1914 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1915 | MaxVersion: VersionTLS12, |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1916 | Bugs: ProtocolBugs{ |
| 1917 | BadFinished: true, |
| 1918 | }, |
| 1919 | }, |
| 1920 | shouldFail: true, |
| 1921 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1922 | }, |
| 1923 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1924 | name: "BadFinished-Client-TLS13", |
| 1925 | config: Config{ |
| 1926 | MaxVersion: VersionTLS13, |
| 1927 | Bugs: ProtocolBugs{ |
| 1928 | BadFinished: true, |
| 1929 | }, |
| 1930 | }, |
| 1931 | shouldFail: true, |
| 1932 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1933 | }, |
| 1934 | { |
David Benjamin | bf82aed | 2016-03-01 22:57:40 -0500 | [diff] [blame] | 1935 | testType: serverTest, |
| 1936 | name: "BadFinished-Server", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1937 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 1938 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1939 | Bugs: ProtocolBugs{ |
| 1940 | BadFinished: true, |
| 1941 | }, |
| 1942 | }, |
| 1943 | shouldFail: true, |
| 1944 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1945 | }, |
| 1946 | { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 1947 | testType: serverTest, |
| 1948 | name: "BadFinished-Server-TLS13", |
| 1949 | config: Config{ |
| 1950 | MaxVersion: VersionTLS13, |
| 1951 | Bugs: ProtocolBugs{ |
| 1952 | BadFinished: true, |
| 1953 | }, |
| 1954 | }, |
| 1955 | shouldFail: true, |
| 1956 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1957 | }, |
| 1958 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1959 | name: "FalseStart-BadFinished", |
| 1960 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1961 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1962 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1963 | NextProtos: []string{"foo"}, |
| 1964 | Bugs: ProtocolBugs{ |
| 1965 | BadFinished: true, |
| 1966 | ExpectFalseStart: true, |
| 1967 | }, |
| 1968 | }, |
| 1969 | flags: []string{ |
| 1970 | "-false-start", |
| 1971 | "-handshake-never-done", |
| 1972 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 1973 | "-expect-alpn", "foo", |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1974 | }, |
| 1975 | shimWritesFirst: true, |
| 1976 | shouldFail: true, |
| 1977 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 1978 | }, |
| 1979 | { |
| 1980 | name: "NoFalseStart-NoALPN", |
| 1981 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 1982 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 1983 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 1984 | Bugs: ProtocolBugs{ |
| 1985 | ExpectFalseStart: true, |
| 1986 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 1987 | }, |
| 1988 | }, |
| 1989 | flags: []string{ |
| 1990 | "-false-start", |
| 1991 | }, |
| 1992 | shimWritesFirst: true, |
| 1993 | shouldFail: true, |
| 1994 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 1995 | expectedLocalError: "tls: peer did not false start: EOF", |
| 1996 | }, |
| 1997 | { |
| 1998 | name: "NoFalseStart-NoAEAD", |
| 1999 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2000 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2001 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 2002 | NextProtos: []string{"foo"}, |
| 2003 | Bugs: ProtocolBugs{ |
| 2004 | ExpectFalseStart: true, |
| 2005 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2006 | }, |
| 2007 | }, |
| 2008 | flags: []string{ |
| 2009 | "-false-start", |
| 2010 | "-advertise-alpn", "\x03foo", |
| 2011 | }, |
| 2012 | shimWritesFirst: true, |
| 2013 | shouldFail: true, |
| 2014 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2015 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2016 | }, |
| 2017 | { |
| 2018 | name: "NoFalseStart-RSA", |
| 2019 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2020 | MaxVersion: VersionTLS12, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2021 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 2022 | NextProtos: []string{"foo"}, |
| 2023 | Bugs: ProtocolBugs{ |
| 2024 | ExpectFalseStart: true, |
| 2025 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 2026 | }, |
| 2027 | }, |
| 2028 | flags: []string{ |
| 2029 | "-false-start", |
| 2030 | "-advertise-alpn", "\x03foo", |
| 2031 | }, |
| 2032 | shimWritesFirst: true, |
| 2033 | shouldFail: true, |
| 2034 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 2035 | expectedLocalError: "tls: peer did not false start: EOF", |
| 2036 | }, |
| 2037 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2038 | protocol: dtls, |
| 2039 | name: "SendSplitAlert-Sync", |
| 2040 | config: Config{ |
| 2041 | Bugs: ProtocolBugs{ |
| 2042 | SendSplitAlert: true, |
| 2043 | }, |
| 2044 | }, |
| 2045 | }, |
| 2046 | { |
| 2047 | protocol: dtls, |
| 2048 | name: "SendSplitAlert-Async", |
| 2049 | config: Config{ |
| 2050 | Bugs: ProtocolBugs{ |
| 2051 | SendSplitAlert: true, |
| 2052 | }, |
| 2053 | }, |
| 2054 | flags: []string{"-async"}, |
| 2055 | }, |
| 2056 | { |
| 2057 | protocol: dtls, |
| 2058 | name: "PackDTLSHandshake", |
| 2059 | config: Config{ |
| 2060 | Bugs: ProtocolBugs{ |
| 2061 | MaxHandshakeRecordLength: 2, |
| 2062 | PackHandshakeFragments: 20, |
| 2063 | PackHandshakeRecords: 200, |
| 2064 | }, |
| 2065 | }, |
| 2066 | }, |
| 2067 | { |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2068 | name: "SendEmptyRecords-Pass", |
| 2069 | sendEmptyRecords: 32, |
| 2070 | }, |
| 2071 | { |
| 2072 | name: "SendEmptyRecords", |
| 2073 | sendEmptyRecords: 33, |
| 2074 | shouldFail: true, |
| 2075 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2076 | }, |
| 2077 | { |
| 2078 | name: "SendEmptyRecords-Async", |
| 2079 | sendEmptyRecords: 33, |
| 2080 | flags: []string{"-async"}, |
| 2081 | shouldFail: true, |
| 2082 | expectedError: ":TOO_MANY_EMPTY_FRAGMENTS:", |
| 2083 | }, |
| 2084 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2085 | name: "SendWarningAlerts-Pass", |
| 2086 | config: Config{ |
| 2087 | MaxVersion: VersionTLS12, |
| 2088 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2089 | sendWarningAlerts: 4, |
| 2090 | }, |
| 2091 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2092 | protocol: dtls, |
| 2093 | name: "SendWarningAlerts-DTLS-Pass", |
| 2094 | config: Config{ |
| 2095 | MaxVersion: VersionTLS12, |
| 2096 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2097 | sendWarningAlerts: 4, |
| 2098 | }, |
| 2099 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2100 | name: "SendWarningAlerts-TLS13", |
| 2101 | config: Config{ |
| 2102 | MaxVersion: VersionTLS13, |
| 2103 | }, |
| 2104 | sendWarningAlerts: 4, |
| 2105 | shouldFail: true, |
| 2106 | expectedError: ":BAD_ALERT:", |
| 2107 | expectedLocalError: "remote error: error decoding message", |
| 2108 | }, |
| 2109 | { |
| 2110 | name: "SendWarningAlerts", |
| 2111 | config: Config{ |
| 2112 | MaxVersion: VersionTLS12, |
| 2113 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2114 | sendWarningAlerts: 5, |
| 2115 | shouldFail: true, |
| 2116 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2117 | }, |
| 2118 | { |
David Benjamin | e8e84b9 | 2016-08-03 15:39:47 -0400 | [diff] [blame] | 2119 | name: "SendWarningAlerts-Async", |
| 2120 | config: Config{ |
| 2121 | MaxVersion: VersionTLS12, |
| 2122 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2123 | sendWarningAlerts: 5, |
| 2124 | flags: []string{"-async"}, |
| 2125 | shouldFail: true, |
| 2126 | expectedError: ":TOO_MANY_WARNING_ALERTS:", |
| 2127 | }, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2128 | { |
David Benjamin | 24e5886 | 2017-06-14 18:45:29 -0400 | [diff] [blame] | 2129 | name: "SendBogusAlertType", |
| 2130 | sendBogusAlertType: true, |
| 2131 | shouldFail: true, |
| 2132 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2133 | expectedLocalError: "remote error: illegal parameter", |
| 2134 | }, |
| 2135 | { |
| 2136 | protocol: dtls, |
| 2137 | name: "SendBogusAlertType-DTLS", |
| 2138 | sendBogusAlertType: true, |
| 2139 | shouldFail: true, |
| 2140 | expectedError: ":UNKNOWN_ALERT_TYPE:", |
| 2141 | expectedLocalError: "remote error: illegal parameter", |
| 2142 | }, |
| 2143 | { |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2144 | name: "TooManyKeyUpdates", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2145 | config: Config{ |
| 2146 | MaxVersion: VersionTLS13, |
| 2147 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2148 | sendKeyUpdates: 33, |
| 2149 | keyUpdateRequest: keyUpdateNotRequested, |
| 2150 | shouldFail: true, |
| 2151 | expectedError: ":TOO_MANY_KEY_UPDATES:", |
Steven Valdez | 32635b8 | 2016-08-16 11:25:03 -0400 | [diff] [blame] | 2152 | }, |
| 2153 | { |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2154 | name: "EmptySessionID", |
| 2155 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2156 | MaxVersion: VersionTLS12, |
David Benjamin | ba4594a | 2015-06-18 18:36:15 -0400 | [diff] [blame] | 2157 | SessionTicketsDisabled: true, |
| 2158 | }, |
| 2159 | noSessionCache: true, |
| 2160 | flags: []string{"-expect-no-session"}, |
| 2161 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 2162 | { |
| 2163 | name: "Unclean-Shutdown", |
| 2164 | config: Config{ |
| 2165 | Bugs: ProtocolBugs{ |
| 2166 | NoCloseNotify: true, |
| 2167 | ExpectCloseNotify: true, |
| 2168 | }, |
| 2169 | }, |
| 2170 | shimShutsDown: true, |
| 2171 | flags: []string{"-check-close-notify"}, |
| 2172 | shouldFail: true, |
| 2173 | expectedError: "Unexpected SSL_shutdown result: -1 != 1", |
| 2174 | }, |
| 2175 | { |
| 2176 | name: "Unclean-Shutdown-Ignored", |
| 2177 | config: Config{ |
| 2178 | Bugs: ProtocolBugs{ |
| 2179 | NoCloseNotify: true, |
| 2180 | }, |
| 2181 | }, |
| 2182 | shimShutsDown: true, |
| 2183 | }, |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2184 | { |
David Benjamin | fa214e4 | 2016-05-10 17:03:10 -0400 | [diff] [blame] | 2185 | name: "Unclean-Shutdown-Alert", |
| 2186 | config: Config{ |
| 2187 | Bugs: ProtocolBugs{ |
| 2188 | SendAlertOnShutdown: alertDecompressionFailure, |
| 2189 | ExpectCloseNotify: true, |
| 2190 | }, |
| 2191 | }, |
| 2192 | shimShutsDown: true, |
| 2193 | flags: []string{"-check-close-notify"}, |
| 2194 | shouldFail: true, |
| 2195 | expectedError: ":SSLV3_ALERT_DECOMPRESSION_FAILURE:", |
| 2196 | }, |
| 2197 | { |
David Benjamin | 4f75aaf | 2015-09-01 16:53:10 -0400 | [diff] [blame] | 2198 | name: "LargePlaintext", |
| 2199 | config: Config{ |
| 2200 | Bugs: ProtocolBugs{ |
| 2201 | SendLargeRecords: true, |
| 2202 | }, |
| 2203 | }, |
| 2204 | messageLen: maxPlaintext + 1, |
| 2205 | shouldFail: true, |
| 2206 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2207 | }, |
| 2208 | { |
| 2209 | protocol: dtls, |
| 2210 | name: "LargePlaintext-DTLS", |
| 2211 | config: Config{ |
| 2212 | Bugs: ProtocolBugs{ |
| 2213 | SendLargeRecords: true, |
| 2214 | }, |
| 2215 | }, |
| 2216 | messageLen: maxPlaintext + 1, |
| 2217 | shouldFail: true, |
| 2218 | expectedError: ":DATA_LENGTH_TOO_LONG:", |
| 2219 | }, |
| 2220 | { |
| 2221 | name: "LargeCiphertext", |
| 2222 | config: Config{ |
| 2223 | Bugs: ProtocolBugs{ |
| 2224 | SendLargeRecords: true, |
| 2225 | }, |
| 2226 | }, |
| 2227 | messageLen: maxPlaintext * 2, |
| 2228 | shouldFail: true, |
| 2229 | expectedError: ":ENCRYPTED_LENGTH_TOO_LONG:", |
| 2230 | }, |
| 2231 | { |
| 2232 | protocol: dtls, |
| 2233 | name: "LargeCiphertext-DTLS", |
| 2234 | config: Config{ |
| 2235 | Bugs: ProtocolBugs{ |
| 2236 | SendLargeRecords: true, |
| 2237 | }, |
| 2238 | }, |
| 2239 | messageLen: maxPlaintext * 2, |
| 2240 | // Unlike the other four cases, DTLS drops records which |
| 2241 | // are invalid before authentication, so the connection |
| 2242 | // does not fail. |
| 2243 | expectMessageDropped: true, |
| 2244 | }, |
David Benjamin | dd6fed9 | 2015-10-23 17:41:12 -0400 | [diff] [blame] | 2245 | { |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2246 | name: "BadHelloRequest-1", |
| 2247 | renegotiate: 1, |
| 2248 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2249 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2250 | Bugs: ProtocolBugs{ |
| 2251 | BadHelloRequest: []byte{typeHelloRequest, 0, 0, 1, 1}, |
| 2252 | }, |
| 2253 | }, |
| 2254 | flags: []string{ |
| 2255 | "-renegotiate-freely", |
| 2256 | "-expect-total-renegotiations", "1", |
| 2257 | }, |
| 2258 | shouldFail: true, |
David Benjamin | 163f29a | 2016-07-28 11:05:58 -0400 | [diff] [blame] | 2259 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2260 | }, |
| 2261 | { |
| 2262 | name: "BadHelloRequest-2", |
| 2263 | renegotiate: 1, |
| 2264 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2265 | MaxVersion: VersionTLS12, |
David Benjamin | ef5dfd2 | 2015-12-06 13:17:07 -0500 | [diff] [blame] | 2266 | Bugs: ProtocolBugs{ |
| 2267 | BadHelloRequest: []byte{typeServerKeyExchange, 0, 0, 0}, |
| 2268 | }, |
| 2269 | }, |
| 2270 | flags: []string{ |
| 2271 | "-renegotiate-freely", |
| 2272 | "-expect-total-renegotiations", "1", |
| 2273 | }, |
| 2274 | shouldFail: true, |
| 2275 | expectedError: ":BAD_HELLO_REQUEST:", |
| 2276 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2277 | { |
| 2278 | testType: serverTest, |
| 2279 | name: "SupportTicketsWithSessionID", |
| 2280 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2281 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2282 | SessionTicketsDisabled: true, |
| 2283 | }, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2284 | resumeConfig: &Config{ |
| 2285 | MaxVersion: VersionTLS12, |
| 2286 | }, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 2287 | resumeSession: true, |
| 2288 | }, |
David Benjamin | 02edcd0 | 2016-07-27 17:40:37 -0400 | [diff] [blame] | 2289 | { |
| 2290 | protocol: dtls, |
| 2291 | name: "DTLS-SendExtraFinished", |
| 2292 | config: Config{ |
| 2293 | Bugs: ProtocolBugs{ |
| 2294 | SendExtraFinished: true, |
| 2295 | }, |
| 2296 | }, |
| 2297 | shouldFail: true, |
| 2298 | expectedError: ":UNEXPECTED_RECORD:", |
| 2299 | }, |
| 2300 | { |
| 2301 | protocol: dtls, |
| 2302 | name: "DTLS-SendExtraFinished-Reordered", |
| 2303 | config: Config{ |
| 2304 | Bugs: ProtocolBugs{ |
| 2305 | MaxHandshakeRecordLength: 2, |
| 2306 | ReorderHandshakeFragments: true, |
| 2307 | SendExtraFinished: true, |
| 2308 | }, |
| 2309 | }, |
| 2310 | shouldFail: true, |
| 2311 | expectedError: ":UNEXPECTED_RECORD:", |
| 2312 | }, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2313 | { |
| 2314 | testType: serverTest, |
| 2315 | name: "V2ClientHello-EmptyRecordPrefix", |
| 2316 | config: Config{ |
| 2317 | // Choose a cipher suite that does not involve |
| 2318 | // elliptic curves, so no extensions are |
| 2319 | // involved. |
| 2320 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2321 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2322 | Bugs: ProtocolBugs{ |
| 2323 | SendV2ClientHello: true, |
| 2324 | }, |
| 2325 | }, |
| 2326 | sendPrefix: string([]byte{ |
| 2327 | byte(recordTypeHandshake), |
| 2328 | 3, 1, // version |
| 2329 | 0, 0, // length |
| 2330 | }), |
| 2331 | // A no-op empty record may not be sent before V2ClientHello. |
| 2332 | shouldFail: true, |
| 2333 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2334 | }, |
| 2335 | { |
| 2336 | testType: serverTest, |
| 2337 | name: "V2ClientHello-WarningAlertPrefix", |
| 2338 | config: Config{ |
| 2339 | // Choose a cipher suite that does not involve |
| 2340 | // elliptic curves, so no extensions are |
| 2341 | // involved. |
| 2342 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 2343 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | e97fb48 | 2016-07-29 09:23:07 -0400 | [diff] [blame] | 2344 | Bugs: ProtocolBugs{ |
| 2345 | SendV2ClientHello: true, |
| 2346 | }, |
| 2347 | }, |
| 2348 | sendPrefix: string([]byte{ |
| 2349 | byte(recordTypeAlert), |
| 2350 | 3, 1, // version |
| 2351 | 0, 2, // length |
| 2352 | alertLevelWarning, byte(alertDecompressionFailure), |
| 2353 | }), |
| 2354 | // A no-op warning alert may not be sent before V2ClientHello. |
| 2355 | shouldFail: true, |
| 2356 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 2357 | }, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2358 | { |
David Benjamin | 7ebe61a | 2017-02-10 13:14:01 -0500 | [diff] [blame] | 2359 | name: "KeyUpdate-Client", |
| 2360 | config: Config{ |
| 2361 | MaxVersion: VersionTLS13, |
| 2362 | }, |
| 2363 | sendKeyUpdates: 1, |
| 2364 | keyUpdateRequest: keyUpdateNotRequested, |
| 2365 | }, |
| 2366 | { |
| 2367 | testType: serverTest, |
| 2368 | name: "KeyUpdate-Server", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2369 | config: Config{ |
| 2370 | MaxVersion: VersionTLS13, |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2371 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 2372 | sendKeyUpdates: 1, |
| 2373 | keyUpdateRequest: keyUpdateNotRequested, |
| 2374 | }, |
| 2375 | { |
| 2376 | name: "KeyUpdate-InvalidRequestMode", |
| 2377 | config: Config{ |
| 2378 | MaxVersion: VersionTLS13, |
| 2379 | }, |
| 2380 | sendKeyUpdates: 1, |
| 2381 | keyUpdateRequest: 42, |
| 2382 | shouldFail: true, |
| 2383 | expectedError: ":DECODE_ERROR:", |
Steven Valdez | 1dc53d2 | 2016-07-26 12:27:38 -0400 | [diff] [blame] | 2384 | }, |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2385 | { |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 2386 | // Test that KeyUpdates are acknowledged properly. |
| 2387 | name: "KeyUpdate-RequestACK", |
| 2388 | config: Config{ |
| 2389 | MaxVersion: VersionTLS13, |
| 2390 | Bugs: ProtocolBugs{ |
| 2391 | RejectUnsolicitedKeyUpdate: true, |
| 2392 | }, |
| 2393 | }, |
| 2394 | // Test the shim receiving many KeyUpdates in a row. |
| 2395 | sendKeyUpdates: 5, |
| 2396 | messageCount: 5, |
| 2397 | keyUpdateRequest: keyUpdateRequested, |
| 2398 | }, |
| 2399 | { |
| 2400 | // Test that KeyUpdates are acknowledged properly if the |
| 2401 | // peer's KeyUpdate is discovered while a write is |
| 2402 | // pending. |
| 2403 | name: "KeyUpdate-RequestACK-UnfinishedWrite", |
| 2404 | config: Config{ |
| 2405 | MaxVersion: VersionTLS13, |
| 2406 | Bugs: ProtocolBugs{ |
| 2407 | RejectUnsolicitedKeyUpdate: true, |
| 2408 | }, |
| 2409 | }, |
| 2410 | // Test the shim receiving many KeyUpdates in a row. |
| 2411 | sendKeyUpdates: 5, |
| 2412 | messageCount: 5, |
| 2413 | keyUpdateRequest: keyUpdateRequested, |
| 2414 | readWithUnfinishedWrite: true, |
| 2415 | flags: []string{"-async"}, |
| 2416 | }, |
| 2417 | { |
David Benjamin | abe94e3 | 2016-09-04 14:18:58 -0400 | [diff] [blame] | 2418 | name: "SendSNIWarningAlert", |
| 2419 | config: Config{ |
| 2420 | MaxVersion: VersionTLS12, |
| 2421 | Bugs: ProtocolBugs{ |
| 2422 | SendSNIWarningAlert: true, |
| 2423 | }, |
| 2424 | }, |
| 2425 | }, |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2426 | { |
| 2427 | testType: serverTest, |
| 2428 | name: "ExtraCompressionMethods-TLS12", |
| 2429 | config: Config{ |
| 2430 | MaxVersion: VersionTLS12, |
| 2431 | Bugs: ProtocolBugs{ |
| 2432 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2433 | }, |
| 2434 | }, |
| 2435 | }, |
| 2436 | { |
| 2437 | testType: serverTest, |
| 2438 | name: "ExtraCompressionMethods-TLS13", |
| 2439 | config: Config{ |
| 2440 | MaxVersion: VersionTLS13, |
| 2441 | Bugs: ProtocolBugs{ |
| 2442 | SendCompressionMethods: []byte{1, 2, 3, compressionNone, 4, 5, 6}, |
| 2443 | }, |
| 2444 | }, |
| 2445 | shouldFail: true, |
| 2446 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2447 | expectedLocalError: "remote error: illegal parameter", |
| 2448 | }, |
| 2449 | { |
| 2450 | testType: serverTest, |
| 2451 | name: "NoNullCompression-TLS12", |
| 2452 | config: Config{ |
| 2453 | MaxVersion: VersionTLS12, |
| 2454 | Bugs: ProtocolBugs{ |
| 2455 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2456 | }, |
| 2457 | }, |
| 2458 | shouldFail: true, |
David Benjamin | daa0539 | 2017-02-02 23:33:21 -0500 | [diff] [blame] | 2459 | expectedError: ":INVALID_COMPRESSION_LIST:", |
David Benjamin | c241d79 | 2016-09-09 10:34:20 -0400 | [diff] [blame] | 2460 | expectedLocalError: "remote error: illegal parameter", |
| 2461 | }, |
| 2462 | { |
| 2463 | testType: serverTest, |
| 2464 | name: "NoNullCompression-TLS13", |
| 2465 | config: Config{ |
| 2466 | MaxVersion: VersionTLS13, |
| 2467 | Bugs: ProtocolBugs{ |
| 2468 | SendCompressionMethods: []byte{1, 2, 3, 4, 5, 6}, |
| 2469 | }, |
| 2470 | }, |
| 2471 | shouldFail: true, |
| 2472 | expectedError: ":INVALID_COMPRESSION_LIST:", |
| 2473 | expectedLocalError: "remote error: illegal parameter", |
| 2474 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2475 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2476 | name: "GREASE-Client-TLS12", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2477 | config: Config{ |
| 2478 | MaxVersion: VersionTLS12, |
| 2479 | Bugs: ProtocolBugs{ |
| 2480 | ExpectGREASE: true, |
| 2481 | }, |
| 2482 | }, |
| 2483 | flags: []string{"-enable-grease"}, |
| 2484 | }, |
| 2485 | { |
David Benjamin | 1a5e8ec | 2016-10-07 15:19:18 -0400 | [diff] [blame] | 2486 | name: "GREASE-Client-TLS13", |
| 2487 | config: Config{ |
| 2488 | MaxVersion: VersionTLS13, |
| 2489 | Bugs: ProtocolBugs{ |
| 2490 | ExpectGREASE: true, |
| 2491 | }, |
| 2492 | }, |
| 2493 | flags: []string{"-enable-grease"}, |
| 2494 | }, |
| 2495 | { |
| 2496 | testType: serverTest, |
| 2497 | name: "GREASE-Server-TLS13", |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2498 | config: Config{ |
| 2499 | MaxVersion: VersionTLS13, |
| 2500 | Bugs: ProtocolBugs{ |
David Benjamin | 079b394 | 2016-10-20 13:19:20 -0400 | [diff] [blame] | 2501 | // TLS 1.3 servers are expected to |
| 2502 | // always enable GREASE. TLS 1.3 is new, |
| 2503 | // so there is no existing ecosystem to |
| 2504 | // worry about. |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2505 | ExpectGREASE: true, |
| 2506 | }, |
| 2507 | }, |
David Benjamin | 65ac997 | 2016-09-02 21:35:25 -0400 | [diff] [blame] | 2508 | }, |
David Benjamin | e3fbb36 | 2017-01-06 16:19:28 -0500 | [diff] [blame] | 2509 | { |
| 2510 | // Test the server so there is a large certificate as |
| 2511 | // well as application data. |
| 2512 | testType: serverTest, |
| 2513 | name: "MaxSendFragment", |
| 2514 | config: Config{ |
| 2515 | Bugs: ProtocolBugs{ |
| 2516 | MaxReceivePlaintext: 512, |
| 2517 | }, |
| 2518 | }, |
| 2519 | messageLen: 1024, |
| 2520 | flags: []string{ |
| 2521 | "-max-send-fragment", "512", |
| 2522 | "-read-size", "1024", |
| 2523 | }, |
| 2524 | }, |
| 2525 | { |
| 2526 | // Test the server so there is a large certificate as |
| 2527 | // well as application data. |
| 2528 | testType: serverTest, |
| 2529 | name: "MaxSendFragment-TooLarge", |
| 2530 | config: Config{ |
| 2531 | Bugs: ProtocolBugs{ |
| 2532 | // Ensure that some of the records are |
| 2533 | // 512. |
| 2534 | MaxReceivePlaintext: 511, |
| 2535 | }, |
| 2536 | }, |
| 2537 | messageLen: 1024, |
| 2538 | flags: []string{ |
| 2539 | "-max-send-fragment", "512", |
| 2540 | "-read-size", "1024", |
| 2541 | }, |
| 2542 | shouldFail: true, |
| 2543 | expectedLocalError: "local error: record overflow", |
| 2544 | }, |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2545 | } |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2546 | testCases = append(testCases, basicTests...) |
David Benjamin | a252b34 | 2016-09-26 19:57:53 -0400 | [diff] [blame] | 2547 | |
| 2548 | // Test that very large messages can be received. |
| 2549 | cert := rsaCertificate |
| 2550 | for i := 0; i < 50; i++ { |
| 2551 | cert.Certificate = append(cert.Certificate, cert.Certificate[0]) |
| 2552 | } |
| 2553 | testCases = append(testCases, testCase{ |
| 2554 | name: "LargeMessage", |
| 2555 | config: Config{ |
| 2556 | Certificates: []Certificate{cert}, |
| 2557 | }, |
| 2558 | }) |
| 2559 | testCases = append(testCases, testCase{ |
| 2560 | protocol: dtls, |
| 2561 | name: "LargeMessage-DTLS", |
| 2562 | config: Config{ |
| 2563 | Certificates: []Certificate{cert}, |
| 2564 | }, |
| 2565 | }) |
| 2566 | |
| 2567 | // They are rejected if the maximum certificate chain length is capped. |
| 2568 | testCases = append(testCases, testCase{ |
| 2569 | name: "LargeMessage-Reject", |
| 2570 | config: Config{ |
| 2571 | Certificates: []Certificate{cert}, |
| 2572 | }, |
| 2573 | flags: []string{"-max-cert-list", "16384"}, |
| 2574 | shouldFail: true, |
| 2575 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2576 | }) |
| 2577 | testCases = append(testCases, testCase{ |
| 2578 | protocol: dtls, |
| 2579 | name: "LargeMessage-Reject-DTLS", |
| 2580 | config: Config{ |
| 2581 | Certificates: []Certificate{cert}, |
| 2582 | }, |
| 2583 | flags: []string{"-max-cert-list", "16384"}, |
| 2584 | shouldFail: true, |
| 2585 | expectedError: ":EXCESSIVE_MESSAGE_SIZE:", |
| 2586 | }) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 2587 | } |
| 2588 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2589 | func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) { |
| 2590 | const psk = "12345" |
| 2591 | const pskIdentity = "luggage combo" |
| 2592 | |
| 2593 | var prefix string |
| 2594 | if protocol == dtls { |
| 2595 | if !ver.hasDTLS { |
| 2596 | return |
| 2597 | } |
| 2598 | prefix = "D" |
| 2599 | } |
| 2600 | |
| 2601 | var cert Certificate |
| 2602 | var certFile string |
| 2603 | var keyFile string |
| 2604 | if hasComponent(suite.name, "ECDSA") { |
| 2605 | cert = ecdsaP256Certificate |
| 2606 | certFile = ecdsaP256CertificateFile |
| 2607 | keyFile = ecdsaP256KeyFile |
| 2608 | } else { |
| 2609 | cert = rsaCertificate |
| 2610 | certFile = rsaCertificateFile |
| 2611 | keyFile = rsaKeyFile |
| 2612 | } |
| 2613 | |
| 2614 | var flags []string |
| 2615 | if hasComponent(suite.name, "PSK") { |
| 2616 | flags = append(flags, |
| 2617 | "-psk", psk, |
| 2618 | "-psk-identity", pskIdentity) |
| 2619 | } |
| 2620 | if hasComponent(suite.name, "NULL") { |
| 2621 | // NULL ciphers must be explicitly enabled. |
| 2622 | flags = append(flags, "-cipher", "DEFAULT:NULL-SHA") |
| 2623 | } |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2624 | |
| 2625 | var shouldServerFail, shouldClientFail bool |
| 2626 | if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 { |
| 2627 | // BoringSSL clients accept ECDHE on SSLv3, but |
| 2628 | // a BoringSSL server will never select it |
| 2629 | // because the extension is missing. |
| 2630 | shouldServerFail = true |
| 2631 | } |
| 2632 | if isTLS12Only(suite.name) && ver.version < VersionTLS12 { |
| 2633 | shouldClientFail = true |
| 2634 | shouldServerFail = true |
| 2635 | } |
| 2636 | if !isTLS13Suite(suite.name) && ver.version >= VersionTLS13 { |
| 2637 | shouldClientFail = true |
| 2638 | shouldServerFail = true |
| 2639 | } |
| 2640 | if isTLS13Suite(suite.name) && ver.version < VersionTLS13 { |
| 2641 | shouldClientFail = true |
| 2642 | shouldServerFail = true |
| 2643 | } |
| 2644 | if !isDTLSCipher(suite.name) && protocol == dtls { |
| 2645 | shouldClientFail = true |
| 2646 | shouldServerFail = true |
| 2647 | } |
| 2648 | |
| 2649 | var sendCipherSuite uint16 |
| 2650 | var expectedServerError, expectedClientError string |
| 2651 | serverCipherSuites := []uint16{suite.id} |
| 2652 | if shouldServerFail { |
| 2653 | expectedServerError = ":NO_SHARED_CIPHER:" |
| 2654 | } |
| 2655 | if shouldClientFail { |
| 2656 | expectedClientError = ":WRONG_CIPHER_RETURNED:" |
| 2657 | // Configure the server to select ciphers as normal but |
| 2658 | // select an incompatible cipher in ServerHello. |
| 2659 | serverCipherSuites = nil |
| 2660 | sendCipherSuite = suite.id |
| 2661 | } |
| 2662 | |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2663 | // For cipher suites and versions where exporters are defined, verify |
| 2664 | // that they interoperate. |
| 2665 | var exportKeyingMaterial int |
| 2666 | if ver.version > VersionSSL30 { |
| 2667 | exportKeyingMaterial = 1024 |
| 2668 | } |
| 2669 | |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2670 | testCases = append(testCases, testCase{ |
| 2671 | testType: serverTest, |
| 2672 | protocol: protocol, |
| 2673 | name: prefix + ver.name + "-" + suite.name + "-server", |
| 2674 | config: Config{ |
| 2675 | MinVersion: ver.version, |
| 2676 | MaxVersion: ver.version, |
| 2677 | CipherSuites: []uint16{suite.id}, |
| 2678 | Certificates: []Certificate{cert}, |
| 2679 | PreSharedKey: []byte(psk), |
| 2680 | PreSharedKeyIdentity: pskIdentity, |
| 2681 | Bugs: ProtocolBugs{ |
| 2682 | AdvertiseAllConfiguredCiphers: true, |
| 2683 | }, |
| 2684 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2685 | certFile: certFile, |
| 2686 | keyFile: keyFile, |
| 2687 | flags: flags, |
| 2688 | resumeSession: true, |
| 2689 | shouldFail: shouldServerFail, |
| 2690 | expectedError: expectedServerError, |
| 2691 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2692 | }) |
| 2693 | |
| 2694 | testCases = append(testCases, testCase{ |
| 2695 | testType: clientTest, |
| 2696 | protocol: protocol, |
| 2697 | name: prefix + ver.name + "-" + suite.name + "-client", |
| 2698 | config: Config{ |
| 2699 | MinVersion: ver.version, |
| 2700 | MaxVersion: ver.version, |
| 2701 | CipherSuites: serverCipherSuites, |
| 2702 | Certificates: []Certificate{cert}, |
| 2703 | PreSharedKey: []byte(psk), |
| 2704 | PreSharedKeyIdentity: pskIdentity, |
| 2705 | Bugs: ProtocolBugs{ |
| 2706 | IgnorePeerCipherPreferences: shouldClientFail, |
| 2707 | SendCipherSuite: sendCipherSuite, |
| 2708 | }, |
| 2709 | }, |
David Benjamin | cdb6fe9 | 2017-02-07 16:06:48 -0500 | [diff] [blame] | 2710 | flags: flags, |
| 2711 | resumeSession: true, |
| 2712 | shouldFail: shouldClientFail, |
| 2713 | expectedError: expectedClientError, |
| 2714 | exportKeyingMaterial: exportKeyingMaterial, |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2715 | }) |
| 2716 | |
David Benjamin | 6f600d6 | 2016-12-21 16:06:54 -0500 | [diff] [blame] | 2717 | if shouldClientFail { |
| 2718 | return |
| 2719 | } |
| 2720 | |
| 2721 | // Ensure the maximum record size is accepted. |
| 2722 | testCases = append(testCases, testCase{ |
| 2723 | protocol: protocol, |
| 2724 | name: prefix + ver.name + "-" + suite.name + "-LargeRecord", |
| 2725 | config: Config{ |
| 2726 | MinVersion: ver.version, |
| 2727 | MaxVersion: ver.version, |
| 2728 | CipherSuites: []uint16{suite.id}, |
| 2729 | Certificates: []Certificate{cert}, |
| 2730 | PreSharedKey: []byte(psk), |
| 2731 | PreSharedKeyIdentity: pskIdentity, |
| 2732 | }, |
| 2733 | flags: flags, |
| 2734 | messageLen: maxPlaintext, |
| 2735 | }) |
| 2736 | |
| 2737 | // Test bad records for all ciphers. Bad records are fatal in TLS |
| 2738 | // and ignored in DTLS. |
| 2739 | var shouldFail bool |
| 2740 | var expectedError string |
| 2741 | if protocol == tls { |
| 2742 | shouldFail = true |
| 2743 | expectedError = ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:" |
| 2744 | } |
| 2745 | |
| 2746 | testCases = append(testCases, testCase{ |
| 2747 | protocol: protocol, |
| 2748 | name: prefix + ver.name + "-" + suite.name + "-BadRecord", |
| 2749 | config: Config{ |
| 2750 | MinVersion: ver.version, |
| 2751 | MaxVersion: ver.version, |
| 2752 | CipherSuites: []uint16{suite.id}, |
| 2753 | Certificates: []Certificate{cert}, |
| 2754 | PreSharedKey: []byte(psk), |
| 2755 | PreSharedKeyIdentity: pskIdentity, |
| 2756 | }, |
| 2757 | flags: flags, |
| 2758 | damageFirstWrite: true, |
| 2759 | messageLen: maxPlaintext, |
| 2760 | shouldFail: shouldFail, |
| 2761 | expectedError: expectedError, |
| 2762 | }) |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2763 | } |
| 2764 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2765 | func addCipherSuiteTests() { |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2766 | const bogusCipher = 0xfe00 |
| 2767 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2768 | for _, suite := range testCipherSuites { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2769 | for _, ver := range tlsVersions { |
David Benjamin | 0407e76 | 2016-06-17 16:41:18 -0400 | [diff] [blame] | 2770 | for _, protocol := range []protocol{tls, dtls} { |
David Benjamin | aa01204 | 2016-12-10 13:33:05 -0500 | [diff] [blame] | 2771 | addTestForCipherSuite(suite, ver, protocol) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 2772 | } |
David Benjamin | 2c99d28 | 2015-09-01 10:23:00 -0400 | [diff] [blame] | 2773 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2774 | } |
Adam Langley | a7997f1 | 2015-05-14 17:38:50 -0700 | [diff] [blame] | 2775 | |
| 2776 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2777 | name: "NoSharedCipher", |
| 2778 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2779 | MaxVersion: VersionTLS12, |
| 2780 | CipherSuites: []uint16{}, |
| 2781 | }, |
| 2782 | shouldFail: true, |
| 2783 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2784 | }) |
| 2785 | |
| 2786 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 2787 | name: "NoSharedCipher-TLS13", |
| 2788 | config: Config{ |
| 2789 | MaxVersion: VersionTLS13, |
| 2790 | CipherSuites: []uint16{}, |
| 2791 | }, |
| 2792 | shouldFail: true, |
| 2793 | expectedError: ":HANDSHAKE_FAILURE_ON_CLIENT_HELLO:", |
| 2794 | }) |
| 2795 | |
| 2796 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2797 | name: "UnsupportedCipherSuite", |
| 2798 | config: Config{ |
| 2799 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2800 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2801 | Bugs: ProtocolBugs{ |
| 2802 | IgnorePeerCipherPreferences: true, |
| 2803 | }, |
| 2804 | }, |
Matt Braithwaite | 9c8c418 | 2016-08-24 14:36:54 -0700 | [diff] [blame] | 2805 | flags: []string{"-cipher", "DEFAULT:!AES"}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 2806 | shouldFail: true, |
| 2807 | expectedError: ":WRONG_CIPHER_RETURNED:", |
| 2808 | }) |
| 2809 | |
| 2810 | testCases = append(testCases, testCase{ |
David Benjamin | e470e66 | 2016-07-18 15:47:32 +0200 | [diff] [blame] | 2811 | name: "ServerHelloBogusCipher", |
| 2812 | config: Config{ |
| 2813 | MaxVersion: VersionTLS12, |
| 2814 | Bugs: ProtocolBugs{ |
| 2815 | SendCipherSuite: bogusCipher, |
| 2816 | }, |
| 2817 | }, |
| 2818 | shouldFail: true, |
| 2819 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2820 | }) |
| 2821 | testCases = append(testCases, testCase{ |
| 2822 | name: "ServerHelloBogusCipher-TLS13", |
| 2823 | config: Config{ |
| 2824 | MaxVersion: VersionTLS13, |
| 2825 | Bugs: ProtocolBugs{ |
| 2826 | SendCipherSuite: bogusCipher, |
| 2827 | }, |
| 2828 | }, |
| 2829 | shouldFail: true, |
| 2830 | expectedError: ":UNKNOWN_CIPHER_RETURNED:", |
| 2831 | }) |
| 2832 | |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2833 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2834 | testCases = append(testCases, testCase{ |
| 2835 | testType: serverTest, |
| 2836 | name: "UnknownCipher", |
| 2837 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2838 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2839 | CipherSuites: []uint16{bogusCipher, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2840 | Bugs: ProtocolBugs{ |
| 2841 | AdvertiseAllConfiguredCiphers: true, |
| 2842 | }, |
| 2843 | }, |
| 2844 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2845 | |
| 2846 | // The server must be tolerant to bogus ciphers. |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2847 | testCases = append(testCases, testCase{ |
| 2848 | testType: serverTest, |
| 2849 | name: "UnknownCipher-TLS13", |
| 2850 | config: Config{ |
| 2851 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2852 | CipherSuites: []uint16{bogusCipher, TLS_AES_128_GCM_SHA256}, |
David Benjamin | 5ecb88b | 2016-10-04 17:51:35 -0400 | [diff] [blame] | 2853 | Bugs: ProtocolBugs{ |
| 2854 | AdvertiseAllConfiguredCiphers: true, |
| 2855 | }, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 2856 | }, |
| 2857 | }) |
| 2858 | |
David Benjamin | 7867934 | 2016-09-16 19:42:05 -0400 | [diff] [blame] | 2859 | // Test empty ECDHE_PSK identity hints work as expected. |
| 2860 | testCases = append(testCases, testCase{ |
| 2861 | name: "EmptyECDHEPSKHint", |
| 2862 | config: Config{ |
| 2863 | MaxVersion: VersionTLS12, |
| 2864 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 2865 | PreSharedKey: []byte("secret"), |
| 2866 | }, |
| 2867 | flags: []string{"-psk", "secret"}, |
| 2868 | }) |
| 2869 | |
| 2870 | // Test empty PSK identity hints work as expected, even if an explicit |
| 2871 | // ServerKeyExchange is sent. |
| 2872 | testCases = append(testCases, testCase{ |
| 2873 | name: "ExplicitEmptyPSKHint", |
| 2874 | config: Config{ |
| 2875 | MaxVersion: VersionTLS12, |
| 2876 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 2877 | PreSharedKey: []byte("secret"), |
| 2878 | Bugs: ProtocolBugs{ |
| 2879 | AlwaysSendPreSharedKeyIdentityHint: true, |
| 2880 | }, |
| 2881 | }, |
| 2882 | flags: []string{"-psk", "secret"}, |
| 2883 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 2884 | |
| 2885 | // Test that clients enforce that the server-sent certificate and cipher |
| 2886 | // suite match in TLS 1.2. |
| 2887 | testCases = append(testCases, testCase{ |
| 2888 | name: "CertificateCipherMismatch-RSA", |
| 2889 | config: Config{ |
| 2890 | MaxVersion: VersionTLS12, |
| 2891 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2892 | Certificates: []Certificate{rsaCertificate}, |
| 2893 | Bugs: ProtocolBugs{ |
| 2894 | SendCipherSuite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 2895 | }, |
| 2896 | }, |
| 2897 | shouldFail: true, |
| 2898 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 2899 | }) |
| 2900 | testCases = append(testCases, testCase{ |
| 2901 | name: "CertificateCipherMismatch-ECDSA", |
| 2902 | config: Config{ |
| 2903 | MaxVersion: VersionTLS12, |
| 2904 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 2905 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2906 | Bugs: ProtocolBugs{ |
| 2907 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 2908 | }, |
| 2909 | }, |
| 2910 | shouldFail: true, |
| 2911 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 2912 | }) |
| 2913 | testCases = append(testCases, testCase{ |
| 2914 | name: "CertificateCipherMismatch-Ed25519", |
| 2915 | config: Config{ |
| 2916 | MaxVersion: VersionTLS12, |
| 2917 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 2918 | Certificates: []Certificate{ed25519Certificate}, |
| 2919 | Bugs: ProtocolBugs{ |
| 2920 | SendCipherSuite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 2921 | }, |
| 2922 | }, |
| 2923 | shouldFail: true, |
| 2924 | expectedError: ":WRONG_CERTIFICATE_TYPE:", |
| 2925 | }) |
| 2926 | |
| 2927 | // Test that servers decline to select a cipher suite which is |
| 2928 | // inconsistent with their configured certificate. |
| 2929 | testCases = append(testCases, testCase{ |
| 2930 | testType: serverTest, |
| 2931 | name: "ServerCipherFilter-RSA", |
| 2932 | config: Config{ |
| 2933 | MaxVersion: VersionTLS12, |
| 2934 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 2935 | }, |
| 2936 | flags: []string{ |
| 2937 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 2938 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 2939 | }, |
| 2940 | shouldFail: true, |
| 2941 | expectedError: ":NO_SHARED_CIPHER:", |
| 2942 | }) |
| 2943 | testCases = append(testCases, testCase{ |
| 2944 | testType: serverTest, |
| 2945 | name: "ServerCipherFilter-ECDSA", |
| 2946 | config: Config{ |
| 2947 | MaxVersion: VersionTLS12, |
| 2948 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2949 | }, |
| 2950 | flags: []string{ |
| 2951 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 2952 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 2953 | }, |
| 2954 | shouldFail: true, |
| 2955 | expectedError: ":NO_SHARED_CIPHER:", |
| 2956 | }) |
| 2957 | testCases = append(testCases, testCase{ |
| 2958 | testType: serverTest, |
| 2959 | name: "ServerCipherFilter-Ed25519", |
| 2960 | config: Config{ |
| 2961 | MaxVersion: VersionTLS12, |
| 2962 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 2963 | }, |
| 2964 | flags: []string{ |
| 2965 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 2966 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 2967 | }, |
| 2968 | shouldFail: true, |
| 2969 | expectedError: ":NO_SHARED_CIPHER:", |
| 2970 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2971 | } |
| 2972 | |
| 2973 | func addBadECDSASignatureTests() { |
| 2974 | for badR := BadValue(1); badR < NumBadValues; badR++ { |
| 2975 | for badS := BadValue(1); badS < NumBadValues; badS++ { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 2976 | testCases = append(testCases, testCase{ |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2977 | name: fmt.Sprintf("BadECDSA-%d-%d", badR, badS), |
| 2978 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2979 | MaxVersion: VersionTLS12, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2980 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 2981 | Certificates: []Certificate{ecdsaP256Certificate}, |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2982 | Bugs: ProtocolBugs{ |
| 2983 | BadECDSAR: badR, |
| 2984 | BadECDSAS: badS, |
| 2985 | }, |
| 2986 | }, |
| 2987 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 2988 | expectedError: ":BAD_SIGNATURE:", |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 2989 | }) |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 2990 | testCases = append(testCases, testCase{ |
| 2991 | name: fmt.Sprintf("BadECDSA-%d-%d-TLS13", badR, badS), |
| 2992 | config: Config{ |
| 2993 | MaxVersion: VersionTLS13, |
| 2994 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 2995 | Bugs: ProtocolBugs{ |
| 2996 | BadECDSAR: badR, |
| 2997 | BadECDSAS: badS, |
| 2998 | }, |
| 2999 | }, |
| 3000 | shouldFail: true, |
| 3001 | expectedError: ":BAD_SIGNATURE:", |
| 3002 | }) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3003 | } |
| 3004 | } |
| 3005 | } |
| 3006 | |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3007 | func addCBCPaddingTests() { |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3008 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3009 | name: "MaxCBCPadding", |
| 3010 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3011 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3012 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3013 | Bugs: ProtocolBugs{ |
| 3014 | MaxPadding: true, |
| 3015 | }, |
| 3016 | }, |
| 3017 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3018 | }) |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3019 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3020 | name: "BadCBCPadding", |
| 3021 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3022 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3023 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3024 | Bugs: ProtocolBugs{ |
| 3025 | PaddingFirstByteBad: true, |
| 3026 | }, |
| 3027 | }, |
| 3028 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3029 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3030 | }) |
| 3031 | // OpenSSL previously had an issue where the first byte of padding in |
| 3032 | // 255 bytes of padding wasn't checked. |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 3033 | testCases = append(testCases, testCase{ |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3034 | name: "BadCBCPadding255", |
| 3035 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3036 | MaxVersion: VersionTLS12, |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3037 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3038 | Bugs: ProtocolBugs{ |
| 3039 | MaxPadding: true, |
| 3040 | PaddingFirstByteBadIf255: true, |
| 3041 | }, |
| 3042 | }, |
| 3043 | messageLen: 12, // 20 bytes of SHA-1 + 12 == 0 % block size |
| 3044 | shouldFail: true, |
David Benjamin | 11d50f9 | 2016-03-10 15:55:45 -0500 | [diff] [blame] | 3045 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 3046 | }) |
| 3047 | } |
| 3048 | |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3049 | func addCBCSplittingTests() { |
| 3050 | testCases = append(testCases, testCase{ |
| 3051 | name: "CBCRecordSplitting", |
| 3052 | config: Config{ |
| 3053 | MaxVersion: VersionTLS10, |
| 3054 | MinVersion: VersionTLS10, |
| 3055 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3056 | }, |
David Benjamin | ac8302a | 2015-09-01 17:18:15 -0400 | [diff] [blame] | 3057 | messageLen: -1, // read until EOF |
| 3058 | resumeSession: true, |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3059 | flags: []string{ |
| 3060 | "-async", |
| 3061 | "-write-different-record-sizes", |
| 3062 | "-cbc-record-splitting", |
| 3063 | }, |
David Benjamin | a8e3e0e | 2014-08-06 22:11:10 -0400 | [diff] [blame] | 3064 | }) |
| 3065 | testCases = append(testCases, testCase{ |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 3066 | name: "CBCRecordSplittingPartialWrite", |
| 3067 | config: Config{ |
| 3068 | MaxVersion: VersionTLS10, |
| 3069 | MinVersion: VersionTLS10, |
| 3070 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, |
| 3071 | }, |
| 3072 | messageLen: -1, // read until EOF |
| 3073 | flags: []string{ |
| 3074 | "-async", |
| 3075 | "-write-different-record-sizes", |
| 3076 | "-cbc-record-splitting", |
| 3077 | "-partial-write", |
| 3078 | }, |
| 3079 | }) |
| 3080 | } |
| 3081 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3082 | func addClientAuthTests() { |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3083 | // Add a dummy cert pool to stress certificate authority parsing. |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3084 | certPool := x509.NewCertPool() |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3085 | for _, cert := range []Certificate{rsaCertificate, rsa1024Certificate} { |
| 3086 | cert, err := x509.ParseCertificate(cert.Certificate[0]) |
| 3087 | if err != nil { |
| 3088 | panic(err) |
| 3089 | } |
| 3090 | certPool.AddCert(cert) |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3091 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3092 | caNames := certPool.Subjects() |
David Benjamin | 407a10c | 2014-07-16 12:58:59 -0400 | [diff] [blame] | 3093 | |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3094 | for _, ver := range tlsVersions { |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3095 | testCases = append(testCases, testCase{ |
| 3096 | testType: clientTest, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3097 | name: ver.name + "-Client-ClientAuth-RSA", |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3098 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3099 | MinVersion: ver.version, |
| 3100 | MaxVersion: ver.version, |
| 3101 | ClientAuth: RequireAnyClientCert, |
| 3102 | ClientCAs: certPool, |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3103 | }, |
| 3104 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3105 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3106 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3107 | }, |
| 3108 | }) |
| 3109 | testCases = append(testCases, testCase{ |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3110 | testType: serverTest, |
| 3111 | name: ver.name + "-Server-ClientAuth-RSA", |
| 3112 | config: Config{ |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3113 | MinVersion: ver.version, |
| 3114 | MaxVersion: ver.version, |
David Benjamin | 67666e7 | 2014-07-12 15:47:52 -0400 | [diff] [blame] | 3115 | Certificates: []Certificate{rsaCertificate}, |
| 3116 | }, |
| 3117 | flags: []string{"-require-any-client-certificate"}, |
| 3118 | }) |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3119 | if ver.version != VersionSSL30 { |
| 3120 | testCases = append(testCases, testCase{ |
| 3121 | testType: serverTest, |
| 3122 | name: ver.name + "-Server-ClientAuth-ECDSA", |
| 3123 | config: Config{ |
| 3124 | MinVersion: ver.version, |
| 3125 | MaxVersion: ver.version, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3126 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3127 | }, |
| 3128 | flags: []string{"-require-any-client-certificate"}, |
| 3129 | }) |
| 3130 | testCases = append(testCases, testCase{ |
| 3131 | testType: clientTest, |
| 3132 | name: ver.name + "-Client-ClientAuth-ECDSA", |
| 3133 | config: Config{ |
| 3134 | MinVersion: ver.version, |
| 3135 | MaxVersion: ver.version, |
| 3136 | ClientAuth: RequireAnyClientCert, |
| 3137 | ClientCAs: certPool, |
| 3138 | }, |
| 3139 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3140 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3141 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | e098ec2 | 2014-08-27 23:13:20 -0400 | [diff] [blame] | 3142 | }, |
| 3143 | }) |
| 3144 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3145 | |
| 3146 | testCases = append(testCases, testCase{ |
| 3147 | name: "NoClientCertificate-" + ver.name, |
| 3148 | config: Config{ |
| 3149 | MinVersion: ver.version, |
| 3150 | MaxVersion: ver.version, |
| 3151 | ClientAuth: RequireAnyClientCert, |
| 3152 | }, |
| 3153 | shouldFail: true, |
| 3154 | expectedLocalError: "client didn't provide a certificate", |
| 3155 | }) |
| 3156 | |
| 3157 | testCases = append(testCases, testCase{ |
| 3158 | // Even if not configured to expect a certificate, OpenSSL will |
| 3159 | // return X509_V_OK as the verify_result. |
| 3160 | testType: serverTest, |
| 3161 | name: "NoClientCertificateRequested-Server-" + ver.name, |
| 3162 | config: Config{ |
| 3163 | MinVersion: ver.version, |
| 3164 | MaxVersion: ver.version, |
| 3165 | }, |
| 3166 | flags: []string{ |
| 3167 | "-expect-verify-result", |
| 3168 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3169 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3170 | }) |
| 3171 | |
| 3172 | testCases = append(testCases, testCase{ |
| 3173 | // If a client certificate is not provided, OpenSSL will still |
| 3174 | // return X509_V_OK as the verify_result. |
| 3175 | testType: serverTest, |
| 3176 | name: "NoClientCertificate-Server-" + ver.name, |
| 3177 | config: Config{ |
| 3178 | MinVersion: ver.version, |
| 3179 | MaxVersion: ver.version, |
| 3180 | }, |
| 3181 | flags: []string{ |
| 3182 | "-expect-verify-result", |
| 3183 | "-verify-peer", |
| 3184 | }, |
David Benjamin | 5d9ba81 | 2016-10-07 20:51:20 -0400 | [diff] [blame] | 3185 | resumeSession: true, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3186 | }) |
| 3187 | |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3188 | certificateRequired := "remote error: certificate required" |
| 3189 | if ver.version < VersionTLS13 { |
| 3190 | // Prior to TLS 1.3, the generic handshake_failure alert |
| 3191 | // was used. |
| 3192 | certificateRequired = "remote error: handshake failure" |
| 3193 | } |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3194 | testCases = append(testCases, testCase{ |
| 3195 | testType: serverTest, |
| 3196 | name: "RequireAnyClientCertificate-" + ver.name, |
| 3197 | config: Config{ |
| 3198 | MinVersion: ver.version, |
| 3199 | MaxVersion: ver.version, |
| 3200 | }, |
David Benjamin | 1db9e1b | 2016-10-07 20:51:43 -0400 | [diff] [blame] | 3201 | flags: []string{"-require-any-client-certificate"}, |
| 3202 | shouldFail: true, |
| 3203 | expectedError: ":PEER_DID_NOT_RETURN_A_CERTIFICATE:", |
| 3204 | expectedLocalError: certificateRequired, |
Adam Langley | 3764683 | 2016-08-01 16:16:46 -0700 | [diff] [blame] | 3205 | }) |
| 3206 | |
| 3207 | if ver.version != VersionSSL30 { |
| 3208 | testCases = append(testCases, testCase{ |
| 3209 | testType: serverTest, |
| 3210 | name: "SkipClientCertificate-" + ver.name, |
| 3211 | config: Config{ |
| 3212 | MinVersion: ver.version, |
| 3213 | MaxVersion: ver.version, |
| 3214 | Bugs: ProtocolBugs{ |
| 3215 | SkipClientCertificate: true, |
| 3216 | }, |
| 3217 | }, |
| 3218 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3219 | flags: []string{"-verify-peer"}, |
| 3220 | shouldFail: true, |
| 3221 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3222 | }) |
| 3223 | } |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3224 | |
| 3225 | testCases = append(testCases, testCase{ |
| 3226 | testType: serverTest, |
| 3227 | name: ver.name + "-Server-CertReq-CA-List", |
| 3228 | config: Config{ |
| 3229 | MinVersion: ver.version, |
| 3230 | MaxVersion: ver.version, |
| 3231 | Certificates: []Certificate{rsaCertificate}, |
| 3232 | Bugs: ProtocolBugs{ |
| 3233 | ExpectCertificateReqNames: caNames, |
| 3234 | }, |
| 3235 | }, |
| 3236 | flags: []string{ |
| 3237 | "-require-any-client-certificate", |
| 3238 | "-use-client-ca-list", encodeDERValues(caNames), |
| 3239 | }, |
| 3240 | }) |
| 3241 | |
| 3242 | testCases = append(testCases, testCase{ |
| 3243 | testType: clientTest, |
| 3244 | name: ver.name + "-Client-CertReq-CA-List", |
| 3245 | config: Config{ |
| 3246 | MinVersion: ver.version, |
| 3247 | MaxVersion: ver.version, |
| 3248 | Certificates: []Certificate{rsaCertificate}, |
| 3249 | ClientAuth: RequireAnyClientCert, |
| 3250 | ClientCAs: certPool, |
| 3251 | }, |
| 3252 | flags: []string{ |
| 3253 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3254 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3255 | "-expect-client-ca-list", encodeDERValues(caNames), |
| 3256 | }, |
| 3257 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3258 | } |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3259 | |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3260 | // Client auth is only legal in certificate-based ciphers. |
| 3261 | testCases = append(testCases, testCase{ |
| 3262 | testType: clientTest, |
| 3263 | name: "ClientAuth-PSK", |
| 3264 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3265 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3266 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 3267 | PreSharedKey: []byte("secret"), |
| 3268 | ClientAuth: RequireAnyClientCert, |
| 3269 | }, |
| 3270 | flags: []string{ |
| 3271 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3272 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3273 | "-psk", "secret", |
| 3274 | }, |
| 3275 | shouldFail: true, |
| 3276 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3277 | }) |
| 3278 | testCases = append(testCases, testCase{ |
| 3279 | testType: clientTest, |
| 3280 | name: "ClientAuth-ECDHE_PSK", |
| 3281 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 3282 | MaxVersion: VersionTLS12, |
David Benjamin | c032dfa | 2016-05-12 14:54:57 -0400 | [diff] [blame] | 3283 | CipherSuites: []uint16{TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA}, |
| 3284 | PreSharedKey: []byte("secret"), |
| 3285 | ClientAuth: RequireAnyClientCert, |
| 3286 | }, |
| 3287 | flags: []string{ |
| 3288 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3289 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3290 | "-psk", "secret", |
| 3291 | }, |
| 3292 | shouldFail: true, |
| 3293 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 3294 | }) |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3295 | |
| 3296 | // Regression test for a bug where the client CA list, if explicitly |
| 3297 | // set to NULL, was mis-encoded. |
| 3298 | testCases = append(testCases, testCase{ |
| 3299 | testType: serverTest, |
| 3300 | name: "Null-Client-CA-List", |
| 3301 | config: Config{ |
| 3302 | MaxVersion: VersionTLS12, |
| 3303 | Certificates: []Certificate{rsaCertificate}, |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3304 | Bugs: ProtocolBugs{ |
| 3305 | ExpectCertificateReqNames: [][]byte{}, |
| 3306 | }, |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3307 | }, |
| 3308 | flags: []string{ |
| 3309 | "-require-any-client-certificate", |
Adam Langley | 2ff7933 | 2017-02-28 13:45:39 -0800 | [diff] [blame] | 3310 | "-use-client-ca-list", "<NULL>", |
David Benjamin | 2f8935d | 2016-07-13 19:47:39 -0400 | [diff] [blame] | 3311 | }, |
| 3312 | }) |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 3313 | } |
| 3314 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3315 | func addExtendedMasterSecretTests() { |
| 3316 | const expectEMSFlag = "-expect-extended-master-secret" |
| 3317 | |
| 3318 | for _, with := range []bool{false, true} { |
| 3319 | prefix := "No" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3320 | if with { |
| 3321 | prefix = "" |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3322 | } |
| 3323 | |
| 3324 | for _, isClient := range []bool{false, true} { |
| 3325 | suffix := "-Server" |
| 3326 | testType := serverTest |
| 3327 | if isClient { |
| 3328 | suffix = "-Client" |
| 3329 | testType = clientTest |
| 3330 | } |
| 3331 | |
| 3332 | for _, ver := range tlsVersions { |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3333 | // In TLS 1.3, the extension is irrelevant and |
| 3334 | // always reports as enabled. |
| 3335 | var flags []string |
| 3336 | if with || ver.version >= VersionTLS13 { |
| 3337 | flags = []string{expectEMSFlag} |
| 3338 | } |
| 3339 | |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3340 | test := testCase{ |
| 3341 | testType: testType, |
| 3342 | name: prefix + "ExtendedMasterSecret-" + ver.name + suffix, |
| 3343 | config: Config{ |
| 3344 | MinVersion: ver.version, |
| 3345 | MaxVersion: ver.version, |
| 3346 | Bugs: ProtocolBugs{ |
| 3347 | NoExtendedMasterSecret: !with, |
| 3348 | RequireExtendedMasterSecret: with, |
| 3349 | }, |
| 3350 | }, |
David Benjamin | 48cae08 | 2014-10-27 01:06:24 -0400 | [diff] [blame] | 3351 | flags: flags, |
| 3352 | shouldFail: ver.version == VersionSSL30 && with, |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3353 | } |
| 3354 | if test.shouldFail { |
| 3355 | test.expectedLocalError = "extended master secret required but not supported by peer" |
| 3356 | } |
| 3357 | testCases = append(testCases, test) |
| 3358 | } |
| 3359 | } |
| 3360 | } |
| 3361 | |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3362 | for _, isClient := range []bool{false, true} { |
| 3363 | for _, supportedInFirstConnection := range []bool{false, true} { |
| 3364 | for _, supportedInResumeConnection := range []bool{false, true} { |
| 3365 | boolToWord := func(b bool) string { |
| 3366 | if b { |
| 3367 | return "Yes" |
| 3368 | } |
| 3369 | return "No" |
| 3370 | } |
| 3371 | suffix := boolToWord(supportedInFirstConnection) + "To" + boolToWord(supportedInResumeConnection) + "-" |
| 3372 | if isClient { |
| 3373 | suffix += "Client" |
| 3374 | } else { |
| 3375 | suffix += "Server" |
| 3376 | } |
| 3377 | |
| 3378 | supportedConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3379 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3380 | Bugs: ProtocolBugs{ |
| 3381 | RequireExtendedMasterSecret: true, |
| 3382 | }, |
| 3383 | } |
| 3384 | |
| 3385 | noSupportConfig := Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3386 | MaxVersion: VersionTLS12, |
Adam Langley | ba5934b | 2015-06-02 10:50:35 -0700 | [diff] [blame] | 3387 | Bugs: ProtocolBugs{ |
| 3388 | NoExtendedMasterSecret: true, |
| 3389 | }, |
| 3390 | } |
| 3391 | |
| 3392 | test := testCase{ |
| 3393 | name: "ExtendedMasterSecret-" + suffix, |
| 3394 | resumeSession: true, |
| 3395 | } |
| 3396 | |
| 3397 | if !isClient { |
| 3398 | test.testType = serverTest |
| 3399 | } |
| 3400 | |
| 3401 | if supportedInFirstConnection { |
| 3402 | test.config = supportedConfig |
| 3403 | } else { |
| 3404 | test.config = noSupportConfig |
| 3405 | } |
| 3406 | |
| 3407 | if supportedInResumeConnection { |
| 3408 | test.resumeConfig = &supportedConfig |
| 3409 | } else { |
| 3410 | test.resumeConfig = &noSupportConfig |
| 3411 | } |
| 3412 | |
| 3413 | switch suffix { |
| 3414 | case "YesToYes-Client", "YesToYes-Server": |
| 3415 | // When a session is resumed, it should |
| 3416 | // still be aware that its master |
| 3417 | // secret was generated via EMS and |
| 3418 | // thus it's safe to use tls-unique. |
| 3419 | test.flags = []string{expectEMSFlag} |
| 3420 | case "NoToYes-Server": |
| 3421 | // If an original connection did not |
| 3422 | // contain EMS, but a resumption |
| 3423 | // handshake does, then a server should |
| 3424 | // not resume the session. |
| 3425 | test.expectResumeRejected = true |
| 3426 | case "YesToNo-Server": |
| 3427 | // Resuming an EMS session without the |
| 3428 | // EMS extension should cause the |
| 3429 | // server to abort the connection. |
| 3430 | test.shouldFail = true |
| 3431 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3432 | case "NoToYes-Client": |
| 3433 | // A client should abort a connection |
| 3434 | // where the server resumed a non-EMS |
| 3435 | // session but echoed the EMS |
| 3436 | // extension. |
| 3437 | test.shouldFail = true |
| 3438 | test.expectedError = ":RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION:" |
| 3439 | case "YesToNo-Client": |
| 3440 | // A client should abort a connection |
| 3441 | // where the server didn't echo EMS |
| 3442 | // when the session used it. |
| 3443 | test.shouldFail = true |
| 3444 | test.expectedError = ":RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION:" |
| 3445 | } |
| 3446 | |
| 3447 | testCases = append(testCases, test) |
| 3448 | } |
| 3449 | } |
| 3450 | } |
David Benjamin | 163c956 | 2016-08-29 23:14:17 -0400 | [diff] [blame] | 3451 | |
| 3452 | // Switching EMS on renegotiation is forbidden. |
| 3453 | testCases = append(testCases, testCase{ |
| 3454 | name: "ExtendedMasterSecret-Renego-NoEMS", |
| 3455 | config: Config{ |
| 3456 | MaxVersion: VersionTLS12, |
| 3457 | Bugs: ProtocolBugs{ |
| 3458 | NoExtendedMasterSecret: true, |
| 3459 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3460 | }, |
| 3461 | }, |
| 3462 | renegotiate: 1, |
| 3463 | flags: []string{ |
| 3464 | "-renegotiate-freely", |
| 3465 | "-expect-total-renegotiations", "1", |
| 3466 | }, |
| 3467 | }) |
| 3468 | |
| 3469 | testCases = append(testCases, testCase{ |
| 3470 | name: "ExtendedMasterSecret-Renego-Upgrade", |
| 3471 | config: Config{ |
| 3472 | MaxVersion: VersionTLS12, |
| 3473 | Bugs: ProtocolBugs{ |
| 3474 | NoExtendedMasterSecret: true, |
| 3475 | }, |
| 3476 | }, |
| 3477 | renegotiate: 1, |
| 3478 | flags: []string{ |
| 3479 | "-renegotiate-freely", |
| 3480 | "-expect-total-renegotiations", "1", |
| 3481 | }, |
| 3482 | shouldFail: true, |
| 3483 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3484 | }) |
| 3485 | |
| 3486 | testCases = append(testCases, testCase{ |
| 3487 | name: "ExtendedMasterSecret-Renego-Downgrade", |
| 3488 | config: Config{ |
| 3489 | MaxVersion: VersionTLS12, |
| 3490 | Bugs: ProtocolBugs{ |
| 3491 | NoExtendedMasterSecretOnRenegotiation: true, |
| 3492 | }, |
| 3493 | }, |
| 3494 | renegotiate: 1, |
| 3495 | flags: []string{ |
| 3496 | "-renegotiate-freely", |
| 3497 | "-expect-total-renegotiations", "1", |
| 3498 | }, |
| 3499 | shouldFail: true, |
| 3500 | expectedError: ":RENEGOTIATION_EMS_MISMATCH:", |
| 3501 | }) |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 3502 | } |
| 3503 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3504 | type stateMachineTestConfig struct { |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3505 | protocol protocol |
| 3506 | async bool |
| 3507 | splitHandshake bool |
| 3508 | packHandshakeFlight bool |
| 3509 | implicitHandshake bool |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3510 | } |
| 3511 | |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 3512 | // Adds tests that try to cover the range of the handshake state machine, under |
| 3513 | // various conditions. Some of these are redundant with other tests, but they |
| 3514 | // only cover the synchronous case. |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3515 | func addAllStateMachineCoverageTests() { |
| 3516 | for _, async := range []bool{false, true} { |
| 3517 | for _, protocol := range []protocol{tls, dtls} { |
| 3518 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3519 | protocol: protocol, |
| 3520 | async: async, |
| 3521 | }) |
| 3522 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 3523 | protocol: protocol, |
| 3524 | async: async, |
| 3525 | implicitHandshake: true, |
| 3526 | }) |
| 3527 | addStateMachineCoverageTests(stateMachineTestConfig{ |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3528 | protocol: protocol, |
| 3529 | async: async, |
| 3530 | splitHandshake: true, |
| 3531 | }) |
| 3532 | if protocol == tls { |
| 3533 | addStateMachineCoverageTests(stateMachineTestConfig{ |
| 3534 | protocol: protocol, |
| 3535 | async: async, |
| 3536 | packHandshakeFlight: true, |
| 3537 | }) |
| 3538 | } |
| 3539 | } |
| 3540 | } |
| 3541 | } |
| 3542 | |
| 3543 | func addStateMachineCoverageTests(config stateMachineTestConfig) { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3544 | var tests []testCase |
| 3545 | |
| 3546 | // Basic handshake, with resumption. Client and server, |
| 3547 | // session ID and session ticket. |
| 3548 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3549 | name: "Basic-Client", |
| 3550 | config: Config{ |
| 3551 | MaxVersion: VersionTLS12, |
| 3552 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3553 | resumeSession: true, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3554 | // Ensure session tickets are used, not session IDs. |
| 3555 | noSessionCache: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3556 | }) |
| 3557 | tests = append(tests, testCase{ |
| 3558 | name: "Basic-Client-RenewTicket", |
| 3559 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3560 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3561 | Bugs: ProtocolBugs{ |
| 3562 | RenewTicketOnResume: true, |
| 3563 | }, |
| 3564 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3565 | flags: []string{"-expect-ticket-renewal"}, |
| 3566 | resumeSession: true, |
| 3567 | resumeRenewedSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3568 | }) |
| 3569 | tests = append(tests, testCase{ |
| 3570 | name: "Basic-Client-NoTicket", |
| 3571 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3572 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3573 | SessionTicketsDisabled: true, |
| 3574 | }, |
| 3575 | resumeSession: true, |
| 3576 | }) |
| 3577 | tests = append(tests, testCase{ |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3578 | testType: serverTest, |
| 3579 | name: "Basic-Server", |
| 3580 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3581 | MaxVersion: VersionTLS12, |
David Benjamin | ef1b009 | 2015-11-21 14:05:44 -0500 | [diff] [blame] | 3582 | Bugs: ProtocolBugs{ |
| 3583 | RequireSessionTickets: true, |
| 3584 | }, |
| 3585 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3586 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3587 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3588 | }) |
| 3589 | tests = append(tests, testCase{ |
| 3590 | testType: serverTest, |
| 3591 | name: "Basic-Server-NoTickets", |
| 3592 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3593 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3594 | SessionTicketsDisabled: true, |
| 3595 | }, |
| 3596 | resumeSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3597 | flags: []string{"-expect-session-id"}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3598 | }) |
| 3599 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3600 | testType: serverTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3601 | name: "Basic-Server-EarlyCallback", |
| 3602 | config: Config{ |
| 3603 | MaxVersion: VersionTLS12, |
| 3604 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3605 | flags: []string{"-use-early-callback"}, |
| 3606 | resumeSession: true, |
| 3607 | }) |
| 3608 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3609 | // TLS 1.3 basic handshake shapes. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3610 | if config.protocol == tls { |
| 3611 | tests = append(tests, testCase{ |
| 3612 | name: "TLS13-1RTT-Client", |
| 3613 | config: Config{ |
| 3614 | MaxVersion: VersionTLS13, |
| 3615 | MinVersion: VersionTLS13, |
| 3616 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3617 | resumeSession: true, |
| 3618 | resumeRenewedSession: true, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3619 | }) |
| 3620 | |
| 3621 | tests = append(tests, testCase{ |
| 3622 | testType: serverTest, |
| 3623 | name: "TLS13-1RTT-Server", |
| 3624 | config: Config{ |
| 3625 | MaxVersion: VersionTLS13, |
| 3626 | MinVersion: VersionTLS13, |
| 3627 | }, |
David Benjamin | 4666248 | 2016-08-17 00:51:00 -0400 | [diff] [blame] | 3628 | resumeSession: true, |
| 3629 | resumeRenewedSession: true, |
David Benjamin | b5c58db | 2017-01-28 01:39:29 -0500 | [diff] [blame] | 3630 | // TLS 1.3 uses tickets, so the session should not be |
| 3631 | // cached statefully. |
| 3632 | flags: []string{"-expect-no-session-id"}, |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3633 | }) |
| 3634 | |
| 3635 | tests = append(tests, testCase{ |
| 3636 | name: "TLS13-HelloRetryRequest-Client", |
| 3637 | config: Config{ |
| 3638 | MaxVersion: VersionTLS13, |
| 3639 | MinVersion: VersionTLS13, |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 3640 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 3641 | // configuration. Assert this with ExpectMissingKeyShare. |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3642 | CurvePreferences: []CurveID{CurveP384}, |
| 3643 | Bugs: ProtocolBugs{ |
| 3644 | ExpectMissingKeyShare: true, |
| 3645 | }, |
| 3646 | }, |
| 3647 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3648 | resumeSession: true, |
| 3649 | }) |
| 3650 | |
| 3651 | tests = append(tests, testCase{ |
| 3652 | testType: serverTest, |
| 3653 | name: "TLS13-HelloRetryRequest-Server", |
| 3654 | config: Config{ |
| 3655 | MaxVersion: VersionTLS13, |
| 3656 | MinVersion: VersionTLS13, |
| 3657 | // Require a HelloRetryRequest for every curve. |
| 3658 | DefaultCurves: []CurveID{}, |
| 3659 | }, |
| 3660 | // Cover HelloRetryRequest during an ECDHE-PSK resumption. |
| 3661 | resumeSession: true, |
| 3662 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3663 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3664 | tests = append(tests, testCase{ |
| 3665 | testType: clientTest, |
| 3666 | name: "TLS13-EarlyData-Client", |
| 3667 | config: Config{ |
| 3668 | MaxVersion: VersionTLS13, |
| 3669 | MinVersion: VersionTLS13, |
| 3670 | MaxEarlyDataSize: 16384, |
| 3671 | }, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3672 | resumeConfig: &Config{ |
| 3673 | MaxVersion: VersionTLS13, |
| 3674 | MinVersion: VersionTLS13, |
| 3675 | MaxEarlyDataSize: 16384, |
| 3676 | Bugs: ProtocolBugs{ |
| 3677 | ExpectEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 3678 | }, |
| 3679 | }, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3680 | resumeSession: true, |
| 3681 | flags: []string{ |
| 3682 | "-enable-early-data", |
| 3683 | "-expect-early-data-info", |
| 3684 | "-expect-accept-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3685 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3686 | }, |
| 3687 | }) |
| 3688 | |
| 3689 | tests = append(tests, testCase{ |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 3690 | testType: clientTest, |
| 3691 | name: "TLS13-EarlyData-TooMuchData-Client", |
| 3692 | config: Config{ |
| 3693 | MaxVersion: VersionTLS13, |
| 3694 | MinVersion: VersionTLS13, |
| 3695 | MaxEarlyDataSize: 2, |
| 3696 | }, |
| 3697 | resumeConfig: &Config{ |
| 3698 | MaxVersion: VersionTLS13, |
| 3699 | MinVersion: VersionTLS13, |
| 3700 | MaxEarlyDataSize: 2, |
| 3701 | Bugs: ProtocolBugs{ |
| 3702 | ExpectEarlyData: [][]byte{{'h', 'e'}}, |
| 3703 | }, |
| 3704 | }, |
| 3705 | resumeShimPrefix: "llo", |
| 3706 | resumeSession: true, |
| 3707 | flags: []string{ |
| 3708 | "-enable-early-data", |
| 3709 | "-expect-early-data-info", |
| 3710 | "-expect-accept-early-data", |
| 3711 | "-on-resume-shim-writes-first", |
| 3712 | }, |
| 3713 | }) |
| 3714 | |
| 3715 | // Unfinished writes can only be tested when operations are async. EarlyData |
| 3716 | // can't be tested as part of an ImplicitHandshake in this case since |
| 3717 | // otherwise the early data will be sent as normal data. |
| 3718 | if config.async && !config.implicitHandshake { |
| 3719 | tests = append(tests, testCase{ |
| 3720 | testType: clientTest, |
| 3721 | name: "TLS13-EarlyData-UnfinishedWrite-Client", |
| 3722 | config: Config{ |
| 3723 | MaxVersion: VersionTLS13, |
| 3724 | MinVersion: VersionTLS13, |
| 3725 | MaxEarlyDataSize: 16384, |
| 3726 | }, |
| 3727 | resumeConfig: &Config{ |
| 3728 | MaxVersion: VersionTLS13, |
| 3729 | MinVersion: VersionTLS13, |
| 3730 | MaxEarlyDataSize: 16384, |
| 3731 | Bugs: ProtocolBugs{ |
| 3732 | ExpectLateEarlyData: [][]byte{{'h', 'e', 'l', 'l', 'o'}}, |
| 3733 | }, |
| 3734 | }, |
| 3735 | resumeSession: true, |
| 3736 | flags: []string{ |
| 3737 | "-enable-early-data", |
| 3738 | "-expect-early-data-info", |
| 3739 | "-expect-accept-early-data", |
| 3740 | "-on-resume-read-with-unfinished-write", |
| 3741 | "-on-resume-shim-writes-first", |
| 3742 | }, |
| 3743 | }) |
| 3744 | |
| 3745 | // Rejected unfinished writes are discarded (from the |
| 3746 | // perspective of the calling application) on 0-RTT |
| 3747 | // reject. |
| 3748 | tests = append(tests, testCase{ |
| 3749 | testType: clientTest, |
| 3750 | name: "TLS13-EarlyData-RejectUnfinishedWrite-Client", |
| 3751 | config: Config{ |
| 3752 | MaxVersion: VersionTLS13, |
| 3753 | MinVersion: VersionTLS13, |
| 3754 | MaxEarlyDataSize: 16384, |
| 3755 | }, |
| 3756 | resumeConfig: &Config{ |
| 3757 | MaxVersion: VersionTLS13, |
| 3758 | MinVersion: VersionTLS13, |
| 3759 | MaxEarlyDataSize: 16384, |
| 3760 | Bugs: ProtocolBugs{ |
| 3761 | AlwaysRejectEarlyData: true, |
| 3762 | }, |
| 3763 | }, |
| 3764 | resumeSession: true, |
| 3765 | flags: []string{ |
| 3766 | "-enable-early-data", |
| 3767 | "-expect-early-data-info", |
| 3768 | "-expect-reject-early-data", |
| 3769 | "-on-resume-read-with-unfinished-write", |
| 3770 | "-on-resume-shim-writes-first", |
| 3771 | }, |
| 3772 | }) |
| 3773 | } |
| 3774 | |
| 3775 | tests = append(tests, testCase{ |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3776 | testType: serverTest, |
| 3777 | name: "TLS13-EarlyData-Server", |
| 3778 | config: Config{ |
| 3779 | MaxVersion: VersionTLS13, |
| 3780 | MinVersion: VersionTLS13, |
| 3781 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 3782 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3783 | ExpectEarlyDataAccepted: true, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 3784 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3785 | }, |
| 3786 | }, |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 3787 | messageCount: 2, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3788 | resumeSession: true, |
| 3789 | flags: []string{ |
| 3790 | "-enable-early-data", |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 3791 | "-expect-accept-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 3792 | }, |
| 3793 | }) |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 3794 | |
| 3795 | tests = append(tests, testCase{ |
| 3796 | testType: serverTest, |
| 3797 | name: "TLS13-MaxEarlyData-Server", |
| 3798 | config: Config{ |
| 3799 | MaxVersion: VersionTLS13, |
| 3800 | MinVersion: VersionTLS13, |
| 3801 | Bugs: ProtocolBugs{ |
David Benjamin | 2997589 | 2017-04-27 23:47:21 -0400 | [diff] [blame] | 3802 | SendEarlyData: [][]byte{bytes.Repeat([]byte{1}, 14336+1)}, |
Alessandro Ghedini | de254b4 | 2017-04-17 19:12:33 +0100 | [diff] [blame] | 3803 | ExpectEarlyDataAccepted: true, |
| 3804 | }, |
| 3805 | }, |
| 3806 | messageCount: 2, |
| 3807 | resumeSession: true, |
| 3808 | flags: []string{ |
| 3809 | "-enable-early-data", |
| 3810 | "-expect-accept-early-data", |
| 3811 | }, |
| 3812 | shouldFail: true, |
| 3813 | expectedError: ":TOO_MUCH_READ_EARLY_DATA:", |
| 3814 | }) |
David Benjamin | e73c7f4 | 2016-08-17 00:29:33 -0400 | [diff] [blame] | 3815 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3816 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3817 | // TLS client auth. |
| 3818 | tests = append(tests, testCase{ |
| 3819 | testType: clientTest, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3820 | name: "ClientAuth-NoCertificate-Client", |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3821 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3822 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3823 | ClientAuth: RequestClientCert, |
| 3824 | }, |
| 3825 | }) |
| 3826 | tests = append(tests, testCase{ |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3827 | testType: serverTest, |
| 3828 | name: "ClientAuth-NoCertificate-Server", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3829 | config: Config{ |
| 3830 | MaxVersion: VersionTLS12, |
| 3831 | }, |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3832 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3833 | flags: []string{"-verify-peer"}, |
| 3834 | }) |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 3835 | if config.protocol == tls { |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3836 | tests = append(tests, testCase{ |
| 3837 | testType: clientTest, |
| 3838 | name: "ClientAuth-NoCertificate-Client-SSL3", |
| 3839 | config: Config{ |
| 3840 | MaxVersion: VersionSSL30, |
| 3841 | ClientAuth: RequestClientCert, |
| 3842 | }, |
| 3843 | }) |
| 3844 | tests = append(tests, testCase{ |
| 3845 | testType: serverTest, |
| 3846 | name: "ClientAuth-NoCertificate-Server-SSL3", |
| 3847 | config: Config{ |
| 3848 | MaxVersion: VersionSSL30, |
| 3849 | }, |
| 3850 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3851 | flags: []string{"-verify-peer"}, |
| 3852 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3853 | tests = append(tests, testCase{ |
| 3854 | testType: clientTest, |
| 3855 | name: "ClientAuth-NoCertificate-Client-TLS13", |
| 3856 | config: Config{ |
| 3857 | MaxVersion: VersionTLS13, |
| 3858 | ClientAuth: RequestClientCert, |
| 3859 | }, |
| 3860 | }) |
| 3861 | tests = append(tests, testCase{ |
| 3862 | testType: serverTest, |
| 3863 | name: "ClientAuth-NoCertificate-Server-TLS13", |
| 3864 | config: Config{ |
| 3865 | MaxVersion: VersionTLS13, |
| 3866 | }, |
| 3867 | // Setting SSL_VERIFY_PEER allows anonymous clients. |
| 3868 | flags: []string{"-verify-peer"}, |
| 3869 | }) |
David Benjamin | 0b7ca7d | 2016-03-10 15:44:22 -0500 | [diff] [blame] | 3870 | } |
| 3871 | tests = append(tests, testCase{ |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3872 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3873 | name: "ClientAuth-RSA-Client", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3874 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3875 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3876 | ClientAuth: RequireAnyClientCert, |
| 3877 | }, |
| 3878 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 3879 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3880 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3881 | }, |
| 3882 | }) |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3883 | tests = append(tests, testCase{ |
| 3884 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3885 | name: "ClientAuth-RSA-Client-TLS13", |
| 3886 | config: Config{ |
| 3887 | MaxVersion: VersionTLS13, |
| 3888 | ClientAuth: RequireAnyClientCert, |
| 3889 | }, |
| 3890 | flags: []string{ |
| 3891 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3892 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3893 | }, |
| 3894 | }) |
| 3895 | tests = append(tests, testCase{ |
| 3896 | testType: clientTest, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3897 | name: "ClientAuth-ECDSA-Client", |
| 3898 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3899 | MaxVersion: VersionTLS12, |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3900 | ClientAuth: RequireAnyClientCert, |
| 3901 | }, |
| 3902 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 3903 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3904 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
nagendra modadugu | 3398dbf | 2015-08-07 14:07:52 -0700 | [diff] [blame] | 3905 | }, |
| 3906 | }) |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3907 | tests = append(tests, testCase{ |
| 3908 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3909 | name: "ClientAuth-ECDSA-Client-TLS13", |
| 3910 | config: Config{ |
| 3911 | MaxVersion: VersionTLS13, |
| 3912 | ClientAuth: RequireAnyClientCert, |
| 3913 | }, |
| 3914 | flags: []string{ |
| 3915 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 3916 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 3917 | }, |
| 3918 | }) |
| 3919 | tests = append(tests, testCase{ |
| 3920 | testType: clientTest, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3921 | name: "ClientAuth-NoCertificate-OldCallback", |
| 3922 | config: Config{ |
| 3923 | MaxVersion: VersionTLS12, |
| 3924 | ClientAuth: RequestClientCert, |
| 3925 | }, |
| 3926 | flags: []string{"-use-old-client-cert-callback"}, |
| 3927 | }) |
| 3928 | tests = append(tests, testCase{ |
| 3929 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3930 | name: "ClientAuth-NoCertificate-OldCallback-TLS13", |
| 3931 | config: Config{ |
| 3932 | MaxVersion: VersionTLS13, |
| 3933 | ClientAuth: RequestClientCert, |
| 3934 | }, |
| 3935 | flags: []string{"-use-old-client-cert-callback"}, |
| 3936 | }) |
| 3937 | tests = append(tests, testCase{ |
| 3938 | testType: clientTest, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3939 | name: "ClientAuth-OldCallback", |
| 3940 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3941 | MaxVersion: VersionTLS12, |
David Benjamin | acb6dcc | 2016-03-10 09:15:01 -0500 | [diff] [blame] | 3942 | ClientAuth: RequireAnyClientCert, |
| 3943 | }, |
| 3944 | flags: []string{ |
| 3945 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3946 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3947 | "-use-old-client-cert-callback", |
| 3948 | }, |
| 3949 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3950 | tests = append(tests, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3951 | testType: clientTest, |
| 3952 | name: "ClientAuth-OldCallback-TLS13", |
| 3953 | config: Config{ |
| 3954 | MaxVersion: VersionTLS13, |
| 3955 | ClientAuth: RequireAnyClientCert, |
| 3956 | }, |
| 3957 | flags: []string{ |
| 3958 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3959 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3960 | "-use-old-client-cert-callback", |
| 3961 | }, |
| 3962 | }) |
| 3963 | tests = append(tests, testCase{ |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3964 | testType: serverTest, |
| 3965 | name: "ClientAuth-Server", |
| 3966 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3967 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3968 | Certificates: []Certificate{rsaCertificate}, |
| 3969 | }, |
| 3970 | flags: []string{"-require-any-client-certificate"}, |
| 3971 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 3972 | tests = append(tests, testCase{ |
| 3973 | testType: serverTest, |
| 3974 | name: "ClientAuth-Server-TLS13", |
| 3975 | config: Config{ |
| 3976 | MaxVersion: VersionTLS13, |
| 3977 | Certificates: []Certificate{rsaCertificate}, |
| 3978 | }, |
| 3979 | flags: []string{"-require-any-client-certificate"}, |
| 3980 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 3981 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3982 | // Test each key exchange on the server side for async keys. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 3983 | tests = append(tests, testCase{ |
| 3984 | testType: serverTest, |
| 3985 | name: "Basic-Server-RSA", |
| 3986 | config: Config{ |
| 3987 | MaxVersion: VersionTLS12, |
| 3988 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 3989 | }, |
| 3990 | flags: []string{ |
| 3991 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 3992 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 3993 | }, |
| 3994 | }) |
| 3995 | tests = append(tests, testCase{ |
| 3996 | testType: serverTest, |
| 3997 | name: "Basic-Server-ECDHE-RSA", |
| 3998 | config: Config{ |
| 3999 | MaxVersion: VersionTLS12, |
| 4000 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4001 | }, |
| 4002 | flags: []string{ |
| 4003 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 4004 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 4005 | }, |
| 4006 | }) |
| 4007 | tests = append(tests, testCase{ |
| 4008 | testType: serverTest, |
| 4009 | name: "Basic-Server-ECDHE-ECDSA", |
| 4010 | config: Config{ |
| 4011 | MaxVersion: VersionTLS12, |
| 4012 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4013 | }, |
| 4014 | flags: []string{ |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 4015 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 4016 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4017 | }, |
| 4018 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 4019 | tests = append(tests, testCase{ |
| 4020 | testType: serverTest, |
| 4021 | name: "Basic-Server-Ed25519", |
| 4022 | config: Config{ |
| 4023 | MaxVersion: VersionTLS12, |
| 4024 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 4025 | }, |
| 4026 | flags: []string{ |
| 4027 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 4028 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 4029 | "-enable-ed25519", |
| 4030 | }, |
| 4031 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4032 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4033 | // No session ticket support; server doesn't send NewSessionTicket. |
| 4034 | tests = append(tests, testCase{ |
| 4035 | name: "SessionTicketsDisabled-Client", |
| 4036 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4037 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4038 | SessionTicketsDisabled: true, |
| 4039 | }, |
| 4040 | }) |
| 4041 | tests = append(tests, testCase{ |
| 4042 | testType: serverTest, |
| 4043 | name: "SessionTicketsDisabled-Server", |
| 4044 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4045 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4046 | SessionTicketsDisabled: true, |
| 4047 | }, |
| 4048 | }) |
| 4049 | |
| 4050 | // Skip ServerKeyExchange in PSK key exchange if there's no |
| 4051 | // identity hint. |
| 4052 | tests = append(tests, testCase{ |
| 4053 | name: "EmptyPSKHint-Client", |
| 4054 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4055 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4056 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4057 | PreSharedKey: []byte("secret"), |
| 4058 | }, |
| 4059 | flags: []string{"-psk", "secret"}, |
| 4060 | }) |
| 4061 | tests = append(tests, testCase{ |
| 4062 | testType: serverTest, |
| 4063 | name: "EmptyPSKHint-Server", |
| 4064 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4065 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4066 | CipherSuites: []uint16{TLS_PSK_WITH_AES_128_CBC_SHA}, |
| 4067 | PreSharedKey: []byte("secret"), |
| 4068 | }, |
| 4069 | flags: []string{"-psk", "secret"}, |
| 4070 | }) |
| 4071 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4072 | // OCSP stapling tests. |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4073 | tests = append(tests, testCase{ |
| 4074 | testType: clientTest, |
| 4075 | name: "OCSPStapling-Client", |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4076 | config: Config{ |
| 4077 | MaxVersion: VersionTLS12, |
| 4078 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4079 | flags: []string{ |
| 4080 | "-enable-ocsp-stapling", |
| 4081 | "-expect-ocsp-response", |
| 4082 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4083 | "-verify-peer", |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4084 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4085 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4086 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4087 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4088 | testType: serverTest, |
| 4089 | name: "OCSPStapling-Server", |
| 4090 | config: Config{ |
| 4091 | MaxVersion: VersionTLS12, |
| 4092 | }, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4093 | expectedOCSPResponse: testOCSPResponse, |
| 4094 | flags: []string{ |
| 4095 | "-ocsp-response", |
| 4096 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4097 | }, |
Paul Lietar | 62be8ac | 2015-09-16 10:03:30 +0100 | [diff] [blame] | 4098 | resumeSession: true, |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4099 | }) |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4100 | tests = append(tests, testCase{ |
| 4101 | testType: clientTest, |
| 4102 | name: "OCSPStapling-Client-TLS13", |
| 4103 | config: Config{ |
| 4104 | MaxVersion: VersionTLS13, |
| 4105 | }, |
| 4106 | flags: []string{ |
| 4107 | "-enable-ocsp-stapling", |
| 4108 | "-expect-ocsp-response", |
| 4109 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4110 | "-verify-peer", |
| 4111 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4112 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4113 | }) |
| 4114 | tests = append(tests, testCase{ |
| 4115 | testType: serverTest, |
| 4116 | name: "OCSPStapling-Server-TLS13", |
| 4117 | config: Config{ |
| 4118 | MaxVersion: VersionTLS13, |
| 4119 | }, |
| 4120 | expectedOCSPResponse: testOCSPResponse, |
| 4121 | flags: []string{ |
| 4122 | "-ocsp-response", |
| 4123 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 4124 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4125 | resumeSession: true, |
David Benjamin | 942f4ed | 2016-07-16 19:03:49 +0300 | [diff] [blame] | 4126 | }) |
Paul Lietar | aeeff2c | 2015-08-12 11:47:11 +0100 | [diff] [blame] | 4127 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4128 | // Certificate verification tests. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4129 | for _, vers := range tlsVersions { |
| 4130 | if config.protocol == dtls && !vers.hasDTLS { |
| 4131 | continue |
| 4132 | } |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4133 | for _, testType := range []testType{clientTest, serverTest} { |
| 4134 | suffix := "-Client" |
| 4135 | if testType == serverTest { |
| 4136 | suffix = "-Server" |
| 4137 | } |
| 4138 | suffix += "-" + vers.name |
| 4139 | |
| 4140 | flag := "-verify-peer" |
| 4141 | if testType == serverTest { |
| 4142 | flag = "-require-any-client-certificate" |
| 4143 | } |
| 4144 | |
| 4145 | tests = append(tests, testCase{ |
| 4146 | testType: testType, |
| 4147 | name: "CertificateVerificationSucceed" + suffix, |
| 4148 | config: Config{ |
| 4149 | MaxVersion: vers.version, |
| 4150 | Certificates: []Certificate{rsaCertificate}, |
| 4151 | }, |
| 4152 | flags: []string{ |
| 4153 | flag, |
| 4154 | "-expect-verify-result", |
| 4155 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4156 | resumeSession: true, |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4157 | }) |
| 4158 | tests = append(tests, testCase{ |
| 4159 | testType: testType, |
| 4160 | name: "CertificateVerificationFail" + suffix, |
| 4161 | config: Config{ |
| 4162 | MaxVersion: vers.version, |
| 4163 | Certificates: []Certificate{rsaCertificate}, |
| 4164 | }, |
| 4165 | flags: []string{ |
| 4166 | flag, |
| 4167 | "-verify-fail", |
| 4168 | }, |
| 4169 | shouldFail: true, |
| 4170 | expectedError: ":CERTIFICATE_VERIFY_FAILED:", |
| 4171 | }) |
| 4172 | } |
| 4173 | |
| 4174 | // By default, the client is in a soft fail mode where the peer |
| 4175 | // certificate is verified but failures are non-fatal. |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4176 | tests = append(tests, testCase{ |
| 4177 | testType: clientTest, |
| 4178 | name: "CertificateVerificationSoftFail-" + vers.name, |
| 4179 | config: Config{ |
David Benjamin | bb9e36e | 2016-08-03 14:14:47 -0400 | [diff] [blame] | 4180 | MaxVersion: vers.version, |
| 4181 | Certificates: []Certificate{rsaCertificate}, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4182 | }, |
| 4183 | flags: []string{ |
| 4184 | "-verify-fail", |
| 4185 | "-expect-verify-result", |
| 4186 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4187 | resumeSession: true, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 4188 | }) |
| 4189 | } |
Paul Lietar | 8f1c268 | 2015-08-18 12:21:54 +0100 | [diff] [blame] | 4190 | |
David Benjamin | 1d4f4c0 | 2016-07-26 18:03:08 -0400 | [diff] [blame] | 4191 | tests = append(tests, testCase{ |
| 4192 | name: "ShimSendAlert", |
| 4193 | flags: []string{"-send-alert"}, |
| 4194 | shimWritesFirst: true, |
| 4195 | shouldFail: true, |
| 4196 | expectedLocalError: "remote error: decompression failure", |
| 4197 | }) |
| 4198 | |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4199 | if config.protocol == tls { |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4200 | tests = append(tests, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4201 | name: "Renegotiate-Client", |
| 4202 | config: Config{ |
| 4203 | MaxVersion: VersionTLS12, |
| 4204 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 4205 | renegotiate: 1, |
| 4206 | flags: []string{ |
| 4207 | "-renegotiate-freely", |
| 4208 | "-expect-total-renegotiations", "1", |
| 4209 | }, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4210 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4211 | |
David Benjamin | 4792110 | 2016-07-28 11:29:18 -0400 | [diff] [blame] | 4212 | tests = append(tests, testCase{ |
| 4213 | name: "SendHalfHelloRequest", |
| 4214 | config: Config{ |
| 4215 | MaxVersion: VersionTLS12, |
| 4216 | Bugs: ProtocolBugs{ |
| 4217 | PackHelloRequestWithFinished: config.packHandshakeFlight, |
| 4218 | }, |
| 4219 | }, |
| 4220 | sendHalfHelloRequest: true, |
| 4221 | flags: []string{"-renegotiate-ignore"}, |
| 4222 | shouldFail: true, |
| 4223 | expectedError: ":UNEXPECTED_RECORD:", |
| 4224 | }) |
| 4225 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4226 | // NPN on client and server; results in post-handshake message. |
| 4227 | tests = append(tests, testCase{ |
| 4228 | name: "NPN-Client", |
| 4229 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4230 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4231 | NextProtos: []string{"foo"}, |
| 4232 | }, |
| 4233 | flags: []string{"-select-next-proto", "foo"}, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4234 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4235 | expectedNextProto: "foo", |
| 4236 | expectedNextProtoType: npn, |
| 4237 | }) |
| 4238 | tests = append(tests, testCase{ |
| 4239 | testType: serverTest, |
| 4240 | name: "NPN-Server", |
| 4241 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4242 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4243 | NextProtos: []string{"bar"}, |
| 4244 | }, |
| 4245 | flags: []string{ |
| 4246 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4247 | "-expect-next-proto", "bar", |
| 4248 | }, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4249 | resumeSession: true, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4250 | expectedNextProto: "bar", |
| 4251 | expectedNextProtoType: npn, |
| 4252 | }) |
| 4253 | |
| 4254 | // TODO(davidben): Add tests for when False Start doesn't trigger. |
| 4255 | |
| 4256 | // Client does False Start and negotiates NPN. |
| 4257 | tests = append(tests, testCase{ |
| 4258 | name: "FalseStart", |
| 4259 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4260 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4261 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4262 | NextProtos: []string{"foo"}, |
| 4263 | Bugs: ProtocolBugs{ |
| 4264 | ExpectFalseStart: true, |
| 4265 | }, |
| 4266 | }, |
| 4267 | flags: []string{ |
| 4268 | "-false-start", |
| 4269 | "-select-next-proto", "foo", |
| 4270 | }, |
| 4271 | shimWritesFirst: true, |
| 4272 | resumeSession: true, |
| 4273 | }) |
| 4274 | |
| 4275 | // Client does False Start and negotiates ALPN. |
| 4276 | tests = append(tests, testCase{ |
| 4277 | name: "FalseStart-ALPN", |
| 4278 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4279 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4280 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4281 | NextProtos: []string{"foo"}, |
| 4282 | Bugs: ProtocolBugs{ |
| 4283 | ExpectFalseStart: true, |
| 4284 | }, |
| 4285 | }, |
| 4286 | flags: []string{ |
| 4287 | "-false-start", |
| 4288 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 4289 | "-expect-alpn", "foo", |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4290 | }, |
| 4291 | shimWritesFirst: true, |
| 4292 | resumeSession: true, |
| 4293 | }) |
| 4294 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4295 | // False Start without session tickets. |
| 4296 | tests = append(tests, testCase{ |
| 4297 | name: "FalseStart-SessionTicketsDisabled", |
| 4298 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4299 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4300 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 4301 | NextProtos: []string{"foo"}, |
| 4302 | SessionTicketsDisabled: true, |
| 4303 | Bugs: ProtocolBugs{ |
| 4304 | ExpectFalseStart: true, |
| 4305 | }, |
| 4306 | }, |
| 4307 | flags: []string{ |
| 4308 | "-false-start", |
| 4309 | "-select-next-proto", "foo", |
| 4310 | }, |
| 4311 | shimWritesFirst: true, |
| 4312 | }) |
| 4313 | |
| 4314 | // Server parses a V2ClientHello. |
| 4315 | tests = append(tests, testCase{ |
| 4316 | testType: serverTest, |
| 4317 | name: "SendV2ClientHello", |
| 4318 | config: Config{ |
| 4319 | // Choose a cipher suite that does not involve |
| 4320 | // elliptic curves, so no extensions are |
| 4321 | // involved. |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4322 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 4323 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4324 | Bugs: ProtocolBugs{ |
| 4325 | SendV2ClientHello: true, |
| 4326 | }, |
| 4327 | }, |
| 4328 | }) |
| 4329 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4330 | // Test Channel ID |
| 4331 | for _, ver := range tlsVersions { |
Nick Harper | c984611 | 2016-10-17 15:05:35 -0700 | [diff] [blame] | 4332 | if ver.version < VersionTLS10 { |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4333 | continue |
| 4334 | } |
| 4335 | // Client sends a Channel ID. |
| 4336 | tests = append(tests, testCase{ |
| 4337 | name: "ChannelID-Client-" + ver.name, |
| 4338 | config: Config{ |
| 4339 | MaxVersion: ver.version, |
| 4340 | RequestChannelID: true, |
| 4341 | }, |
| 4342 | flags: []string{"-send-channel-id", path.Join(*resourceDir, channelIDKeyFile)}, |
| 4343 | resumeSession: true, |
| 4344 | expectChannelID: true, |
| 4345 | }) |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4346 | |
Nick Harper | 60a85cb | 2016-09-23 16:25:11 -0700 | [diff] [blame] | 4347 | // Server accepts a Channel ID. |
| 4348 | tests = append(tests, testCase{ |
| 4349 | testType: serverTest, |
| 4350 | name: "ChannelID-Server-" + ver.name, |
| 4351 | config: Config{ |
| 4352 | MaxVersion: ver.version, |
| 4353 | ChannelID: channelIDKey, |
| 4354 | }, |
| 4355 | flags: []string{ |
| 4356 | "-expect-channel-id", |
| 4357 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4358 | }, |
| 4359 | resumeSession: true, |
| 4360 | expectChannelID: true, |
| 4361 | }) |
| 4362 | |
| 4363 | tests = append(tests, testCase{ |
| 4364 | testType: serverTest, |
| 4365 | name: "InvalidChannelIDSignature-" + ver.name, |
| 4366 | config: Config{ |
| 4367 | MaxVersion: ver.version, |
| 4368 | ChannelID: channelIDKey, |
| 4369 | Bugs: ProtocolBugs{ |
| 4370 | InvalidChannelIDSignature: true, |
| 4371 | }, |
| 4372 | }, |
| 4373 | flags: []string{"-enable-channel-id"}, |
| 4374 | shouldFail: true, |
| 4375 | expectedError: ":CHANNEL_ID_SIGNATURE_INVALID:", |
| 4376 | }) |
| 4377 | } |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4378 | |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4379 | // Channel ID and NPN at the same time, to ensure their relative |
| 4380 | // ordering is correct. |
| 4381 | tests = append(tests, testCase{ |
| 4382 | name: "ChannelID-NPN-Client", |
| 4383 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4384 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4385 | RequestChannelID: true, |
| 4386 | NextProtos: []string{"foo"}, |
| 4387 | }, |
| 4388 | flags: []string{ |
| 4389 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 4390 | "-select-next-proto", "foo", |
| 4391 | }, |
| 4392 | resumeSession: true, |
| 4393 | expectChannelID: true, |
| 4394 | expectedNextProto: "foo", |
| 4395 | expectedNextProtoType: npn, |
| 4396 | }) |
| 4397 | tests = append(tests, testCase{ |
| 4398 | testType: serverTest, |
| 4399 | name: "ChannelID-NPN-Server", |
| 4400 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4401 | MaxVersion: VersionTLS12, |
David Benjamin | f8fcdf3 | 2016-06-08 15:56:13 -0400 | [diff] [blame] | 4402 | ChannelID: channelIDKey, |
| 4403 | NextProtos: []string{"bar"}, |
| 4404 | }, |
| 4405 | flags: []string{ |
| 4406 | "-expect-channel-id", |
| 4407 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 4408 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 4409 | "-expect-next-proto", "bar", |
| 4410 | }, |
| 4411 | resumeSession: true, |
| 4412 | expectChannelID: true, |
| 4413 | expectedNextProto: "bar", |
| 4414 | expectedNextProtoType: npn, |
| 4415 | }) |
| 4416 | |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4417 | // Bidirectional shutdown with the runner initiating. |
| 4418 | tests = append(tests, testCase{ |
| 4419 | name: "Shutdown-Runner", |
| 4420 | config: Config{ |
| 4421 | Bugs: ProtocolBugs{ |
| 4422 | ExpectCloseNotify: true, |
| 4423 | }, |
| 4424 | }, |
| 4425 | flags: []string{"-check-close-notify"}, |
| 4426 | }) |
| 4427 | |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4428 | if !config.implicitHandshake { |
| 4429 | // Bidirectional shutdown with the shim initiating. The runner, |
| 4430 | // in the meantime, sends garbage before the close_notify which |
| 4431 | // the shim must ignore. This test is disabled under implicit |
| 4432 | // handshake tests because the shim never reads or writes. |
| 4433 | tests = append(tests, testCase{ |
| 4434 | name: "Shutdown-Shim", |
| 4435 | config: Config{ |
| 4436 | MaxVersion: VersionTLS12, |
| 4437 | Bugs: ProtocolBugs{ |
| 4438 | ExpectCloseNotify: true, |
| 4439 | }, |
David Benjamin | 30789da | 2015-08-29 22:56:45 -0400 | [diff] [blame] | 4440 | }, |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4441 | shimShutsDown: true, |
| 4442 | sendEmptyRecords: 1, |
| 4443 | sendWarningAlerts: 1, |
| 4444 | flags: []string{"-check-close-notify"}, |
| 4445 | }) |
| 4446 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4447 | } else { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4448 | // TODO(davidben): DTLS 1.3 will want a similar thing for |
| 4449 | // HelloRetryRequest. |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4450 | tests = append(tests, testCase{ |
| 4451 | name: "SkipHelloVerifyRequest", |
| 4452 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4453 | MaxVersion: VersionTLS12, |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4454 | Bugs: ProtocolBugs{ |
| 4455 | SkipHelloVerifyRequest: true, |
| 4456 | }, |
| 4457 | }, |
| 4458 | }) |
| 4459 | } |
| 4460 | |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4461 | for _, test := range tests { |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4462 | test.protocol = config.protocol |
| 4463 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4464 | test.name += "-DTLS" |
| 4465 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4466 | if config.async { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4467 | test.name += "-Async" |
| 4468 | test.flags = append(test.flags, "-async") |
| 4469 | } else { |
| 4470 | test.name += "-Sync" |
| 4471 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4472 | if config.splitHandshake { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4473 | test.name += "-SplitHandshakeRecords" |
| 4474 | test.config.Bugs.MaxHandshakeRecordLength = 1 |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4475 | if config.protocol == dtls { |
David Benjamin | 16285ea | 2015-11-03 15:39:45 -0500 | [diff] [blame] | 4476 | test.config.Bugs.MaxPacketLength = 256 |
| 4477 | test.flags = append(test.flags, "-mtu", "256") |
| 4478 | } |
| 4479 | } |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 4480 | if config.packHandshakeFlight { |
| 4481 | test.name += "-PackHandshakeFlight" |
| 4482 | test.config.Bugs.PackHandshakeFlight = true |
| 4483 | } |
David Benjamin | e3843d4 | 2017-03-25 18:00:56 -0500 | [diff] [blame] | 4484 | if config.implicitHandshake { |
| 4485 | test.name += "-ImplicitHandshake" |
| 4486 | test.flags = append(test.flags, "-implicit-handshake") |
| 4487 | } |
David Benjamin | 760b1dd | 2015-05-15 23:33:48 -0400 | [diff] [blame] | 4488 | testCases = append(testCases, test) |
David Benjamin | 6fd297b | 2014-08-11 18:43:38 -0400 | [diff] [blame] | 4489 | } |
David Benjamin | 43ec06f | 2014-08-05 02:28:57 -0400 | [diff] [blame] | 4490 | } |
| 4491 | |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4492 | func addDDoSCallbackTests() { |
| 4493 | // DDoS callback. |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4494 | for _, resume := range []bool{false, true} { |
| 4495 | suffix := "Resume" |
| 4496 | if resume { |
| 4497 | suffix = "No" + suffix |
| 4498 | } |
| 4499 | |
| 4500 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4501 | testType: serverTest, |
| 4502 | name: "Server-DDoS-OK-" + suffix, |
| 4503 | config: Config{ |
| 4504 | MaxVersion: VersionTLS12, |
| 4505 | }, |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4506 | flags: []string{"-install-ddos-callback"}, |
| 4507 | resumeSession: resume, |
| 4508 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4509 | testCases = append(testCases, testCase{ |
| 4510 | testType: serverTest, |
| 4511 | name: "Server-DDoS-OK-" + suffix + "-TLS13", |
| 4512 | config: Config{ |
| 4513 | MaxVersion: VersionTLS13, |
| 4514 | }, |
| 4515 | flags: []string{"-install-ddos-callback"}, |
| 4516 | resumeSession: resume, |
| 4517 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4518 | |
| 4519 | failFlag := "-fail-ddos-callback" |
| 4520 | if resume { |
| 4521 | failFlag = "-fail-second-ddos-callback" |
| 4522 | } |
| 4523 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4524 | testType: serverTest, |
| 4525 | name: "Server-DDoS-Reject-" + suffix, |
| 4526 | config: Config{ |
| 4527 | MaxVersion: VersionTLS12, |
| 4528 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4529 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4530 | resumeSession: resume, |
| 4531 | shouldFail: true, |
| 4532 | expectedError: ":CONNECTION_REJECTED:", |
| 4533 | expectedLocalError: "remote error: internal error", |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4534 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4535 | testCases = append(testCases, testCase{ |
| 4536 | testType: serverTest, |
| 4537 | name: "Server-DDoS-Reject-" + suffix + "-TLS13", |
| 4538 | config: Config{ |
| 4539 | MaxVersion: VersionTLS13, |
| 4540 | }, |
David Benjamin | 2c66e07 | 2016-09-16 15:58:00 -0400 | [diff] [blame] | 4541 | flags: []string{"-install-ddos-callback", failFlag}, |
| 4542 | resumeSession: resume, |
| 4543 | shouldFail: true, |
| 4544 | expectedError: ":CONNECTION_REJECTED:", |
| 4545 | expectedLocalError: "remote error: internal error", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 4546 | }) |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 4547 | } |
| 4548 | } |
| 4549 | |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4550 | func addVersionNegotiationTests() { |
| 4551 | for i, shimVers := range tlsVersions { |
| 4552 | // Assemble flags to disable all newer versions on the shim. |
| 4553 | var flags []string |
| 4554 | for _, vers := range tlsVersions[i+1:] { |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4555 | flags = append(flags, vers.excludeFlag) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4556 | } |
| 4557 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4558 | // Test configuring the runner's maximum version. |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4559 | for _, runnerVers := range tlsVersions { |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4560 | protocols := []protocol{tls} |
| 4561 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4562 | protocols = append(protocols, dtls) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4563 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4564 | for _, protocol := range protocols { |
| 4565 | expectedVersion := shimVers.version |
| 4566 | if runnerVers.version < shimVers.version { |
| 4567 | expectedVersion = runnerVers.version |
| 4568 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4569 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4570 | suffix := shimVers.name + "-" + runnerVers.name |
| 4571 | if protocol == dtls { |
| 4572 | suffix += "-DTLS" |
| 4573 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4574 | |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4575 | // Determine the expected initial record-layer versions. |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4576 | clientVers := shimVers.version |
| 4577 | if clientVers > VersionTLS10 { |
| 4578 | clientVers = VersionTLS10 |
| 4579 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4580 | clientVers = versionToWire(clientVers, protocol == dtls) |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4581 | serverVers := expectedVersion |
| 4582 | if expectedVersion >= VersionTLS13 { |
| 4583 | serverVers = VersionTLS10 |
| 4584 | } |
David Benjamin | b1dd8cd | 2016-09-26 19:20:48 -0400 | [diff] [blame] | 4585 | serverVers = versionToWire(serverVers, protocol == dtls) |
| 4586 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4587 | testCases = append(testCases, testCase{ |
| 4588 | protocol: protocol, |
| 4589 | testType: clientTest, |
| 4590 | name: "VersionNegotiation-Client-" + suffix, |
| 4591 | config: Config{ |
| 4592 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4593 | Bugs: ProtocolBugs{ |
| 4594 | ExpectInitialRecordVersion: clientVers, |
| 4595 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4596 | }, |
| 4597 | flags: flags, |
| 4598 | expectedVersion: expectedVersion, |
| 4599 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4600 | testCases = append(testCases, testCase{ |
| 4601 | protocol: protocol, |
| 4602 | testType: clientTest, |
| 4603 | name: "VersionNegotiation-Client2-" + suffix, |
| 4604 | config: Config{ |
| 4605 | MaxVersion: runnerVers.version, |
| 4606 | Bugs: ProtocolBugs{ |
| 4607 | ExpectInitialRecordVersion: clientVers, |
| 4608 | }, |
| 4609 | }, |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4610 | flags: []string{"-max-version", shimVers.shimFlag(protocol)}, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4611 | expectedVersion: expectedVersion, |
| 4612 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4613 | |
| 4614 | testCases = append(testCases, testCase{ |
| 4615 | protocol: protocol, |
| 4616 | testType: serverTest, |
| 4617 | name: "VersionNegotiation-Server-" + suffix, |
| 4618 | config: Config{ |
| 4619 | MaxVersion: runnerVers.version, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4620 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4621 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1e29a6b | 2014-12-10 02:27:24 -0500 | [diff] [blame] | 4622 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4623 | }, |
| 4624 | flags: flags, |
| 4625 | expectedVersion: expectedVersion, |
| 4626 | }) |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4627 | testCases = append(testCases, testCase{ |
| 4628 | protocol: protocol, |
| 4629 | testType: serverTest, |
| 4630 | name: "VersionNegotiation-Server2-" + suffix, |
| 4631 | config: Config{ |
| 4632 | MaxVersion: runnerVers.version, |
| 4633 | Bugs: ProtocolBugs{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 4634 | ExpectInitialRecordVersion: serverVers, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4635 | }, |
| 4636 | }, |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4637 | flags: []string{"-max-version", shimVers.shimFlag(protocol)}, |
David Benjamin | 1eb367c | 2014-12-12 18:17:51 -0500 | [diff] [blame] | 4638 | expectedVersion: expectedVersion, |
| 4639 | }) |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 4640 | } |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4641 | } |
| 4642 | } |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4643 | |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4644 | // Test the version extension at all versions. |
| 4645 | for _, vers := range tlsVersions { |
| 4646 | protocols := []protocol{tls} |
| 4647 | if vers.hasDTLS { |
| 4648 | protocols = append(protocols, dtls) |
| 4649 | } |
| 4650 | for _, protocol := range protocols { |
| 4651 | suffix := vers.name |
| 4652 | if protocol == dtls { |
| 4653 | suffix += "-DTLS" |
| 4654 | } |
| 4655 | |
| 4656 | wireVersion := versionToWire(vers.version, protocol == dtls) |
| 4657 | testCases = append(testCases, testCase{ |
| 4658 | protocol: protocol, |
| 4659 | testType: serverTest, |
| 4660 | name: "VersionNegotiationExtension-" + suffix, |
| 4661 | config: Config{ |
| 4662 | Bugs: ProtocolBugs{ |
| 4663 | SendSupportedVersions: []uint16{0x1111, wireVersion, 0x2222}, |
| 4664 | }, |
| 4665 | }, |
| 4666 | expectedVersion: vers.version, |
| 4667 | }) |
| 4668 | } |
| 4669 | |
| 4670 | } |
| 4671 | |
| 4672 | // If all versions are unknown, negotiation fails. |
| 4673 | testCases = append(testCases, testCase{ |
| 4674 | testType: serverTest, |
| 4675 | name: "NoSupportedVersions", |
| 4676 | config: Config{ |
| 4677 | Bugs: ProtocolBugs{ |
| 4678 | SendSupportedVersions: []uint16{0x1111}, |
| 4679 | }, |
| 4680 | }, |
| 4681 | shouldFail: true, |
| 4682 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4683 | }) |
| 4684 | testCases = append(testCases, testCase{ |
| 4685 | protocol: dtls, |
| 4686 | testType: serverTest, |
| 4687 | name: "NoSupportedVersions-DTLS", |
| 4688 | config: Config{ |
| 4689 | Bugs: ProtocolBugs{ |
| 4690 | SendSupportedVersions: []uint16{0x1111}, |
| 4691 | }, |
| 4692 | }, |
| 4693 | shouldFail: true, |
| 4694 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4695 | }) |
| 4696 | |
| 4697 | testCases = append(testCases, testCase{ |
| 4698 | testType: serverTest, |
| 4699 | name: "ClientHelloVersionTooHigh", |
| 4700 | config: Config{ |
| 4701 | MaxVersion: VersionTLS13, |
| 4702 | Bugs: ProtocolBugs{ |
| 4703 | SendClientVersion: 0x0304, |
| 4704 | OmitSupportedVersions: true, |
| 4705 | }, |
| 4706 | }, |
| 4707 | expectedVersion: VersionTLS12, |
| 4708 | }) |
| 4709 | |
| 4710 | testCases = append(testCases, testCase{ |
| 4711 | testType: serverTest, |
| 4712 | name: "ConflictingVersionNegotiation", |
| 4713 | config: Config{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4714 | Bugs: ProtocolBugs{ |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4715 | SendClientVersion: VersionTLS12, |
| 4716 | SendSupportedVersions: []uint16{VersionTLS11}, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4717 | }, |
| 4718 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4719 | // The extension takes precedence over the ClientHello version. |
| 4720 | expectedVersion: VersionTLS11, |
| 4721 | }) |
| 4722 | |
| 4723 | testCases = append(testCases, testCase{ |
| 4724 | testType: serverTest, |
| 4725 | name: "ConflictingVersionNegotiation-2", |
| 4726 | config: Config{ |
| 4727 | Bugs: ProtocolBugs{ |
| 4728 | SendClientVersion: VersionTLS11, |
| 4729 | SendSupportedVersions: []uint16{VersionTLS12}, |
| 4730 | }, |
| 4731 | }, |
| 4732 | // The extension takes precedence over the ClientHello version. |
| 4733 | expectedVersion: VersionTLS12, |
| 4734 | }) |
| 4735 | |
| 4736 | testCases = append(testCases, testCase{ |
| 4737 | testType: serverTest, |
| 4738 | name: "RejectFinalTLS13", |
| 4739 | config: Config{ |
| 4740 | Bugs: ProtocolBugs{ |
| 4741 | SendSupportedVersions: []uint16{VersionTLS13, VersionTLS12}, |
| 4742 | }, |
| 4743 | }, |
| 4744 | // We currently implement a draft TLS 1.3 version. Ensure that |
| 4745 | // the true TLS 1.3 value is ignored for now. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4746 | expectedVersion: VersionTLS12, |
| 4747 | }) |
| 4748 | |
Brian Smith | f85d323 | 2016-10-28 10:34:06 -1000 | [diff] [blame] | 4749 | // Test that the maximum version is selected regardless of the |
| 4750 | // client-sent order. |
| 4751 | testCases = append(testCases, testCase{ |
| 4752 | testType: serverTest, |
| 4753 | name: "IgnoreClientVersionOrder", |
| 4754 | config: Config{ |
| 4755 | Bugs: ProtocolBugs{ |
| 4756 | SendSupportedVersions: []uint16{VersionTLS12, tls13DraftVersion}, |
| 4757 | }, |
| 4758 | }, |
| 4759 | expectedVersion: VersionTLS13, |
| 4760 | }) |
| 4761 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4762 | // Test for version tolerance. |
| 4763 | testCases = append(testCases, testCase{ |
| 4764 | testType: serverTest, |
| 4765 | name: "MinorVersionTolerance", |
| 4766 | config: Config{ |
| 4767 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4768 | SendClientVersion: 0x03ff, |
| 4769 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4770 | }, |
| 4771 | }, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4772 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4773 | }) |
| 4774 | testCases = append(testCases, testCase{ |
| 4775 | testType: serverTest, |
| 4776 | name: "MajorVersionTolerance", |
| 4777 | config: Config{ |
| 4778 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4779 | SendClientVersion: 0x0400, |
| 4780 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4781 | }, |
| 4782 | }, |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4783 | // TLS 1.3 must be negotiated with the supported_versions |
| 4784 | // extension, not ClientHello.version. |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4785 | expectedVersion: VersionTLS12, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4786 | }) |
David Benjamin | ad75a66 | 2016-09-30 15:42:59 -0400 | [diff] [blame] | 4787 | testCases = append(testCases, testCase{ |
| 4788 | testType: serverTest, |
| 4789 | name: "VersionTolerance-TLS13", |
| 4790 | config: Config{ |
| 4791 | Bugs: ProtocolBugs{ |
| 4792 | // Although TLS 1.3 does not use |
| 4793 | // ClientHello.version, it still tolerates high |
| 4794 | // values there. |
| 4795 | SendClientVersion: 0x0400, |
| 4796 | }, |
| 4797 | }, |
| 4798 | expectedVersion: VersionTLS13, |
| 4799 | }) |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4800 | |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4801 | testCases = append(testCases, testCase{ |
| 4802 | protocol: dtls, |
| 4803 | testType: serverTest, |
| 4804 | name: "MinorVersionTolerance-DTLS", |
| 4805 | config: Config{ |
| 4806 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4807 | SendClientVersion: 0xfe00, |
| 4808 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4809 | }, |
| 4810 | }, |
| 4811 | expectedVersion: VersionTLS12, |
| 4812 | }) |
| 4813 | testCases = append(testCases, testCase{ |
| 4814 | protocol: dtls, |
| 4815 | testType: serverTest, |
| 4816 | name: "MajorVersionTolerance-DTLS", |
| 4817 | config: Config{ |
| 4818 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4819 | SendClientVersion: 0xfdff, |
| 4820 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4821 | }, |
| 4822 | }, |
| 4823 | expectedVersion: VersionTLS12, |
| 4824 | }) |
| 4825 | |
| 4826 | // Test that versions below 3.0 are rejected. |
| 4827 | testCases = append(testCases, testCase{ |
| 4828 | testType: serverTest, |
| 4829 | name: "VersionTooLow", |
| 4830 | config: Config{ |
| 4831 | Bugs: ProtocolBugs{ |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4832 | SendClientVersion: 0x0200, |
| 4833 | OmitSupportedVersions: true, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4834 | }, |
| 4835 | }, |
| 4836 | shouldFail: true, |
| 4837 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4838 | }) |
| 4839 | testCases = append(testCases, testCase{ |
| 4840 | protocol: dtls, |
| 4841 | testType: serverTest, |
| 4842 | name: "VersionTooLow-DTLS", |
| 4843 | config: Config{ |
| 4844 | Bugs: ProtocolBugs{ |
David Benjamin | 3c6a1ea | 2016-09-26 18:30:05 -0400 | [diff] [blame] | 4845 | SendClientVersion: 0xffff, |
David Benjamin | 95c6956 | 2016-06-29 18:15:03 -0400 | [diff] [blame] | 4846 | }, |
| 4847 | }, |
| 4848 | shouldFail: true, |
| 4849 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4850 | }) |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4851 | |
David Benjamin | 2dc0204 | 2016-09-19 19:57:37 -0400 | [diff] [blame] | 4852 | testCases = append(testCases, testCase{ |
| 4853 | name: "ServerBogusVersion", |
| 4854 | config: Config{ |
| 4855 | Bugs: ProtocolBugs{ |
| 4856 | SendServerHelloVersion: 0x1234, |
| 4857 | }, |
| 4858 | }, |
| 4859 | shouldFail: true, |
| 4860 | expectedError: ":UNSUPPORTED_PROTOCOL:", |
| 4861 | }) |
| 4862 | |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4863 | // Test TLS 1.3's downgrade signal. |
| 4864 | testCases = append(testCases, testCase{ |
| 4865 | name: "Downgrade-TLS12-Client", |
| 4866 | config: Config{ |
| 4867 | Bugs: ProtocolBugs{ |
| 4868 | NegotiateVersion: VersionTLS12, |
| 4869 | }, |
| 4870 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4871 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4872 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4873 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4874 | }) |
| 4875 | testCases = append(testCases, testCase{ |
| 4876 | testType: serverTest, |
| 4877 | name: "Downgrade-TLS12-Server", |
| 4878 | config: Config{ |
| 4879 | Bugs: ProtocolBugs{ |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4880 | SendSupportedVersions: []uint16{VersionTLS12}, |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4881 | }, |
| 4882 | }, |
David Benjamin | 592b532 | 2016-09-30 15:15:01 -0400 | [diff] [blame] | 4883 | expectedVersion: VersionTLS12, |
David Benjamin | 5510863 | 2016-08-11 22:01:18 -0400 | [diff] [blame] | 4884 | // TODO(davidben): This test should fail once TLS 1.3 is final |
| 4885 | // and the fallback signal restored. |
David Benjamin | 1f61f0d | 2016-07-10 12:20:35 -0400 | [diff] [blame] | 4886 | }) |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 4887 | } |
| 4888 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4889 | func addMinimumVersionTests() { |
| 4890 | for i, shimVers := range tlsVersions { |
| 4891 | // Assemble flags to disable all older versions on the shim. |
| 4892 | var flags []string |
| 4893 | for _, vers := range tlsVersions[:i] { |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4894 | flags = append(flags, vers.excludeFlag) |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4895 | } |
| 4896 | |
| 4897 | for _, runnerVers := range tlsVersions { |
| 4898 | protocols := []protocol{tls} |
| 4899 | if runnerVers.hasDTLS && shimVers.hasDTLS { |
| 4900 | protocols = append(protocols, dtls) |
| 4901 | } |
| 4902 | for _, protocol := range protocols { |
| 4903 | suffix := shimVers.name + "-" + runnerVers.name |
| 4904 | if protocol == dtls { |
| 4905 | suffix += "-DTLS" |
| 4906 | } |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4907 | |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4908 | var expectedVersion uint16 |
| 4909 | var shouldFail bool |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4910 | var expectedError, expectedLocalError string |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4911 | if runnerVers.version >= shimVers.version { |
| 4912 | expectedVersion = runnerVers.version |
| 4913 | } else { |
| 4914 | shouldFail = true |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4915 | expectedError = ":UNSUPPORTED_PROTOCOL:" |
| 4916 | expectedLocalError = "remote error: protocol version not supported" |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4917 | } |
| 4918 | |
| 4919 | testCases = append(testCases, testCase{ |
| 4920 | protocol: protocol, |
| 4921 | testType: clientTest, |
| 4922 | name: "MinimumVersion-Client-" + suffix, |
| 4923 | config: Config{ |
| 4924 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4925 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4926 | // Ensure the server does not decline to |
| 4927 | // select a version (versions extension) or |
| 4928 | // cipher (some ciphers depend on versions). |
| 4929 | NegotiateVersion: runnerVers.version, |
| 4930 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4931 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4932 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4933 | flags: flags, |
| 4934 | expectedVersion: expectedVersion, |
| 4935 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4936 | expectedError: expectedError, |
| 4937 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4938 | }) |
| 4939 | testCases = append(testCases, testCase{ |
| 4940 | protocol: protocol, |
| 4941 | testType: clientTest, |
| 4942 | name: "MinimumVersion-Client2-" + suffix, |
| 4943 | config: Config{ |
| 4944 | MaxVersion: runnerVers.version, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4945 | Bugs: ProtocolBugs{ |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4946 | // Ensure the server does not decline to |
| 4947 | // select a version (versions extension) or |
| 4948 | // cipher (some ciphers depend on versions). |
| 4949 | NegotiateVersion: runnerVers.version, |
| 4950 | IgnorePeerCipherPreferences: shouldFail, |
Steven Valdez | fdd1099 | 2016-09-15 16:27:05 -0400 | [diff] [blame] | 4951 | }, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4952 | }, |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4953 | flags: []string{"-min-version", shimVers.shimFlag(protocol)}, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4954 | expectedVersion: expectedVersion, |
| 4955 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4956 | expectedError: expectedError, |
| 4957 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4958 | }) |
| 4959 | |
| 4960 | testCases = append(testCases, testCase{ |
| 4961 | protocol: protocol, |
| 4962 | testType: serverTest, |
| 4963 | name: "MinimumVersion-Server-" + suffix, |
| 4964 | config: Config{ |
| 4965 | MaxVersion: runnerVers.version, |
| 4966 | }, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4967 | flags: flags, |
| 4968 | expectedVersion: expectedVersion, |
| 4969 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4970 | expectedError: expectedError, |
| 4971 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4972 | }) |
| 4973 | testCases = append(testCases, testCase{ |
| 4974 | protocol: protocol, |
| 4975 | testType: serverTest, |
| 4976 | name: "MinimumVersion-Server2-" + suffix, |
| 4977 | config: Config{ |
| 4978 | MaxVersion: runnerVers.version, |
| 4979 | }, |
David Benjamin | 353577c | 2017-06-29 15:54:58 -0400 | [diff] [blame^] | 4980 | flags: []string{"-min-version", shimVers.shimFlag(protocol)}, |
David Benjamin | 87909c0 | 2014-12-13 01:55:01 -0500 | [diff] [blame] | 4981 | expectedVersion: expectedVersion, |
| 4982 | shouldFail: shouldFail, |
David Benjamin | 6dbde98 | 2016-10-03 19:11:14 -0400 | [diff] [blame] | 4983 | expectedError: expectedError, |
| 4984 | expectedLocalError: expectedLocalError, |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 4985 | }) |
| 4986 | } |
| 4987 | } |
| 4988 | } |
| 4989 | } |
| 4990 | |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 4991 | func addExtensionTests() { |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 4992 | // TODO(davidben): Extensions, where applicable, all move their server |
| 4993 | // halves to EncryptedExtensions in TLS 1.3. Duplicate each of these |
| 4994 | // tests for both. Also test interaction with 0-RTT when implemented. |
| 4995 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 4996 | // Repeat extensions tests all versions except SSL 3.0. |
| 4997 | for _, ver := range tlsVersions { |
| 4998 | if ver.version == VersionSSL30 { |
| 4999 | continue |
| 5000 | } |
| 5001 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5002 | // Test that duplicate extensions are rejected. |
| 5003 | testCases = append(testCases, testCase{ |
| 5004 | testType: clientTest, |
| 5005 | name: "DuplicateExtensionClient-" + ver.name, |
| 5006 | config: Config{ |
| 5007 | MaxVersion: ver.version, |
| 5008 | Bugs: ProtocolBugs{ |
| 5009 | DuplicateExtension: true, |
| 5010 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5011 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5012 | shouldFail: true, |
| 5013 | expectedLocalError: "remote error: error decoding message", |
| 5014 | }) |
| 5015 | testCases = append(testCases, testCase{ |
| 5016 | testType: serverTest, |
| 5017 | name: "DuplicateExtensionServer-" + ver.name, |
| 5018 | config: Config{ |
| 5019 | MaxVersion: ver.version, |
| 5020 | Bugs: ProtocolBugs{ |
| 5021 | DuplicateExtension: true, |
| 5022 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5023 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5024 | shouldFail: true, |
| 5025 | expectedLocalError: "remote error: error decoding message", |
| 5026 | }) |
| 5027 | |
| 5028 | // Test SNI. |
| 5029 | testCases = append(testCases, testCase{ |
| 5030 | testType: clientTest, |
| 5031 | name: "ServerNameExtensionClient-" + ver.name, |
| 5032 | config: Config{ |
| 5033 | MaxVersion: ver.version, |
| 5034 | Bugs: ProtocolBugs{ |
| 5035 | ExpectServerName: "example.com", |
| 5036 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5037 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5038 | flags: []string{"-host-name", "example.com"}, |
| 5039 | }) |
| 5040 | testCases = append(testCases, testCase{ |
| 5041 | testType: clientTest, |
| 5042 | name: "ServerNameExtensionClientMismatch-" + ver.name, |
| 5043 | config: Config{ |
| 5044 | MaxVersion: ver.version, |
| 5045 | Bugs: ProtocolBugs{ |
| 5046 | ExpectServerName: "mismatch.com", |
| 5047 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5048 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5049 | flags: []string{"-host-name", "example.com"}, |
| 5050 | shouldFail: true, |
| 5051 | expectedLocalError: "tls: unexpected server name", |
| 5052 | }) |
| 5053 | testCases = append(testCases, testCase{ |
| 5054 | testType: clientTest, |
| 5055 | name: "ServerNameExtensionClientMissing-" + ver.name, |
| 5056 | config: Config{ |
| 5057 | MaxVersion: ver.version, |
| 5058 | Bugs: ProtocolBugs{ |
| 5059 | ExpectServerName: "missing.com", |
| 5060 | }, |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5061 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5062 | shouldFail: true, |
| 5063 | expectedLocalError: "tls: unexpected server name", |
| 5064 | }) |
| 5065 | testCases = append(testCases, testCase{ |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 5066 | testType: clientTest, |
| 5067 | name: "TolerateServerNameAck-" + ver.name, |
| 5068 | config: Config{ |
| 5069 | MaxVersion: ver.version, |
| 5070 | Bugs: ProtocolBugs{ |
| 5071 | SendServerNameAck: true, |
| 5072 | }, |
| 5073 | }, |
| 5074 | flags: []string{"-host-name", "example.com"}, |
| 5075 | resumeSession: true, |
| 5076 | }) |
| 5077 | testCases = append(testCases, testCase{ |
| 5078 | testType: clientTest, |
| 5079 | name: "UnsolicitedServerNameAck-" + ver.name, |
| 5080 | config: Config{ |
| 5081 | MaxVersion: ver.version, |
| 5082 | Bugs: ProtocolBugs{ |
| 5083 | SendServerNameAck: true, |
| 5084 | }, |
| 5085 | }, |
| 5086 | shouldFail: true, |
| 5087 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5088 | expectedLocalError: "remote error: unsupported extension", |
| 5089 | }) |
| 5090 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5091 | testType: serverTest, |
| 5092 | name: "ServerNameExtensionServer-" + ver.name, |
| 5093 | config: Config{ |
| 5094 | MaxVersion: ver.version, |
| 5095 | ServerName: "example.com", |
David Benjamin | fc7b086 | 2014-09-06 13:21:53 -0400 | [diff] [blame] | 5096 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5097 | flags: []string{"-expect-server-name", "example.com"}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5098 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5099 | }) |
| 5100 | |
| 5101 | // Test ALPN. |
| 5102 | testCases = append(testCases, testCase{ |
| 5103 | testType: clientTest, |
| 5104 | name: "ALPNClient-" + ver.name, |
| 5105 | config: Config{ |
| 5106 | MaxVersion: ver.version, |
| 5107 | NextProtos: []string{"foo"}, |
| 5108 | }, |
| 5109 | flags: []string{ |
| 5110 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 5111 | "-expect-alpn", "foo", |
| 5112 | }, |
| 5113 | expectedNextProto: "foo", |
| 5114 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5115 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5116 | }) |
| 5117 | testCases = append(testCases, testCase{ |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5118 | testType: clientTest, |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5119 | name: "ALPNClient-RejectUnknown-" + ver.name, |
David Benjamin | 3e51757 | 2016-08-11 11:52:23 -0400 | [diff] [blame] | 5120 | config: Config{ |
| 5121 | MaxVersion: ver.version, |
| 5122 | Bugs: ProtocolBugs{ |
| 5123 | SendALPN: "baz", |
| 5124 | }, |
| 5125 | }, |
| 5126 | flags: []string{ |
| 5127 | "-advertise-alpn", "\x03foo\x03bar", |
| 5128 | }, |
| 5129 | shouldFail: true, |
| 5130 | expectedError: ":INVALID_ALPN_PROTOCOL:", |
| 5131 | expectedLocalError: "remote error: illegal parameter", |
| 5132 | }) |
| 5133 | testCases = append(testCases, testCase{ |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5134 | testType: clientTest, |
| 5135 | name: "ALPNClient-AllowUnknown-" + ver.name, |
| 5136 | config: Config{ |
| 5137 | MaxVersion: ver.version, |
| 5138 | Bugs: ProtocolBugs{ |
| 5139 | SendALPN: "baz", |
| 5140 | }, |
| 5141 | }, |
| 5142 | flags: []string{ |
| 5143 | "-advertise-alpn", "\x03foo\x03bar", |
| 5144 | "-allow-unknown-alpn-protos", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 5145 | "-expect-alpn", "baz", |
David Benjamin | c8ff30c | 2017-04-04 13:52:36 -0400 | [diff] [blame] | 5146 | }, |
| 5147 | }) |
| 5148 | testCases = append(testCases, testCase{ |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5149 | testType: serverTest, |
| 5150 | name: "ALPNServer-" + ver.name, |
| 5151 | config: Config{ |
| 5152 | MaxVersion: ver.version, |
| 5153 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5154 | }, |
| 5155 | flags: []string{ |
| 5156 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5157 | "-select-alpn", "foo", |
| 5158 | }, |
| 5159 | expectedNextProto: "foo", |
| 5160 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5161 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5162 | }) |
| 5163 | testCases = append(testCases, testCase{ |
| 5164 | testType: serverTest, |
| 5165 | name: "ALPNServer-Decline-" + ver.name, |
| 5166 | config: Config{ |
| 5167 | MaxVersion: ver.version, |
| 5168 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5169 | }, |
| 5170 | flags: []string{"-decline-alpn"}, |
| 5171 | expectNoNextProto: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5172 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5173 | }) |
| 5174 | |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5175 | // Test ALPN in async mode as well to ensure that extensions callbacks are only |
| 5176 | // called once. |
| 5177 | testCases = append(testCases, testCase{ |
| 5178 | testType: serverTest, |
| 5179 | name: "ALPNServer-Async-" + ver.name, |
| 5180 | config: Config{ |
| 5181 | MaxVersion: ver.version, |
| 5182 | NextProtos: []string{"foo", "bar", "baz"}, |
David Benjamin | 4eb95cc | 2016-11-16 17:08:23 +0900 | [diff] [blame] | 5183 | // Prior to TLS 1.3, exercise the asynchronous session callback. |
| 5184 | SessionTicketsDisabled: ver.version < VersionTLS13, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5185 | }, |
| 5186 | flags: []string{ |
| 5187 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5188 | "-select-alpn", "foo", |
| 5189 | "-async", |
| 5190 | }, |
| 5191 | expectedNextProto: "foo", |
| 5192 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5193 | resumeSession: true, |
David Benjamin | 25fe85b | 2016-08-09 20:00:32 -0400 | [diff] [blame] | 5194 | }) |
| 5195 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5196 | var emptyString string |
| 5197 | testCases = append(testCases, testCase{ |
| 5198 | testType: clientTest, |
| 5199 | name: "ALPNClient-EmptyProtocolName-" + ver.name, |
| 5200 | config: Config{ |
| 5201 | MaxVersion: ver.version, |
| 5202 | NextProtos: []string{""}, |
| 5203 | Bugs: ProtocolBugs{ |
| 5204 | // A server returning an empty ALPN protocol |
| 5205 | // should be rejected. |
| 5206 | ALPNProtocol: &emptyString, |
| 5207 | }, |
| 5208 | }, |
| 5209 | flags: []string{ |
| 5210 | "-advertise-alpn", "\x03foo", |
| 5211 | }, |
| 5212 | shouldFail: true, |
| 5213 | expectedError: ":PARSE_TLSEXT:", |
| 5214 | }) |
| 5215 | testCases = append(testCases, testCase{ |
| 5216 | testType: serverTest, |
| 5217 | name: "ALPNServer-EmptyProtocolName-" + ver.name, |
| 5218 | config: Config{ |
| 5219 | MaxVersion: ver.version, |
| 5220 | // A ClientHello containing an empty ALPN protocol |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5221 | // should be rejected. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5222 | NextProtos: []string{"foo", "", "baz"}, |
Adam Langley | efb0e16 | 2015-07-09 11:35:04 -0700 | [diff] [blame] | 5223 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5224 | flags: []string{ |
| 5225 | "-select-alpn", "foo", |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5226 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5227 | shouldFail: true, |
| 5228 | expectedError: ":PARSE_TLSEXT:", |
| 5229 | }) |
| 5230 | |
| 5231 | // Test NPN and the interaction with ALPN. |
| 5232 | if ver.version < VersionTLS13 { |
| 5233 | // Test that the server prefers ALPN over NPN. |
| 5234 | testCases = append(testCases, testCase{ |
| 5235 | testType: serverTest, |
| 5236 | name: "ALPNServer-Preferred-" + ver.name, |
| 5237 | config: Config{ |
| 5238 | MaxVersion: ver.version, |
| 5239 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5240 | }, |
| 5241 | flags: []string{ |
| 5242 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5243 | "-select-alpn", "foo", |
| 5244 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5245 | }, |
| 5246 | expectedNextProto: "foo", |
| 5247 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5248 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5249 | }) |
| 5250 | testCases = append(testCases, testCase{ |
| 5251 | testType: serverTest, |
| 5252 | name: "ALPNServer-Preferred-Swapped-" + ver.name, |
| 5253 | config: Config{ |
| 5254 | MaxVersion: ver.version, |
| 5255 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5256 | Bugs: ProtocolBugs{ |
| 5257 | SwapNPNAndALPN: true, |
| 5258 | }, |
| 5259 | }, |
| 5260 | flags: []string{ |
| 5261 | "-expect-advertised-alpn", "\x03foo\x03bar\x03baz", |
| 5262 | "-select-alpn", "foo", |
| 5263 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 5264 | }, |
| 5265 | expectedNextProto: "foo", |
| 5266 | expectedNextProtoType: alpn, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5267 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5268 | }) |
| 5269 | |
| 5270 | // Test that negotiating both NPN and ALPN is forbidden. |
| 5271 | testCases = append(testCases, testCase{ |
| 5272 | name: "NegotiateALPNAndNPN-" + ver.name, |
| 5273 | config: Config{ |
| 5274 | MaxVersion: ver.version, |
| 5275 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5276 | Bugs: ProtocolBugs{ |
| 5277 | NegotiateALPNAndNPN: true, |
| 5278 | }, |
| 5279 | }, |
| 5280 | flags: []string{ |
| 5281 | "-advertise-alpn", "\x03foo", |
| 5282 | "-select-next-proto", "foo", |
| 5283 | }, |
| 5284 | shouldFail: true, |
| 5285 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5286 | }) |
| 5287 | testCases = append(testCases, testCase{ |
| 5288 | name: "NegotiateALPNAndNPN-Swapped-" + ver.name, |
| 5289 | config: Config{ |
| 5290 | MaxVersion: ver.version, |
| 5291 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5292 | Bugs: ProtocolBugs{ |
| 5293 | NegotiateALPNAndNPN: true, |
| 5294 | SwapNPNAndALPN: true, |
| 5295 | }, |
| 5296 | }, |
| 5297 | flags: []string{ |
| 5298 | "-advertise-alpn", "\x03foo", |
| 5299 | "-select-next-proto", "foo", |
| 5300 | }, |
| 5301 | shouldFail: true, |
| 5302 | expectedError: ":NEGOTIATED_BOTH_NPN_AND_ALPN:", |
| 5303 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5304 | } |
| 5305 | |
| 5306 | // Test ticket behavior. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5307 | |
| 5308 | // Resume with a corrupt ticket. |
| 5309 | testCases = append(testCases, testCase{ |
| 5310 | testType: serverTest, |
| 5311 | name: "CorruptTicket-" + ver.name, |
| 5312 | config: Config{ |
| 5313 | MaxVersion: ver.version, |
| 5314 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5315 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5316 | in[len(in)-1] ^= 1 |
| 5317 | return in, nil |
| 5318 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5319 | }, |
| 5320 | }, |
| 5321 | resumeSession: true, |
| 5322 | expectResumeRejected: true, |
| 5323 | }) |
| 5324 | // Test the ticket callback, with and without renewal. |
| 5325 | testCases = append(testCases, testCase{ |
| 5326 | testType: serverTest, |
| 5327 | name: "TicketCallback-" + ver.name, |
| 5328 | config: Config{ |
| 5329 | MaxVersion: ver.version, |
| 5330 | }, |
| 5331 | resumeSession: true, |
| 5332 | flags: []string{"-use-ticket-callback"}, |
| 5333 | }) |
| 5334 | testCases = append(testCases, testCase{ |
| 5335 | testType: serverTest, |
| 5336 | name: "TicketCallback-Renew-" + ver.name, |
| 5337 | config: Config{ |
| 5338 | MaxVersion: ver.version, |
| 5339 | Bugs: ProtocolBugs{ |
| 5340 | ExpectNewTicket: true, |
| 5341 | }, |
| 5342 | }, |
| 5343 | flags: []string{"-use-ticket-callback", "-renew-ticket"}, |
| 5344 | resumeSession: true, |
| 5345 | }) |
| 5346 | |
| 5347 | // Test that the ticket callback is only called once when everything before |
| 5348 | // it in the ClientHello is asynchronous. This corrupts the ticket so |
| 5349 | // certificate selection callbacks run. |
| 5350 | testCases = append(testCases, testCase{ |
| 5351 | testType: serverTest, |
| 5352 | name: "TicketCallback-SingleCall-" + ver.name, |
| 5353 | config: Config{ |
| 5354 | MaxVersion: ver.version, |
| 5355 | Bugs: ProtocolBugs{ |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 5356 | FilterTicket: func(in []byte) ([]byte, error) { |
| 5357 | in[len(in)-1] ^= 1 |
| 5358 | return in, nil |
| 5359 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5360 | }, |
| 5361 | }, |
| 5362 | resumeSession: true, |
| 5363 | expectResumeRejected: true, |
| 5364 | flags: []string{ |
| 5365 | "-use-ticket-callback", |
| 5366 | "-async", |
| 5367 | }, |
| 5368 | }) |
| 5369 | |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5370 | // Resume with various lengths of ticket session id. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5371 | if ver.version < VersionTLS13 { |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5372 | testCases = append(testCases, testCase{ |
| 5373 | testType: serverTest, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5374 | name: "TicketSessionIDLength-0-" + ver.name, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5375 | config: Config{ |
| 5376 | MaxVersion: ver.version, |
| 5377 | Bugs: ProtocolBugs{ |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5378 | EmptyTicketSessionID: true, |
| 5379 | }, |
| 5380 | }, |
| 5381 | resumeSession: true, |
| 5382 | }) |
| 5383 | testCases = append(testCases, testCase{ |
| 5384 | testType: serverTest, |
| 5385 | name: "TicketSessionIDLength-16-" + ver.name, |
| 5386 | config: Config{ |
| 5387 | MaxVersion: ver.version, |
| 5388 | Bugs: ProtocolBugs{ |
| 5389 | TicketSessionIDLength: 16, |
| 5390 | }, |
| 5391 | }, |
| 5392 | resumeSession: true, |
| 5393 | }) |
| 5394 | testCases = append(testCases, testCase{ |
| 5395 | testType: serverTest, |
| 5396 | name: "TicketSessionIDLength-32-" + ver.name, |
| 5397 | config: Config{ |
| 5398 | MaxVersion: ver.version, |
| 5399 | Bugs: ProtocolBugs{ |
| 5400 | TicketSessionIDLength: 32, |
| 5401 | }, |
| 5402 | }, |
| 5403 | resumeSession: true, |
| 5404 | }) |
| 5405 | testCases = append(testCases, testCase{ |
| 5406 | testType: serverTest, |
| 5407 | name: "TicketSessionIDLength-33-" + ver.name, |
| 5408 | config: Config{ |
| 5409 | MaxVersion: ver.version, |
| 5410 | Bugs: ProtocolBugs{ |
| 5411 | TicketSessionIDLength: 33, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5412 | }, |
| 5413 | }, |
| 5414 | resumeSession: true, |
| 5415 | shouldFail: true, |
David Benjamin | d4c349b | 2017-02-09 14:07:17 -0500 | [diff] [blame] | 5416 | // The maximum session ID length is 32. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5417 | expectedError: ":DECODE_ERROR:", |
| 5418 | }) |
| 5419 | } |
| 5420 | |
| 5421 | // Basic DTLS-SRTP tests. Include fake profiles to ensure they |
| 5422 | // are ignored. |
| 5423 | if ver.hasDTLS { |
| 5424 | testCases = append(testCases, testCase{ |
| 5425 | protocol: dtls, |
| 5426 | name: "SRTP-Client-" + ver.name, |
| 5427 | config: Config{ |
| 5428 | MaxVersion: ver.version, |
| 5429 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5430 | }, |
| 5431 | flags: []string{ |
| 5432 | "-srtp-profiles", |
| 5433 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5434 | }, |
| 5435 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5436 | }) |
| 5437 | testCases = append(testCases, testCase{ |
| 5438 | protocol: dtls, |
| 5439 | testType: serverTest, |
| 5440 | name: "SRTP-Server-" + ver.name, |
| 5441 | config: Config{ |
| 5442 | MaxVersion: ver.version, |
| 5443 | SRTPProtectionProfiles: []uint16{40, SRTP_AES128_CM_HMAC_SHA1_80, 42}, |
| 5444 | }, |
| 5445 | flags: []string{ |
| 5446 | "-srtp-profiles", |
| 5447 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5448 | }, |
| 5449 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5450 | }) |
| 5451 | // Test that the MKI is ignored. |
| 5452 | testCases = append(testCases, testCase{ |
| 5453 | protocol: dtls, |
| 5454 | testType: serverTest, |
| 5455 | name: "SRTP-Server-IgnoreMKI-" + ver.name, |
| 5456 | config: Config{ |
| 5457 | MaxVersion: ver.version, |
| 5458 | SRTPProtectionProfiles: []uint16{SRTP_AES128_CM_HMAC_SHA1_80}, |
| 5459 | Bugs: ProtocolBugs{ |
| 5460 | SRTPMasterKeyIdentifer: "bogus", |
| 5461 | }, |
| 5462 | }, |
| 5463 | flags: []string{ |
| 5464 | "-srtp-profiles", |
| 5465 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5466 | }, |
| 5467 | expectedSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_80, |
| 5468 | }) |
| 5469 | // Test that SRTP isn't negotiated on the server if there were |
| 5470 | // no matching profiles. |
| 5471 | testCases = append(testCases, testCase{ |
| 5472 | protocol: dtls, |
| 5473 | testType: serverTest, |
| 5474 | name: "SRTP-Server-NoMatch-" + ver.name, |
| 5475 | config: Config{ |
| 5476 | MaxVersion: ver.version, |
| 5477 | SRTPProtectionProfiles: []uint16{100, 101, 102}, |
| 5478 | }, |
| 5479 | flags: []string{ |
| 5480 | "-srtp-profiles", |
| 5481 | "SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32", |
| 5482 | }, |
| 5483 | expectedSRTPProtectionProfile: 0, |
| 5484 | }) |
| 5485 | // Test that the server returning an invalid SRTP profile is |
| 5486 | // flagged as an error by the client. |
| 5487 | testCases = append(testCases, testCase{ |
| 5488 | protocol: dtls, |
| 5489 | name: "SRTP-Client-NoMatch-" + ver.name, |
| 5490 | config: Config{ |
| 5491 | MaxVersion: ver.version, |
| 5492 | Bugs: ProtocolBugs{ |
| 5493 | SendSRTPProtectionProfile: SRTP_AES128_CM_HMAC_SHA1_32, |
| 5494 | }, |
| 5495 | }, |
| 5496 | flags: []string{ |
| 5497 | "-srtp-profiles", |
| 5498 | "SRTP_AES128_CM_SHA1_80", |
| 5499 | }, |
| 5500 | shouldFail: true, |
| 5501 | expectedError: ":BAD_SRTP_PROTECTION_PROFILE_LIST:", |
| 5502 | }) |
| 5503 | } |
| 5504 | |
| 5505 | // Test SCT list. |
| 5506 | testCases = append(testCases, testCase{ |
| 5507 | name: "SignedCertificateTimestampList-Client-" + ver.name, |
| 5508 | testType: clientTest, |
| 5509 | config: Config{ |
| 5510 | MaxVersion: ver.version, |
David Benjamin | 76c2efc | 2015-08-31 14:24:29 -0400 | [diff] [blame] | 5511 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5512 | flags: []string{ |
| 5513 | "-enable-signed-cert-timestamps", |
| 5514 | "-expect-signed-cert-timestamps", |
| 5515 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5516 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5517 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5518 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5519 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5520 | var differentSCTList []byte |
| 5521 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5522 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5523 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5524 | // The SCT extension did not specify that it must only be sent on resumption as it |
| 5525 | // should have, so test that we tolerate but ignore it. |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5526 | testCases = append(testCases, testCase{ |
| 5527 | name: "SendSCTListOnResume-" + ver.name, |
| 5528 | config: Config{ |
| 5529 | MaxVersion: ver.version, |
| 5530 | Bugs: ProtocolBugs{ |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5531 | SendSCTListOnResume: differentSCTList, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5532 | }, |
David Benjamin | d98452d | 2015-06-16 14:16:23 -0400 | [diff] [blame] | 5533 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5534 | flags: []string{ |
| 5535 | "-enable-signed-cert-timestamps", |
| 5536 | "-expect-signed-cert-timestamps", |
| 5537 | base64.StdEncoding.EncodeToString(testSCTList), |
Adam Langley | 3831173 | 2014-10-16 19:04:35 -0700 | [diff] [blame] | 5538 | }, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5539 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5540 | }) |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5541 | |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5542 | testCases = append(testCases, testCase{ |
| 5543 | name: "SignedCertificateTimestampList-Server-" + ver.name, |
| 5544 | testType: serverTest, |
| 5545 | config: Config{ |
| 5546 | MaxVersion: ver.version, |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5547 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5548 | flags: []string{ |
| 5549 | "-signed-cert-timestamps", |
| 5550 | base64.StdEncoding.EncodeToString(testSCTList), |
David Benjamin | ca6c826 | 2014-11-15 19:06:08 -0500 | [diff] [blame] | 5551 | }, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5552 | expectedSCTList: testSCTList, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5553 | resumeSession: true, |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5554 | }) |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5555 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5556 | emptySCTListCert := *testCerts[0].cert |
| 5557 | emptySCTListCert.SignedCertificateTimestampList = []byte{0, 0} |
| 5558 | |
| 5559 | // Test empty SCT list. |
| 5560 | testCases = append(testCases, testCase{ |
| 5561 | name: "SignedCertificateTimestampListEmpty-Client-" + ver.name, |
| 5562 | testType: clientTest, |
| 5563 | config: Config{ |
| 5564 | MaxVersion: ver.version, |
| 5565 | Certificates: []Certificate{emptySCTListCert}, |
| 5566 | }, |
| 5567 | flags: []string{ |
| 5568 | "-enable-signed-cert-timestamps", |
| 5569 | }, |
| 5570 | shouldFail: true, |
| 5571 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5572 | }) |
| 5573 | |
| 5574 | emptySCTCert := *testCerts[0].cert |
| 5575 | emptySCTCert.SignedCertificateTimestampList = []byte{0, 6, 0, 2, 1, 2, 0, 0} |
| 5576 | |
| 5577 | // Test empty SCT in non-empty list. |
| 5578 | testCases = append(testCases, testCase{ |
| 5579 | name: "SignedCertificateTimestampListEmptySCT-Client-" + ver.name, |
| 5580 | testType: clientTest, |
| 5581 | config: Config{ |
| 5582 | MaxVersion: ver.version, |
| 5583 | Certificates: []Certificate{emptySCTCert}, |
| 5584 | }, |
| 5585 | flags: []string{ |
| 5586 | "-enable-signed-cert-timestamps", |
| 5587 | }, |
| 5588 | shouldFail: true, |
| 5589 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5590 | }) |
| 5591 | |
David Benjamin | 53210cb | 2016-11-16 09:01:48 +0900 | [diff] [blame] | 5592 | // Test that certificate-related extensions are not sent unsolicited. |
| 5593 | testCases = append(testCases, testCase{ |
| 5594 | testType: serverTest, |
| 5595 | name: "UnsolicitedCertificateExtensions-" + ver.name, |
| 5596 | config: Config{ |
| 5597 | MaxVersion: ver.version, |
| 5598 | Bugs: ProtocolBugs{ |
| 5599 | NoOCSPStapling: true, |
| 5600 | NoSignedCertificateTimestamps: true, |
| 5601 | }, |
| 5602 | }, |
| 5603 | flags: []string{ |
| 5604 | "-ocsp-response", |
| 5605 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5606 | "-signed-cert-timestamps", |
| 5607 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5608 | }, |
| 5609 | }) |
David Benjamin | 97d17d9 | 2016-07-14 16:12:00 -0400 | [diff] [blame] | 5610 | } |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 5611 | |
Paul Lietar | 4fac72e | 2015-09-09 13:44:55 +0100 | [diff] [blame] | 5612 | testCases = append(testCases, testCase{ |
Adam Langley | 33ad2b5 | 2015-07-20 17:43:53 -0700 | [diff] [blame] | 5613 | testType: clientTest, |
| 5614 | name: "ClientHelloPadding", |
| 5615 | config: Config{ |
| 5616 | Bugs: ProtocolBugs{ |
| 5617 | RequireClientHelloSize: 512, |
| 5618 | }, |
| 5619 | }, |
| 5620 | // This hostname just needs to be long enough to push the |
| 5621 | // ClientHello into F5's danger zone between 256 and 511 bytes |
| 5622 | // long. |
| 5623 | flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"}, |
| 5624 | }) |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5625 | |
| 5626 | // Extensions should not function in SSL 3.0. |
| 5627 | testCases = append(testCases, testCase{ |
| 5628 | testType: serverTest, |
| 5629 | name: "SSLv3Extensions-NoALPN", |
| 5630 | config: Config{ |
| 5631 | MaxVersion: VersionSSL30, |
| 5632 | NextProtos: []string{"foo", "bar", "baz"}, |
| 5633 | }, |
| 5634 | flags: []string{ |
| 5635 | "-select-alpn", "foo", |
| 5636 | }, |
| 5637 | expectNoNextProto: true, |
| 5638 | }) |
| 5639 | |
| 5640 | // Test session tickets separately as they follow a different codepath. |
| 5641 | testCases = append(testCases, testCase{ |
| 5642 | testType: serverTest, |
| 5643 | name: "SSLv3Extensions-NoTickets", |
| 5644 | config: Config{ |
| 5645 | MaxVersion: VersionSSL30, |
| 5646 | Bugs: ProtocolBugs{ |
| 5647 | // Historically, session tickets in SSL 3.0 |
| 5648 | // failed in different ways depending on whether |
| 5649 | // the client supported renegotiation_info. |
| 5650 | NoRenegotiationInfo: true, |
| 5651 | }, |
| 5652 | }, |
| 5653 | resumeSession: true, |
| 5654 | }) |
| 5655 | testCases = append(testCases, testCase{ |
| 5656 | testType: serverTest, |
| 5657 | name: "SSLv3Extensions-NoTickets2", |
| 5658 | config: Config{ |
| 5659 | MaxVersion: VersionSSL30, |
| 5660 | }, |
| 5661 | resumeSession: true, |
| 5662 | }) |
| 5663 | |
| 5664 | // But SSL 3.0 does send and process renegotiation_info. |
| 5665 | testCases = append(testCases, testCase{ |
| 5666 | testType: serverTest, |
| 5667 | name: "SSLv3Extensions-RenegotiationInfo", |
| 5668 | config: Config{ |
| 5669 | MaxVersion: VersionSSL30, |
| 5670 | Bugs: ProtocolBugs{ |
| 5671 | RequireRenegotiationInfo: true, |
| 5672 | }, |
| 5673 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5674 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5675 | }) |
| 5676 | testCases = append(testCases, testCase{ |
| 5677 | testType: serverTest, |
| 5678 | name: "SSLv3Extensions-RenegotiationInfo-SCSV", |
| 5679 | config: Config{ |
| 5680 | MaxVersion: VersionSSL30, |
| 5681 | Bugs: ProtocolBugs{ |
| 5682 | NoRenegotiationInfo: true, |
| 5683 | SendRenegotiationSCSV: true, |
| 5684 | RequireRenegotiationInfo: true, |
| 5685 | }, |
| 5686 | }, |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 5687 | flags: []string{"-expect-secure-renegotiation"}, |
David Benjamin | c7ce977 | 2015-10-09 19:32:41 -0400 | [diff] [blame] | 5688 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5689 | |
| 5690 | // Test that illegal extensions in TLS 1.3 are rejected by the client if |
| 5691 | // in ServerHello. |
| 5692 | testCases = append(testCases, testCase{ |
| 5693 | name: "NPN-Forbidden-TLS13", |
| 5694 | config: Config{ |
| 5695 | MaxVersion: VersionTLS13, |
| 5696 | NextProtos: []string{"foo"}, |
| 5697 | Bugs: ProtocolBugs{ |
| 5698 | NegotiateNPNAtAllVersions: true, |
| 5699 | }, |
| 5700 | }, |
| 5701 | flags: []string{"-select-next-proto", "foo"}, |
| 5702 | shouldFail: true, |
| 5703 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5704 | }) |
| 5705 | testCases = append(testCases, testCase{ |
| 5706 | name: "EMS-Forbidden-TLS13", |
| 5707 | config: Config{ |
| 5708 | MaxVersion: VersionTLS13, |
| 5709 | Bugs: ProtocolBugs{ |
| 5710 | NegotiateEMSAtAllVersions: true, |
| 5711 | }, |
| 5712 | }, |
| 5713 | shouldFail: true, |
| 5714 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5715 | }) |
| 5716 | testCases = append(testCases, testCase{ |
| 5717 | name: "RenegotiationInfo-Forbidden-TLS13", |
| 5718 | config: Config{ |
| 5719 | MaxVersion: VersionTLS13, |
| 5720 | Bugs: ProtocolBugs{ |
| 5721 | NegotiateRenegotiationInfoAtAllVersions: true, |
| 5722 | }, |
| 5723 | }, |
| 5724 | shouldFail: true, |
| 5725 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5726 | }) |
| 5727 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5728 | name: "Ticket-Forbidden-TLS13", |
| 5729 | config: Config{ |
| 5730 | MaxVersion: VersionTLS12, |
| 5731 | }, |
| 5732 | resumeConfig: &Config{ |
| 5733 | MaxVersion: VersionTLS13, |
| 5734 | Bugs: ProtocolBugs{ |
| 5735 | AdvertiseTicketExtension: true, |
| 5736 | }, |
| 5737 | }, |
| 5738 | resumeSession: true, |
| 5739 | shouldFail: true, |
| 5740 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 5741 | }) |
| 5742 | |
| 5743 | // Test that illegal extensions in TLS 1.3 are declined by the server if |
| 5744 | // offered in ClientHello. The runner's server will fail if this occurs, |
| 5745 | // so we exercise the offering path. (EMS and Renegotiation Info are |
| 5746 | // implicit in every test.) |
| 5747 | testCases = append(testCases, testCase{ |
| 5748 | testType: serverTest, |
David Benjamin | 7364719 | 2016-09-22 16:24:04 -0400 | [diff] [blame] | 5749 | name: "NPN-Declined-TLS13", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 5750 | config: Config{ |
| 5751 | MaxVersion: VersionTLS13, |
| 5752 | NextProtos: []string{"bar"}, |
| 5753 | }, |
| 5754 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
| 5755 | }) |
David Benjamin | 196df5b | 2016-09-21 16:23:27 -0400 | [diff] [blame] | 5756 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5757 | // OpenSSL sends the status_request extension on resumption in TLS 1.2. Test that this is |
| 5758 | // tolerated. |
| 5759 | testCases = append(testCases, testCase{ |
| 5760 | name: "SendOCSPResponseOnResume-TLS12", |
| 5761 | config: Config{ |
| 5762 | MaxVersion: VersionTLS12, |
| 5763 | Bugs: ProtocolBugs{ |
| 5764 | SendOCSPResponseOnResume: []byte("bogus"), |
| 5765 | }, |
| 5766 | }, |
| 5767 | flags: []string{ |
| 5768 | "-enable-ocsp-stapling", |
| 5769 | "-expect-ocsp-response", |
| 5770 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5771 | }, |
| 5772 | resumeSession: true, |
| 5773 | }) |
| 5774 | |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5775 | testCases = append(testCases, testCase{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5776 | name: "SendUnsolicitedOCSPOnCertificate-TLS13", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5777 | config: Config{ |
| 5778 | MaxVersion: VersionTLS13, |
| 5779 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5780 | SendExtensionOnCertificate: testOCSPExtension, |
| 5781 | }, |
| 5782 | }, |
| 5783 | shouldFail: true, |
| 5784 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5785 | }) |
| 5786 | |
| 5787 | testCases = append(testCases, testCase{ |
| 5788 | name: "SendUnsolicitedSCTOnCertificate-TLS13", |
| 5789 | config: Config{ |
| 5790 | MaxVersion: VersionTLS13, |
| 5791 | Bugs: ProtocolBugs{ |
| 5792 | SendExtensionOnCertificate: testSCTExtension, |
| 5793 | }, |
| 5794 | }, |
| 5795 | shouldFail: true, |
| 5796 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5797 | }) |
| 5798 | |
| 5799 | // Test that extensions on client certificates are never accepted. |
| 5800 | testCases = append(testCases, testCase{ |
| 5801 | name: "SendExtensionOnClientCertificate-TLS13", |
| 5802 | testType: serverTest, |
| 5803 | config: Config{ |
| 5804 | MaxVersion: VersionTLS13, |
| 5805 | Certificates: []Certificate{rsaCertificate}, |
| 5806 | Bugs: ProtocolBugs{ |
| 5807 | SendExtensionOnCertificate: testOCSPExtension, |
| 5808 | }, |
| 5809 | }, |
| 5810 | flags: []string{ |
| 5811 | "-enable-ocsp-stapling", |
| 5812 | "-require-any-client-certificate", |
| 5813 | }, |
| 5814 | shouldFail: true, |
| 5815 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5816 | }) |
| 5817 | |
| 5818 | testCases = append(testCases, testCase{ |
| 5819 | name: "SendUnknownExtensionOnCertificate-TLS13", |
| 5820 | config: Config{ |
| 5821 | MaxVersion: VersionTLS13, |
| 5822 | Bugs: ProtocolBugs{ |
| 5823 | SendExtensionOnCertificate: []byte{0x00, 0x7f, 0, 0}, |
| 5824 | }, |
| 5825 | }, |
| 5826 | shouldFail: true, |
| 5827 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 5828 | }) |
| 5829 | |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5830 | var differentSCTList []byte |
| 5831 | differentSCTList = append(differentSCTList, testSCTList...) |
| 5832 | differentSCTList[len(differentSCTList)-1] ^= 1 |
| 5833 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5834 | // Test that extensions on intermediates are allowed but ignored. |
| 5835 | testCases = append(testCases, testCase{ |
| 5836 | name: "IgnoreExtensionsOnIntermediates-TLS13", |
| 5837 | config: Config{ |
| 5838 | MaxVersion: VersionTLS13, |
| 5839 | Certificates: []Certificate{rsaChainCertificate}, |
| 5840 | Bugs: ProtocolBugs{ |
| 5841 | // Send different values on the intermediate. This tests |
| 5842 | // the intermediate's extensions do not override the |
| 5843 | // leaf's. |
| 5844 | SendOCSPOnIntermediates: []byte{1, 3, 3, 7}, |
Adam Langley | cfa08c3 | 2016-11-17 13:21:27 -0800 | [diff] [blame] | 5845 | SendSCTOnIntermediates: differentSCTList, |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5846 | }, |
| 5847 | }, |
| 5848 | flags: []string{ |
| 5849 | "-enable-ocsp-stapling", |
| 5850 | "-expect-ocsp-response", |
| 5851 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5852 | "-enable-signed-cert-timestamps", |
| 5853 | "-expect-signed-cert-timestamps", |
| 5854 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5855 | }, |
| 5856 | resumeSession: true, |
| 5857 | }) |
| 5858 | |
| 5859 | // Test that extensions are not sent on intermediates when configured |
| 5860 | // only for a leaf. |
| 5861 | testCases = append(testCases, testCase{ |
| 5862 | testType: serverTest, |
| 5863 | name: "SendNoExtensionsOnIntermediate-TLS13", |
| 5864 | config: Config{ |
| 5865 | MaxVersion: VersionTLS13, |
| 5866 | Bugs: ProtocolBugs{ |
| 5867 | ExpectNoExtensionsOnIntermediate: true, |
| 5868 | }, |
| 5869 | }, |
| 5870 | flags: []string{ |
| 5871 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 5872 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 5873 | "-ocsp-response", |
| 5874 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5875 | "-signed-cert-timestamps", |
| 5876 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5877 | }, |
| 5878 | }) |
| 5879 | |
| 5880 | // Test that extensions are not sent on client certificates. |
| 5881 | testCases = append(testCases, testCase{ |
| 5882 | name: "SendNoClientCertificateExtensions-TLS13", |
| 5883 | config: Config{ |
| 5884 | MaxVersion: VersionTLS13, |
| 5885 | ClientAuth: RequireAnyClientCert, |
| 5886 | }, |
| 5887 | flags: []string{ |
| 5888 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 5889 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 5890 | "-ocsp-response", |
| 5891 | base64.StdEncoding.EncodeToString(testOCSPResponse), |
| 5892 | "-signed-cert-timestamps", |
| 5893 | base64.StdEncoding.EncodeToString(testSCTList), |
| 5894 | }, |
| 5895 | }) |
| 5896 | |
| 5897 | testCases = append(testCases, testCase{ |
| 5898 | name: "SendDuplicateExtensionsOnCerts-TLS13", |
| 5899 | config: Config{ |
| 5900 | MaxVersion: VersionTLS13, |
| 5901 | Bugs: ProtocolBugs{ |
| 5902 | SendDuplicateCertExtensions: true, |
| 5903 | }, |
| 5904 | }, |
| 5905 | flags: []string{ |
| 5906 | "-enable-ocsp-stapling", |
| 5907 | "-enable-signed-cert-timestamps", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5908 | }, |
| 5909 | resumeSession: true, |
| 5910 | shouldFail: true, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 5911 | expectedError: ":DUPLICATE_EXTENSION:", |
David Benjamin | daa8850 | 2016-10-04 16:32:16 -0400 | [diff] [blame] | 5912 | }) |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5913 | |
| 5914 | testCases = append(testCases, testCase{ |
| 5915 | name: "SignedCertificateTimestampListInvalid-Server", |
| 5916 | testType: serverTest, |
| 5917 | flags: []string{ |
| 5918 | "-signed-cert-timestamps", |
| 5919 | base64.StdEncoding.EncodeToString([]byte{0, 0}), |
| 5920 | }, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 5921 | shouldFail: true, |
Adam Langley | 9b885c5 | 2016-11-18 14:21:03 -0800 | [diff] [blame] | 5922 | expectedError: ":INVALID_SCT_LIST:", |
| 5923 | }) |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 5924 | } |
| 5925 | |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5926 | func addResumptionVersionTests() { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5927 | for _, sessionVers := range tlsVersions { |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 5928 | for _, resumeVers := range tlsVersions { |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5929 | // SSL 3.0 does not have tickets and TLS 1.3 does not |
| 5930 | // have session IDs, so skip their cross-resumption |
| 5931 | // tests. |
| 5932 | if (sessionVers.version >= VersionTLS13 && resumeVers.version == VersionSSL30) || |
| 5933 | (resumeVers.version >= VersionTLS13 && sessionVers.version == VersionSSL30) { |
| 5934 | continue |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 5935 | } |
| 5936 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5937 | protocols := []protocol{tls} |
| 5938 | if sessionVers.hasDTLS && resumeVers.hasDTLS { |
| 5939 | protocols = append(protocols, dtls) |
David Benjamin | bdf5e72 | 2014-11-11 00:52:15 -0500 | [diff] [blame] | 5940 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5941 | for _, protocol := range protocols { |
| 5942 | suffix := "-" + sessionVers.name + "-" + resumeVers.name |
| 5943 | if protocol == dtls { |
| 5944 | suffix += "-DTLS" |
| 5945 | } |
| 5946 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5947 | if sessionVers.version == resumeVers.version { |
| 5948 | testCases = append(testCases, testCase{ |
| 5949 | protocol: protocol, |
| 5950 | name: "Resume-Client" + suffix, |
| 5951 | resumeSession: true, |
| 5952 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5953 | MaxVersion: sessionVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5954 | Bugs: ProtocolBugs{ |
| 5955 | ExpectNoTLS12Session: sessionVers.version >= VersionTLS13, |
| 5956 | ExpectNoTLS13PSK: sessionVers.version < VersionTLS13, |
| 5957 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5958 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5959 | expectedVersion: sessionVers.version, |
| 5960 | expectedResumeVersion: resumeVers.version, |
| 5961 | }) |
| 5962 | } else { |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5963 | error := ":OLD_SESSION_VERSION_NOT_RETURNED:" |
| 5964 | |
| 5965 | // Offering a TLS 1.3 session sends an empty session ID, so |
| 5966 | // there is no way to convince a non-lookahead client the |
| 5967 | // session was resumed. It will appear to the client that a |
| 5968 | // stray ChangeCipherSpec was sent. |
| 5969 | if resumeVers.version < VersionTLS13 && sessionVers.version >= VersionTLS13 { |
| 5970 | error = ":UNEXPECTED_RECORD:" |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5971 | } |
| 5972 | |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5973 | testCases = append(testCases, testCase{ |
| 5974 | protocol: protocol, |
| 5975 | name: "Resume-Client-Mismatch" + suffix, |
| 5976 | resumeSession: true, |
| 5977 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5978 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5979 | }, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5980 | expectedVersion: sessionVers.version, |
| 5981 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5982 | MaxVersion: resumeVers.version, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5983 | Bugs: ProtocolBugs{ |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 5984 | AcceptAnySession: true, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5985 | }, |
| 5986 | }, |
| 5987 | expectedResumeVersion: resumeVers.version, |
| 5988 | shouldFail: true, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 5989 | expectedError: error, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 5990 | }) |
| 5991 | } |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5992 | |
| 5993 | testCases = append(testCases, testCase{ |
| 5994 | protocol: protocol, |
| 5995 | name: "Resume-Client-NoResume" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5996 | resumeSession: true, |
| 5997 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 5998 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 5999 | }, |
| 6000 | expectedVersion: sessionVers.version, |
| 6001 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6002 | MaxVersion: resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6003 | }, |
| 6004 | newSessionsOnResume: true, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6005 | expectResumeRejected: true, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6006 | expectedResumeVersion: resumeVers.version, |
| 6007 | }) |
| 6008 | |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6009 | testCases = append(testCases, testCase{ |
| 6010 | protocol: protocol, |
| 6011 | testType: serverTest, |
| 6012 | name: "Resume-Server" + suffix, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6013 | resumeSession: true, |
| 6014 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6015 | MaxVersion: sessionVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6016 | }, |
Adam Langley | b0eef0a | 2015-06-02 10:47:39 -0700 | [diff] [blame] | 6017 | expectedVersion: sessionVers.version, |
| 6018 | expectResumeRejected: sessionVers.version != resumeVers.version, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6019 | resumeConfig: &Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6020 | MaxVersion: resumeVers.version, |
David Benjamin | 405da48 | 2016-08-08 17:25:07 -0400 | [diff] [blame] | 6021 | Bugs: ProtocolBugs{ |
| 6022 | SendBothTickets: true, |
| 6023 | }, |
David Benjamin | 8b8c006 | 2014-11-23 02:47:52 -0500 | [diff] [blame] | 6024 | }, |
| 6025 | expectedResumeVersion: resumeVers.version, |
| 6026 | }) |
| 6027 | } |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6028 | } |
| 6029 | } |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6030 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6031 | // Make sure shim ticket mutations are functional. |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6032 | testCases = append(testCases, testCase{ |
| 6033 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6034 | name: "ShimTicketRewritable", |
| 6035 | resumeSession: true, |
| 6036 | config: Config{ |
| 6037 | MaxVersion: VersionTLS12, |
| 6038 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6039 | Bugs: ProtocolBugs{ |
| 6040 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6041 | in, err := SetShimTicketVersion(in, VersionTLS12) |
| 6042 | if err != nil { |
| 6043 | return nil, err |
| 6044 | } |
| 6045 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6046 | }, |
| 6047 | }, |
| 6048 | }, |
| 6049 | flags: []string{ |
| 6050 | "-ticket-key", |
| 6051 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6052 | }, |
| 6053 | }) |
| 6054 | |
| 6055 | // Resumptions are declined if the version does not match. |
| 6056 | testCases = append(testCases, testCase{ |
| 6057 | testType: serverTest, |
| 6058 | name: "Resume-Server-DeclineCrossVersion", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6059 | resumeSession: true, |
| 6060 | config: Config{ |
| 6061 | MaxVersion: VersionTLS12, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6062 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6063 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6064 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6065 | return SetShimTicketVersion(in, VersionTLS13) |
| 6066 | }, |
| 6067 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6068 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6069 | flags: []string{ |
| 6070 | "-ticket-key", |
| 6071 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6072 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6073 | expectResumeRejected: true, |
| 6074 | }) |
| 6075 | |
| 6076 | testCases = append(testCases, testCase{ |
| 6077 | testType: serverTest, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6078 | name: "Resume-Server-DeclineCrossVersion-TLS13", |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6079 | resumeSession: true, |
| 6080 | config: Config{ |
| 6081 | MaxVersion: VersionTLS13, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6082 | Bugs: ProtocolBugs{ |
| 6083 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6084 | return SetShimTicketVersion(in, VersionTLS12) |
| 6085 | }, |
| 6086 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6087 | }, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6088 | flags: []string{ |
| 6089 | "-ticket-key", |
| 6090 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6091 | }, |
Steven Valdez | b6b6ff3 | 2016-10-26 11:56:35 -0400 | [diff] [blame] | 6092 | expectResumeRejected: true, |
| 6093 | }) |
| 6094 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6095 | // Resumptions are declined if the cipher is invalid or disabled. |
| 6096 | testCases = append(testCases, testCase{ |
| 6097 | testType: serverTest, |
| 6098 | name: "Resume-Server-DeclineBadCipher", |
| 6099 | resumeSession: true, |
| 6100 | config: Config{ |
| 6101 | MaxVersion: VersionTLS12, |
| 6102 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6103 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6104 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6105 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6106 | }, |
| 6107 | }, |
| 6108 | }, |
| 6109 | flags: []string{ |
| 6110 | "-ticket-key", |
| 6111 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6112 | }, |
| 6113 | expectResumeRejected: true, |
| 6114 | }) |
| 6115 | |
| 6116 | testCases = append(testCases, testCase{ |
| 6117 | testType: serverTest, |
| 6118 | name: "Resume-Server-DeclineBadCipher-2", |
| 6119 | resumeSession: true, |
| 6120 | config: Config{ |
| 6121 | MaxVersion: VersionTLS12, |
| 6122 | Bugs: ProtocolBugs{ |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6123 | ExpectNewTicket: true, |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6124 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6125 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) |
| 6126 | }, |
| 6127 | }, |
| 6128 | }, |
| 6129 | flags: []string{ |
| 6130 | "-cipher", "AES128", |
| 6131 | "-ticket-key", |
| 6132 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6133 | }, |
| 6134 | expectResumeRejected: true, |
| 6135 | }) |
| 6136 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6137 | // Sessions are not resumed if they do not use the preferred cipher. |
| 6138 | testCases = append(testCases, testCase{ |
| 6139 | testType: serverTest, |
| 6140 | name: "Resume-Server-CipherNotPreferred", |
| 6141 | resumeSession: true, |
| 6142 | config: Config{ |
| 6143 | MaxVersion: VersionTLS12, |
| 6144 | Bugs: ProtocolBugs{ |
| 6145 | ExpectNewTicket: true, |
| 6146 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6147 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) |
| 6148 | }, |
| 6149 | }, |
| 6150 | }, |
| 6151 | flags: []string{ |
| 6152 | "-ticket-key", |
| 6153 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6154 | }, |
| 6155 | shouldFail: false, |
| 6156 | expectResumeRejected: true, |
| 6157 | }) |
| 6158 | |
| 6159 | // TLS 1.3 allows sessions to be resumed at a different cipher if their |
| 6160 | // PRF hashes match, but BoringSSL will always decline such resumptions. |
| 6161 | testCases = append(testCases, testCase{ |
| 6162 | testType: serverTest, |
| 6163 | name: "Resume-Server-CipherNotPreferred-TLS13", |
| 6164 | resumeSession: true, |
| 6165 | config: Config{ |
| 6166 | MaxVersion: VersionTLS13, |
| 6167 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_GCM_SHA256}, |
| 6168 | Bugs: ProtocolBugs{ |
| 6169 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6170 | // If the client (runner) offers ChaCha20-Poly1305 first, the |
| 6171 | // server (shim) always prefers it. Switch it to AES-GCM. |
| 6172 | return SetShimTicketCipherSuite(in, TLS_AES_128_GCM_SHA256) |
| 6173 | }, |
| 6174 | }, |
| 6175 | }, |
| 6176 | flags: []string{ |
| 6177 | "-ticket-key", |
| 6178 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6179 | }, |
| 6180 | shouldFail: false, |
| 6181 | expectResumeRejected: true, |
| 6182 | }) |
| 6183 | |
| 6184 | // Sessions may not be resumed if they contain another version's cipher. |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6185 | testCases = append(testCases, testCase{ |
| 6186 | testType: serverTest, |
| 6187 | name: "Resume-Server-DeclineBadCipher-TLS13", |
| 6188 | resumeSession: true, |
| 6189 | config: Config{ |
| 6190 | MaxVersion: VersionTLS13, |
| 6191 | Bugs: ProtocolBugs{ |
| 6192 | FilterTicket: func(in []byte) ([]byte, error) { |
| 6193 | return SetShimTicketCipherSuite(in, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) |
| 6194 | }, |
| 6195 | }, |
| 6196 | }, |
| 6197 | flags: []string{ |
| 6198 | "-ticket-key", |
| 6199 | base64.StdEncoding.EncodeToString(TestShimTicketKey), |
| 6200 | }, |
| 6201 | expectResumeRejected: true, |
| 6202 | }) |
| 6203 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6204 | // If the client does not offer the cipher from the session, decline to |
| 6205 | // resume. Clients are forbidden from doing this, but BoringSSL selects |
| 6206 | // the cipher first, so we only decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6207 | testCases = append(testCases, testCase{ |
| 6208 | testType: serverTest, |
| 6209 | name: "Resume-Server-UnofferedCipher", |
| 6210 | resumeSession: true, |
| 6211 | config: Config{ |
| 6212 | MaxVersion: VersionTLS12, |
| 6213 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6214 | }, |
| 6215 | resumeConfig: &Config{ |
| 6216 | MaxVersion: VersionTLS12, |
| 6217 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 6218 | Bugs: ProtocolBugs{ |
| 6219 | SendCipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6220 | }, |
| 6221 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6222 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6223 | }) |
| 6224 | |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6225 | // In TLS 1.3, clients may advertise a cipher list which does not |
| 6226 | // include the selected cipher. Test that we tolerate this. Servers may |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 6227 | // resume at another cipher if the PRF matches and are not doing 0-RTT, but |
| 6228 | // BoringSSL will always decline. |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6229 | testCases = append(testCases, testCase{ |
| 6230 | testType: serverTest, |
| 6231 | name: "Resume-Server-UnofferedCipher-TLS13", |
| 6232 | resumeSession: true, |
| 6233 | config: Config{ |
| 6234 | MaxVersion: VersionTLS13, |
| 6235 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6236 | }, |
| 6237 | resumeConfig: &Config{ |
| 6238 | MaxVersion: VersionTLS13, |
| 6239 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6240 | Bugs: ProtocolBugs{ |
| 6241 | SendCipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6242 | }, |
| 6243 | }, |
David Benjamin | f01f42a | 2016-11-16 19:05:33 +0900 | [diff] [blame] | 6244 | expectResumeRejected: true, |
David Benjamin | 75f9914 | 2016-11-12 12:36:06 +0900 | [diff] [blame] | 6245 | }) |
| 6246 | |
David Benjamin | 4199b0d | 2016-11-01 13:58:25 -0400 | [diff] [blame] | 6247 | // Sessions may not be resumed at a different cipher. |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6248 | testCases = append(testCases, testCase{ |
| 6249 | name: "Resume-Client-CipherMismatch", |
| 6250 | resumeSession: true, |
| 6251 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6252 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6253 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6254 | }, |
| 6255 | resumeConfig: &Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6256 | MaxVersion: VersionTLS12, |
David Benjamin | ece3de9 | 2015-03-16 18:02:20 -0400 | [diff] [blame] | 6257 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 6258 | Bugs: ProtocolBugs{ |
| 6259 | SendCipherSuite: TLS_RSA_WITH_AES_128_CBC_SHA, |
| 6260 | }, |
| 6261 | }, |
| 6262 | shouldFail: true, |
| 6263 | expectedError: ":OLD_SESSION_CIPHER_NOT_RETURNED:", |
| 6264 | }) |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6265 | |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6266 | // Session resumption in TLS 1.3 may change the cipher suite if the PRF |
| 6267 | // matches. |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6268 | testCases = append(testCases, testCase{ |
| 6269 | name: "Resume-Client-CipherMismatch-TLS13", |
| 6270 | resumeSession: true, |
| 6271 | config: Config{ |
| 6272 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6273 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6274 | }, |
| 6275 | resumeConfig: &Config{ |
| 6276 | MaxVersion: VersionTLS13, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6277 | CipherSuites: []uint16{TLS_CHACHA20_POLY1305_SHA256}, |
| 6278 | }, |
| 6279 | }) |
| 6280 | |
| 6281 | // Session resumption in TLS 1.3 is forbidden if the PRF does not match. |
| 6282 | testCases = append(testCases, testCase{ |
| 6283 | name: "Resume-Client-PRFMismatch-TLS13", |
| 6284 | resumeSession: true, |
| 6285 | config: Config{ |
| 6286 | MaxVersion: VersionTLS13, |
| 6287 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
| 6288 | }, |
| 6289 | resumeConfig: &Config{ |
| 6290 | MaxVersion: VersionTLS13, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6291 | CipherSuites: []uint16{TLS_AES_128_GCM_SHA256}, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6292 | Bugs: ProtocolBugs{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6293 | SendCipherSuite: TLS_AES_256_GCM_SHA384, |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6294 | }, |
| 6295 | }, |
| 6296 | shouldFail: true, |
David Benjamin | e1cc35e | 2016-11-16 16:25:58 +0900 | [diff] [blame] | 6297 | expectedError: ":OLD_SESSION_PRF_HASH_MISMATCH:", |
Steven Valdez | 4aa154e | 2016-07-29 14:32:55 -0400 | [diff] [blame] | 6298 | }) |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6299 | |
| 6300 | testCases = append(testCases, testCase{ |
| 6301 | testType: serverTest, |
| 6302 | name: "Resume-Server-BinderWrongLength", |
| 6303 | resumeSession: true, |
| 6304 | config: Config{ |
| 6305 | MaxVersion: VersionTLS13, |
| 6306 | Bugs: ProtocolBugs{ |
| 6307 | SendShortPSKBinder: true, |
| 6308 | }, |
| 6309 | }, |
| 6310 | shouldFail: true, |
| 6311 | expectedLocalError: "remote error: error decrypting message", |
| 6312 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6313 | }) |
| 6314 | |
| 6315 | testCases = append(testCases, testCase{ |
| 6316 | testType: serverTest, |
| 6317 | name: "Resume-Server-NoPSKBinder", |
| 6318 | resumeSession: true, |
| 6319 | config: Config{ |
| 6320 | MaxVersion: VersionTLS13, |
| 6321 | Bugs: ProtocolBugs{ |
| 6322 | SendNoPSKBinder: true, |
| 6323 | }, |
| 6324 | }, |
| 6325 | shouldFail: true, |
| 6326 | expectedLocalError: "remote error: error decoding message", |
| 6327 | expectedError: ":DECODE_ERROR:", |
| 6328 | }) |
| 6329 | |
| 6330 | testCases = append(testCases, testCase{ |
| 6331 | testType: serverTest, |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 6332 | name: "Resume-Server-ExtraPSKBinder", |
| 6333 | resumeSession: true, |
| 6334 | config: Config{ |
| 6335 | MaxVersion: VersionTLS13, |
| 6336 | Bugs: ProtocolBugs{ |
| 6337 | SendExtraPSKBinder: true, |
| 6338 | }, |
| 6339 | }, |
| 6340 | shouldFail: true, |
| 6341 | expectedLocalError: "remote error: illegal parameter", |
| 6342 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6343 | }) |
| 6344 | |
| 6345 | testCases = append(testCases, testCase{ |
| 6346 | testType: serverTest, |
| 6347 | name: "Resume-Server-ExtraIdentityNoBinder", |
| 6348 | resumeSession: true, |
| 6349 | config: Config{ |
| 6350 | MaxVersion: VersionTLS13, |
| 6351 | Bugs: ProtocolBugs{ |
| 6352 | ExtraPSKIdentity: true, |
| 6353 | }, |
| 6354 | }, |
| 6355 | shouldFail: true, |
| 6356 | expectedLocalError: "remote error: illegal parameter", |
| 6357 | expectedError: ":PSK_IDENTITY_BINDER_COUNT_MISMATCH:", |
| 6358 | }) |
| 6359 | |
| 6360 | testCases = append(testCases, testCase{ |
| 6361 | testType: serverTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 6362 | name: "Resume-Server-InvalidPSKBinder", |
| 6363 | resumeSession: true, |
| 6364 | config: Config{ |
| 6365 | MaxVersion: VersionTLS13, |
| 6366 | Bugs: ProtocolBugs{ |
| 6367 | SendInvalidPSKBinder: true, |
| 6368 | }, |
| 6369 | }, |
| 6370 | shouldFail: true, |
| 6371 | expectedLocalError: "remote error: error decrypting message", |
| 6372 | expectedError: ":DIGEST_CHECK_FAILED:", |
| 6373 | }) |
| 6374 | |
| 6375 | testCases = append(testCases, testCase{ |
| 6376 | testType: serverTest, |
| 6377 | name: "Resume-Server-PSKBinderFirstExtension", |
| 6378 | resumeSession: true, |
| 6379 | config: Config{ |
| 6380 | MaxVersion: VersionTLS13, |
| 6381 | Bugs: ProtocolBugs{ |
| 6382 | PSKBinderFirst: true, |
| 6383 | }, |
| 6384 | }, |
| 6385 | shouldFail: true, |
| 6386 | expectedLocalError: "remote error: illegal parameter", |
| 6387 | expectedError: ":PRE_SHARED_KEY_MUST_BE_LAST:", |
| 6388 | }) |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 6389 | } |
| 6390 | |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6391 | func addRenegotiationTests() { |
David Benjamin | 44d3eed | 2015-05-21 01:29:55 -0400 | [diff] [blame] | 6392 | // Servers cannot renegotiate. |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6393 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6394 | testType: serverTest, |
| 6395 | name: "Renegotiate-Server-Forbidden", |
| 6396 | config: Config{ |
| 6397 | MaxVersion: VersionTLS12, |
| 6398 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6399 | renegotiate: 1, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6400 | shouldFail: true, |
| 6401 | expectedError: ":NO_RENEGOTIATION:", |
| 6402 | expectedLocalError: "remote error: no renegotiation", |
| 6403 | }) |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6404 | // The server shouldn't echo the renegotiation extension unless |
| 6405 | // requested by the client. |
| 6406 | testCases = append(testCases, testCase{ |
| 6407 | testType: serverTest, |
| 6408 | name: "Renegotiate-Server-NoExt", |
| 6409 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6410 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6411 | Bugs: ProtocolBugs{ |
| 6412 | NoRenegotiationInfo: true, |
| 6413 | RequireRenegotiationInfo: true, |
| 6414 | }, |
| 6415 | }, |
| 6416 | shouldFail: true, |
| 6417 | expectedLocalError: "renegotiation extension missing", |
| 6418 | }) |
| 6419 | // The renegotiation SCSV should be sufficient for the server to echo |
| 6420 | // the extension. |
| 6421 | testCases = append(testCases, testCase{ |
| 6422 | testType: serverTest, |
| 6423 | name: "Renegotiate-Server-NoExt-SCSV", |
| 6424 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6425 | MaxVersion: VersionTLS12, |
Adam Langley | 5021b22 | 2015-06-12 18:27:58 -0700 | [diff] [blame] | 6426 | Bugs: ProtocolBugs{ |
| 6427 | NoRenegotiationInfo: true, |
| 6428 | SendRenegotiationSCSV: true, |
| 6429 | RequireRenegotiationInfo: true, |
| 6430 | }, |
| 6431 | }, |
| 6432 | }) |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6433 | testCases = append(testCases, testCase{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6434 | name: "Renegotiate-Client", |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6435 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6436 | MaxVersion: VersionTLS12, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6437 | Bugs: ProtocolBugs{ |
David Benjamin | 4b27d9f | 2015-05-12 22:42:52 -0400 | [diff] [blame] | 6438 | FailIfResumeOnRenego: true, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6439 | }, |
| 6440 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6441 | renegotiate: 1, |
| 6442 | flags: []string{ |
| 6443 | "-renegotiate-freely", |
| 6444 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6445 | "-expect-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6446 | }, |
David Benjamin | cdea40c | 2015-03-19 14:09:43 -0400 | [diff] [blame] | 6447 | }) |
| 6448 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6449 | name: "Renegotiate-Client-EmptyExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6450 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6451 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6452 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6453 | Bugs: ProtocolBugs{ |
| 6454 | EmptyRenegotiationInfo: true, |
| 6455 | }, |
| 6456 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6457 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6458 | shouldFail: true, |
| 6459 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6460 | }) |
| 6461 | testCases = append(testCases, testCase{ |
| 6462 | name: "Renegotiate-Client-BadExt", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6463 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6464 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6465 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6466 | Bugs: ProtocolBugs{ |
| 6467 | BadRenegotiationInfo: true, |
| 6468 | }, |
| 6469 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6470 | flags: []string{"-renegotiate-freely"}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6471 | shouldFail: true, |
| 6472 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6473 | }) |
| 6474 | testCases = append(testCases, testCase{ |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6475 | name: "Renegotiate-Client-Downgrade", |
| 6476 | renegotiate: 1, |
| 6477 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6478 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6479 | Bugs: ProtocolBugs{ |
| 6480 | NoRenegotiationInfoAfterInitial: true, |
| 6481 | }, |
| 6482 | }, |
| 6483 | flags: []string{"-renegotiate-freely"}, |
| 6484 | shouldFail: true, |
| 6485 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6486 | }) |
| 6487 | testCases = append(testCases, testCase{ |
| 6488 | name: "Renegotiate-Client-Upgrade", |
| 6489 | renegotiate: 1, |
| 6490 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6491 | MaxVersion: VersionTLS12, |
David Benjamin | 3e052de | 2015-11-25 20:10:31 -0500 | [diff] [blame] | 6492 | Bugs: ProtocolBugs{ |
| 6493 | NoRenegotiationInfoInInitial: true, |
| 6494 | }, |
| 6495 | }, |
| 6496 | flags: []string{"-renegotiate-freely"}, |
| 6497 | shouldFail: true, |
| 6498 | expectedError: ":RENEGOTIATION_MISMATCH:", |
| 6499 | }) |
| 6500 | testCases = append(testCases, testCase{ |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6501 | name: "Renegotiate-Client-NoExt-Allowed", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6502 | renegotiate: 1, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6503 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6504 | MaxVersion: VersionTLS12, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6505 | Bugs: ProtocolBugs{ |
| 6506 | NoRenegotiationInfo: true, |
| 6507 | }, |
| 6508 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6509 | flags: []string{ |
| 6510 | "-renegotiate-freely", |
| 6511 | "-expect-total-renegotiations", "1", |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6512 | "-expect-no-secure-renegotiation", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6513 | }, |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6514 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6515 | |
| 6516 | // Test that the server may switch ciphers on renegotiation without |
| 6517 | // problems. |
David Benjamin | cff0b90 | 2015-05-15 23:09:47 -0400 | [diff] [blame] | 6518 | testCases = append(testCases, testCase{ |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6519 | name: "Renegotiate-Client-SwitchCiphers", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6520 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6521 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6522 | MaxVersion: VersionTLS12, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6523 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6524 | }, |
| 6525 | renegotiateCiphers: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6526 | flags: []string{ |
| 6527 | "-renegotiate-freely", |
| 6528 | "-expect-total-renegotiations", "1", |
| 6529 | }, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6530 | }) |
| 6531 | testCases = append(testCases, testCase{ |
| 6532 | name: "Renegotiate-Client-SwitchCiphers2", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6533 | renegotiate: 1, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6534 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6535 | MaxVersion: VersionTLS12, |
Adam Langley | cf2d4f4 | 2014-10-28 19:06:14 -0700 | [diff] [blame] | 6536 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6537 | }, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 6538 | renegotiateCiphers: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6539 | flags: []string{ |
| 6540 | "-renegotiate-freely", |
| 6541 | "-expect-total-renegotiations", "1", |
| 6542 | }, |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6543 | }) |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6544 | |
| 6545 | // Test that the server may not switch versions on renegotiation. |
| 6546 | testCases = append(testCases, testCase{ |
| 6547 | name: "Renegotiate-Client-SwitchVersion", |
| 6548 | config: Config{ |
| 6549 | MaxVersion: VersionTLS12, |
| 6550 | // Pick a cipher which exists at both versions. |
| 6551 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, |
| 6552 | Bugs: ProtocolBugs{ |
| 6553 | NegotiateVersionOnRenego: VersionTLS11, |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 6554 | // Avoid failing early at the record layer. |
| 6555 | SendRecordVersion: VersionTLS12, |
David Benjamin | e7e36aa | 2016-08-08 12:39:41 -0400 | [diff] [blame] | 6556 | }, |
| 6557 | }, |
| 6558 | renegotiate: 1, |
| 6559 | flags: []string{ |
| 6560 | "-renegotiate-freely", |
| 6561 | "-expect-total-renegotiations", "1", |
| 6562 | }, |
| 6563 | shouldFail: true, |
| 6564 | expectedError: ":WRONG_SSL_VERSION:", |
| 6565 | }) |
| 6566 | |
David Benjamin | b16346b | 2015-04-08 19:16:58 -0400 | [diff] [blame] | 6567 | testCases = append(testCases, testCase{ |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6568 | name: "Renegotiate-SameClientVersion", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6569 | renegotiate: 1, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6570 | config: Config{ |
| 6571 | MaxVersion: VersionTLS10, |
| 6572 | Bugs: ProtocolBugs{ |
| 6573 | RequireSameRenegoClientVersion: true, |
| 6574 | }, |
| 6575 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6576 | flags: []string{ |
| 6577 | "-renegotiate-freely", |
| 6578 | "-expect-total-renegotiations", "1", |
| 6579 | }, |
David Benjamin | c44b1df | 2014-11-23 12:11:01 -0500 | [diff] [blame] | 6580 | }) |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6581 | testCases = append(testCases, testCase{ |
| 6582 | name: "Renegotiate-FalseStart", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6583 | renegotiate: 1, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6584 | config: Config{ |
Nick Harper | 1fd39d8 | 2016-06-14 18:14:35 -0700 | [diff] [blame] | 6585 | MaxVersion: VersionTLS12, |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6586 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 6587 | NextProtos: []string{"foo"}, |
| 6588 | }, |
| 6589 | flags: []string{ |
| 6590 | "-false-start", |
| 6591 | "-select-next-proto", "foo", |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6592 | "-renegotiate-freely", |
David Benjamin | 324dce4 | 2015-10-12 19:49:00 -0400 | [diff] [blame] | 6593 | "-expect-total-renegotiations", "1", |
Adam Langley | b558c4c | 2015-07-08 12:16:38 -0700 | [diff] [blame] | 6594 | }, |
| 6595 | shimWritesFirst: true, |
| 6596 | }) |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6597 | |
| 6598 | // Client-side renegotiation controls. |
| 6599 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6600 | name: "Renegotiate-Client-Forbidden-1", |
| 6601 | config: Config{ |
| 6602 | MaxVersion: VersionTLS12, |
| 6603 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6604 | renegotiate: 1, |
| 6605 | shouldFail: true, |
| 6606 | expectedError: ":NO_RENEGOTIATION:", |
| 6607 | expectedLocalError: "remote error: no renegotiation", |
| 6608 | }) |
| 6609 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6610 | name: "Renegotiate-Client-Once-1", |
| 6611 | config: Config{ |
| 6612 | MaxVersion: VersionTLS12, |
| 6613 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6614 | renegotiate: 1, |
| 6615 | flags: []string{ |
| 6616 | "-renegotiate-once", |
| 6617 | "-expect-total-renegotiations", "1", |
| 6618 | }, |
| 6619 | }) |
| 6620 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6621 | name: "Renegotiate-Client-Freely-1", |
| 6622 | config: Config{ |
| 6623 | MaxVersion: VersionTLS12, |
| 6624 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6625 | renegotiate: 1, |
| 6626 | flags: []string{ |
| 6627 | "-renegotiate-freely", |
| 6628 | "-expect-total-renegotiations", "1", |
| 6629 | }, |
| 6630 | }) |
| 6631 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6632 | name: "Renegotiate-Client-Once-2", |
| 6633 | config: Config{ |
| 6634 | MaxVersion: VersionTLS12, |
| 6635 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6636 | renegotiate: 2, |
| 6637 | flags: []string{"-renegotiate-once"}, |
| 6638 | shouldFail: true, |
| 6639 | expectedError: ":NO_RENEGOTIATION:", |
| 6640 | expectedLocalError: "remote error: no renegotiation", |
| 6641 | }) |
| 6642 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6643 | name: "Renegotiate-Client-Freely-2", |
| 6644 | config: Config{ |
| 6645 | MaxVersion: VersionTLS12, |
| 6646 | }, |
David Benjamin | 1d5ef3b | 2015-10-12 19:54:18 -0400 | [diff] [blame] | 6647 | renegotiate: 2, |
| 6648 | flags: []string{ |
| 6649 | "-renegotiate-freely", |
| 6650 | "-expect-total-renegotiations", "2", |
| 6651 | }, |
| 6652 | }) |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6653 | testCases = append(testCases, testCase{ |
| 6654 | name: "Renegotiate-Client-NoIgnore", |
| 6655 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6656 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6657 | Bugs: ProtocolBugs{ |
| 6658 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6659 | }, |
| 6660 | }, |
| 6661 | shouldFail: true, |
| 6662 | expectedError: ":NO_RENEGOTIATION:", |
| 6663 | }) |
| 6664 | testCases = append(testCases, testCase{ |
| 6665 | name: "Renegotiate-Client-Ignore", |
| 6666 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6667 | MaxVersion: VersionTLS12, |
Adam Langley | 27a0d08 | 2015-11-03 13:34:10 -0800 | [diff] [blame] | 6668 | Bugs: ProtocolBugs{ |
| 6669 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6670 | }, |
| 6671 | }, |
| 6672 | flags: []string{ |
| 6673 | "-renegotiate-ignore", |
| 6674 | "-expect-total-renegotiations", "0", |
| 6675 | }, |
| 6676 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 6677 | |
David Benjamin | 34941c0 | 2016-10-08 11:45:31 -0400 | [diff] [blame] | 6678 | // Renegotiation is not allowed at SSL 3.0. |
| 6679 | testCases = append(testCases, testCase{ |
| 6680 | name: "Renegotiate-Client-SSL3", |
| 6681 | config: Config{ |
| 6682 | MaxVersion: VersionSSL30, |
| 6683 | }, |
| 6684 | renegotiate: 1, |
| 6685 | flags: []string{ |
| 6686 | "-renegotiate-freely", |
| 6687 | "-expect-total-renegotiations", "1", |
| 6688 | }, |
| 6689 | shouldFail: true, |
| 6690 | expectedError: ":NO_RENEGOTIATION:", |
| 6691 | expectedLocalError: "remote error: no renegotiation", |
| 6692 | }) |
| 6693 | |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6694 | // Renegotiation is not allowed when there is an unfinished write. |
| 6695 | testCases = append(testCases, testCase{ |
| 6696 | name: "Renegotiate-Client-UnfinishedWrite", |
| 6697 | config: Config{ |
| 6698 | MaxVersion: VersionTLS12, |
| 6699 | }, |
David Benjamin | bbba939 | 2017-04-06 12:54:12 -0400 | [diff] [blame] | 6700 | renegotiate: 1, |
| 6701 | readWithUnfinishedWrite: true, |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6702 | flags: []string{ |
| 6703 | "-async", |
| 6704 | "-renegotiate-freely", |
David Benjamin | a1eaba1 | 2017-01-01 23:19:22 -0500 | [diff] [blame] | 6705 | }, |
| 6706 | shouldFail: true, |
| 6707 | expectedError: ":NO_RENEGOTIATION:", |
| 6708 | // We do not successfully send the no_renegotiation alert in |
| 6709 | // this case. https://crbug.com/boringssl/130 |
| 6710 | }) |
| 6711 | |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6712 | // We reject stray HelloRequests during the handshake in TLS 1.2. |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6713 | testCases = append(testCases, testCase{ |
| 6714 | name: "StrayHelloRequest", |
| 6715 | config: Config{ |
| 6716 | MaxVersion: VersionTLS12, |
| 6717 | Bugs: ProtocolBugs{ |
| 6718 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6719 | }, |
| 6720 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6721 | shouldFail: true, |
| 6722 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6723 | }) |
| 6724 | testCases = append(testCases, testCase{ |
| 6725 | name: "StrayHelloRequest-Packed", |
| 6726 | config: Config{ |
| 6727 | MaxVersion: VersionTLS12, |
| 6728 | Bugs: ProtocolBugs{ |
| 6729 | PackHandshakeFlight: true, |
| 6730 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6731 | }, |
| 6732 | }, |
David Benjamin | 07ab5d4 | 2017-02-09 20:11:41 -0500 | [diff] [blame] | 6733 | shouldFail: true, |
| 6734 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 71dd666 | 2016-07-08 14:10:48 -0700 | [diff] [blame] | 6735 | }) |
| 6736 | |
David Benjamin | 12d2c48 | 2016-07-24 10:56:51 -0400 | [diff] [blame] | 6737 | // Test renegotiation works if HelloRequest and server Finished come in |
| 6738 | // the same record. |
| 6739 | testCases = append(testCases, testCase{ |
| 6740 | name: "Renegotiate-Client-Packed", |
| 6741 | config: Config{ |
| 6742 | MaxVersion: VersionTLS12, |
| 6743 | Bugs: ProtocolBugs{ |
| 6744 | PackHandshakeFlight: true, |
| 6745 | PackHelloRequestWithFinished: true, |
| 6746 | }, |
| 6747 | }, |
| 6748 | renegotiate: 1, |
| 6749 | flags: []string{ |
| 6750 | "-renegotiate-freely", |
| 6751 | "-expect-total-renegotiations", "1", |
| 6752 | }, |
| 6753 | }) |
| 6754 | |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6755 | // Renegotiation is forbidden in TLS 1.3. |
| 6756 | testCases = append(testCases, testCase{ |
| 6757 | name: "Renegotiate-Client-TLS13", |
| 6758 | config: Config{ |
| 6759 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 6760 | Bugs: ProtocolBugs{ |
| 6761 | SendHelloRequestBeforeEveryAppDataRecord: true, |
| 6762 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6763 | }, |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6764 | flags: []string{ |
| 6765 | "-renegotiate-freely", |
| 6766 | }, |
Steven Valdez | 8e1c7be | 2016-07-26 12:39:22 -0400 | [diff] [blame] | 6767 | shouldFail: true, |
| 6768 | expectedError: ":UNEXPECTED_MESSAGE:", |
David Benjamin | 397c8e6 | 2016-07-08 14:14:36 -0700 | [diff] [blame] | 6769 | }) |
| 6770 | |
| 6771 | // Stray HelloRequests during the handshake are forbidden in TLS 1.3. |
| 6772 | testCases = append(testCases, testCase{ |
| 6773 | name: "StrayHelloRequest-TLS13", |
| 6774 | config: Config{ |
| 6775 | MaxVersion: VersionTLS13, |
| 6776 | Bugs: ProtocolBugs{ |
| 6777 | SendHelloRequestBeforeEveryHandshakeMessage: true, |
| 6778 | }, |
| 6779 | }, |
| 6780 | shouldFail: true, |
| 6781 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 6782 | }) |
David Benjamin | d261004 | 2017-01-03 10:49:28 -0500 | [diff] [blame] | 6783 | |
| 6784 | // The renegotiation_info extension is not sent in TLS 1.3, but TLS 1.3 |
| 6785 | // always reads as supporting it, regardless of whether it was |
| 6786 | // negotiated. |
| 6787 | testCases = append(testCases, testCase{ |
| 6788 | name: "AlwaysReportRenegotiationInfo-TLS13", |
| 6789 | config: Config{ |
| 6790 | MaxVersion: VersionTLS13, |
| 6791 | Bugs: ProtocolBugs{ |
| 6792 | NoRenegotiationInfo: true, |
| 6793 | }, |
| 6794 | }, |
| 6795 | flags: []string{ |
| 6796 | "-expect-secure-renegotiation", |
| 6797 | }, |
| 6798 | }) |
David Benjamin | a58baaf | 2017-02-28 20:54:28 -0500 | [diff] [blame] | 6799 | |
| 6800 | // Certificates may not change on renegotiation. |
| 6801 | testCases = append(testCases, testCase{ |
| 6802 | name: "Renegotiation-CertificateChange", |
| 6803 | config: Config{ |
| 6804 | MaxVersion: VersionTLS12, |
| 6805 | Certificates: []Certificate{rsaCertificate}, |
| 6806 | Bugs: ProtocolBugs{ |
| 6807 | RenegotiationCertificate: &rsaChainCertificate, |
| 6808 | }, |
| 6809 | }, |
| 6810 | renegotiate: 1, |
| 6811 | flags: []string{"-renegotiate-freely"}, |
| 6812 | shouldFail: true, |
| 6813 | expectedError: ":SERVER_CERT_CHANGED:", |
| 6814 | }) |
| 6815 | testCases = append(testCases, testCase{ |
| 6816 | name: "Renegotiation-CertificateChange-2", |
| 6817 | config: Config{ |
| 6818 | MaxVersion: VersionTLS12, |
| 6819 | Certificates: []Certificate{rsaCertificate}, |
| 6820 | Bugs: ProtocolBugs{ |
| 6821 | RenegotiationCertificate: &rsa1024Certificate, |
| 6822 | }, |
| 6823 | }, |
| 6824 | renegotiate: 1, |
| 6825 | flags: []string{"-renegotiate-freely"}, |
| 6826 | shouldFail: true, |
| 6827 | expectedError: ":SERVER_CERT_CHANGED:", |
| 6828 | }) |
David Benjamin | bbf4246 | 2017-03-14 21:27:10 -0400 | [diff] [blame] | 6829 | |
| 6830 | // We do not negotiate ALPN after the initial handshake. This is |
| 6831 | // error-prone and only risks bugs in consumers. |
| 6832 | testCases = append(testCases, testCase{ |
| 6833 | testType: clientTest, |
| 6834 | name: "Renegotiation-ForbidALPN", |
| 6835 | config: Config{ |
| 6836 | MaxVersion: VersionTLS12, |
| 6837 | Bugs: ProtocolBugs{ |
| 6838 | // Forcibly negotiate ALPN on both initial and |
| 6839 | // renegotiation handshakes. The test stack will |
| 6840 | // internally check the client does not offer |
| 6841 | // it. |
| 6842 | SendALPN: "foo", |
| 6843 | }, |
| 6844 | }, |
| 6845 | flags: []string{ |
| 6846 | "-advertise-alpn", "\x03foo\x03bar\x03baz", |
| 6847 | "-expect-alpn", "foo", |
| 6848 | "-renegotiate-freely", |
| 6849 | }, |
| 6850 | renegotiate: 1, |
| 6851 | shouldFail: true, |
| 6852 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 6853 | }) |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 6854 | } |
| 6855 | |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6856 | func addDTLSReplayTests() { |
| 6857 | // Test that sequence number replays are detected. |
| 6858 | testCases = append(testCases, testCase{ |
| 6859 | protocol: dtls, |
| 6860 | name: "DTLS-Replay", |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6861 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6862 | replayWrites: true, |
| 6863 | }) |
| 6864 | |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6865 | // Test the incoming sequence number skipping by values larger |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6866 | // than the retransmit window. |
| 6867 | testCases = append(testCases, testCase{ |
| 6868 | protocol: dtls, |
| 6869 | name: "DTLS-Replay-LargeGaps", |
| 6870 | config: Config{ |
| 6871 | Bugs: ProtocolBugs{ |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6872 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6873 | return in * 127 |
| 6874 | }, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6875 | }, |
| 6876 | }, |
David Benjamin | 8e6db49 | 2015-07-25 18:29:23 -0400 | [diff] [blame] | 6877 | messageCount: 200, |
| 6878 | replayWrites: true, |
| 6879 | }) |
| 6880 | |
| 6881 | // Test the incoming sequence number changing non-monotonically. |
| 6882 | testCases = append(testCases, testCase{ |
| 6883 | protocol: dtls, |
| 6884 | name: "DTLS-Replay-NonMonotonic", |
| 6885 | config: Config{ |
| 6886 | Bugs: ProtocolBugs{ |
| 6887 | SequenceNumberMapping: func(in uint64) uint64 { |
| 6888 | return in ^ 31 |
| 6889 | }, |
| 6890 | }, |
| 6891 | }, |
| 6892 | messageCount: 200, |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 6893 | replayWrites: true, |
| 6894 | }) |
| 6895 | } |
| 6896 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6897 | var testSignatureAlgorithms = []struct { |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6898 | name string |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6899 | id signatureAlgorithm |
| 6900 | cert testCert |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6901 | }{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6902 | {"RSA-PKCS1-SHA1", signatureRSAPKCS1WithSHA1, testCertRSA}, |
| 6903 | {"RSA-PKCS1-SHA256", signatureRSAPKCS1WithSHA256, testCertRSA}, |
| 6904 | {"RSA-PKCS1-SHA384", signatureRSAPKCS1WithSHA384, testCertRSA}, |
| 6905 | {"RSA-PKCS1-SHA512", signatureRSAPKCS1WithSHA512, testCertRSA}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6906 | {"ECDSA-SHA1", signatureECDSAWithSHA1, testCertECDSAP256}, |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 6907 | // The “P256” in the following line is not a mistake. In TLS 1.2 the |
| 6908 | // hash function doesn't have to match the curve and so the same |
| 6909 | // signature algorithm works with P-224. |
| 6910 | {"ECDSA-P224-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP224}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 6911 | {"ECDSA-P256-SHA256", signatureECDSAWithP256AndSHA256, testCertECDSAP256}, |
| 6912 | {"ECDSA-P384-SHA384", signatureECDSAWithP384AndSHA384, testCertECDSAP384}, |
| 6913 | {"ECDSA-P521-SHA512", signatureECDSAWithP521AndSHA512, testCertECDSAP521}, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6914 | {"RSA-PSS-SHA256", signatureRSAPSSWithSHA256, testCertRSA}, |
| 6915 | {"RSA-PSS-SHA384", signatureRSAPSSWithSHA384, testCertRSA}, |
| 6916 | {"RSA-PSS-SHA512", signatureRSAPSSWithSHA512, testCertRSA}, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 6917 | {"Ed25519", signatureEd25519, testCertEd25519}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6918 | // Tests for key types prior to TLS 1.2. |
| 6919 | {"RSA", 0, testCertRSA}, |
| 6920 | {"ECDSA", 0, testCertECDSAP256}, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6921 | } |
| 6922 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6923 | const fakeSigAlg1 signatureAlgorithm = 0x2a01 |
| 6924 | const fakeSigAlg2 signatureAlgorithm = 0xff01 |
| 6925 | |
| 6926 | func addSignatureAlgorithmTests() { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6927 | // Not all ciphers involve a signature. Advertise a list which gives all |
| 6928 | // versions a signing cipher. |
| 6929 | signingCiphers := []uint16{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 6930 | TLS_AES_128_GCM_SHA256, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6931 | TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 6932 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 6933 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 6934 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 6935 | } |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6936 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 6937 | var allAlgorithms []signatureAlgorithm |
| 6938 | for _, alg := range testSignatureAlgorithms { |
| 6939 | if alg.id != 0 { |
| 6940 | allAlgorithms = append(allAlgorithms, alg.id) |
| 6941 | } |
| 6942 | } |
| 6943 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6944 | // Make sure each signature algorithm works. Include some fake values in |
| 6945 | // the list and ensure they're ignored. |
| 6946 | for _, alg := range testSignatureAlgorithms { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6947 | for _, ver := range tlsVersions { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 6948 | if (ver.version < VersionTLS12) != (alg.id == 0) { |
| 6949 | continue |
| 6950 | } |
| 6951 | |
| 6952 | // TODO(davidben): Support ECDSA in SSL 3.0 in Go for testing |
| 6953 | // or remove it in C. |
| 6954 | if ver.version == VersionSSL30 && alg.cert != testCertRSA { |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6955 | continue |
| 6956 | } |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 6957 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6958 | var shouldSignFail, shouldVerifyFail bool |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6959 | // ecdsa_sha1 does not exist in TLS 1.3. |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6960 | if ver.version >= VersionTLS13 && alg.id == signatureECDSAWithSHA1 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6961 | shouldSignFail = true |
| 6962 | shouldVerifyFail = true |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6963 | } |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6964 | // RSA-PKCS1 does not exist in TLS 1.3. |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 6965 | if ver.version >= VersionTLS13 && hasComponent(alg.name, "PKCS1") { |
| 6966 | shouldSignFail = true |
| 6967 | shouldVerifyFail = true |
| 6968 | } |
| 6969 | // SHA-224 has been removed from TLS 1.3 and, in 1.3, |
| 6970 | // the curve has to match the hash size. |
| 6971 | if ver.version >= VersionTLS13 && alg.cert == testCertECDSAP224 { |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6972 | shouldSignFail = true |
| 6973 | shouldVerifyFail = true |
| 6974 | } |
| 6975 | |
| 6976 | // BoringSSL will sign SHA-1 and SHA-512 with ECDSA but not accept them. |
| 6977 | if alg.id == signatureECDSAWithSHA1 || alg.id == signatureECDSAWithP521AndSHA512 { |
| 6978 | shouldVerifyFail = true |
Steven Valdez | 54ed58e | 2016-08-18 14:03:49 -0400 | [diff] [blame] | 6979 | } |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6980 | |
| 6981 | var signError, verifyError string |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6982 | if shouldSignFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6983 | signError = ":NO_COMMON_SIGNATURE_ALGORITHMS:" |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 6984 | } |
| 6985 | if shouldVerifyFail { |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 6986 | verifyError = ":WRONG_SIGNATURE_TYPE:" |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6987 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 6988 | |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 6989 | suffix := "-" + alg.name + "-" + ver.name |
David Benjamin | 6e80765 | 2015-11-02 12:02:20 -0500 | [diff] [blame] | 6990 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6991 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 6992 | name: "ClientAuth-Sign" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 6993 | config: Config{ |
| 6994 | MaxVersion: ver.version, |
| 6995 | ClientAuth: RequireAnyClientCert, |
| 6996 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 6997 | fakeSigAlg1, |
| 6998 | alg.id, |
| 6999 | fakeSigAlg2, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7000 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7001 | }, |
| 7002 | flags: []string{ |
| 7003 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7004 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7005 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7006 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7007 | }, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7008 | shouldFail: shouldSignFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7009 | expectedError: signError, |
| 7010 | expectedPeerSignatureAlgorithm: alg.id, |
| 7011 | }) |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7012 | |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7013 | testCases = append(testCases, testCase{ |
| 7014 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7015 | name: "ClientAuth-Verify" + suffix, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7016 | config: Config{ |
| 7017 | MaxVersion: ver.version, |
| 7018 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7019 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7020 | alg.id, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7021 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7022 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7023 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7024 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7025 | // Some signature algorithms may not be advertised. |
| 7026 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7027 | }, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7028 | }, |
| 7029 | flags: []string{ |
| 7030 | "-require-any-client-certificate", |
| 7031 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7032 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7033 | "-enable-ed25519", |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7034 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7035 | // Resume the session to assert the peer signature |
| 7036 | // algorithm is reported on both handshakes. |
| 7037 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7038 | shouldFail: shouldVerifyFail, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7039 | expectedError: verifyError, |
| 7040 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7041 | |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7042 | // No signing cipher for SSL 3.0. |
David Benjamin | 96bc12a | 2017-04-14 16:48:08 -0400 | [diff] [blame] | 7043 | if ver.version > VersionSSL30 { |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7044 | testCases = append(testCases, testCase{ |
| 7045 | testType: serverTest, |
| 7046 | name: "ServerAuth-Sign" + suffix, |
| 7047 | config: Config{ |
| 7048 | MaxVersion: ver.version, |
| 7049 | CipherSuites: signingCiphers, |
| 7050 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7051 | fakeSigAlg1, |
| 7052 | alg.id, |
| 7053 | fakeSigAlg2, |
| 7054 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7055 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7056 | flags: []string{ |
| 7057 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7058 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7059 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7060 | "-enable-ed25519", |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 7061 | }, |
| 7062 | shouldFail: shouldSignFail, |
| 7063 | expectedError: signError, |
| 7064 | expectedPeerSignatureAlgorithm: alg.id, |
| 7065 | }) |
| 7066 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7067 | |
| 7068 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7069 | name: "ServerAuth-Verify" + suffix, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7070 | config: Config{ |
| 7071 | MaxVersion: ver.version, |
| 7072 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7073 | CipherSuites: signingCiphers, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7074 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7075 | alg.id, |
| 7076 | }, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7077 | Bugs: ProtocolBugs{ |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7078 | SkipECDSACurveCheck: shouldVerifyFail, |
| 7079 | IgnoreSignatureVersionChecks: shouldVerifyFail, |
| 7080 | // Some signature algorithms may not be advertised. |
| 7081 | IgnorePeerSignatureAlgorithmPreferences: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7082 | }, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7083 | }, |
| 7084 | flags: []string{ |
| 7085 | "-expect-peer-signature-algorithm", strconv.Itoa(int(alg.id)), |
| 7086 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7087 | "-enable-ed25519", |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7088 | }, |
David Benjamin | f1050fd | 2016-12-13 20:05:36 -0500 | [diff] [blame] | 7089 | // Resume the session to assert the peer signature |
| 7090 | // algorithm is reported on both handshakes. |
| 7091 | resumeSession: !shouldVerifyFail, |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7092 | shouldFail: shouldVerifyFail, |
Steven Valdez | eff1e8d | 2016-07-06 14:24:47 -0400 | [diff] [blame] | 7093 | expectedError: verifyError, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7094 | }) |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7095 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7096 | if !shouldVerifyFail { |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7097 | testCases = append(testCases, testCase{ |
| 7098 | testType: serverTest, |
| 7099 | name: "ClientAuth-InvalidSignature" + suffix, |
| 7100 | config: Config{ |
| 7101 | MaxVersion: ver.version, |
| 7102 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7103 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7104 | alg.id, |
| 7105 | }, |
| 7106 | Bugs: ProtocolBugs{ |
| 7107 | InvalidSignature: true, |
| 7108 | }, |
| 7109 | }, |
| 7110 | flags: []string{ |
| 7111 | "-require-any-client-certificate", |
| 7112 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7113 | "-enable-ed25519", |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7114 | }, |
| 7115 | shouldFail: true, |
| 7116 | expectedError: ":BAD_SIGNATURE:", |
| 7117 | }) |
| 7118 | |
| 7119 | testCases = append(testCases, testCase{ |
| 7120 | name: "ServerAuth-InvalidSignature" + suffix, |
| 7121 | config: Config{ |
| 7122 | MaxVersion: ver.version, |
| 7123 | Certificates: []Certificate{getRunnerCertificate(alg.cert)}, |
| 7124 | CipherSuites: signingCiphers, |
| 7125 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7126 | alg.id, |
| 7127 | }, |
| 7128 | Bugs: ProtocolBugs{ |
| 7129 | InvalidSignature: true, |
| 7130 | }, |
| 7131 | }, |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7132 | flags: []string{ |
| 7133 | "-enable-all-curves", |
| 7134 | "-enable-ed25519", |
| 7135 | }, |
David Benjamin | 5208fd4 | 2016-07-13 21:43:25 -0400 | [diff] [blame] | 7136 | shouldFail: true, |
| 7137 | expectedError: ":BAD_SIGNATURE:", |
| 7138 | }) |
| 7139 | } |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7140 | |
David Benjamin | 3ef7697 | 2016-10-17 17:59:54 -0400 | [diff] [blame] | 7141 | if ver.version >= VersionTLS12 && !shouldSignFail { |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7142 | testCases = append(testCases, testCase{ |
| 7143 | name: "ClientAuth-Sign-Negotiate" + suffix, |
| 7144 | config: Config{ |
| 7145 | MaxVersion: ver.version, |
| 7146 | ClientAuth: RequireAnyClientCert, |
| 7147 | VerifySignatureAlgorithms: allAlgorithms, |
| 7148 | }, |
| 7149 | flags: []string{ |
| 7150 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7151 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7152 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7153 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7154 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7155 | }, |
| 7156 | expectedPeerSignatureAlgorithm: alg.id, |
| 7157 | }) |
| 7158 | |
| 7159 | testCases = append(testCases, testCase{ |
| 7160 | testType: serverTest, |
| 7161 | name: "ServerAuth-Sign-Negotiate" + suffix, |
| 7162 | config: Config{ |
| 7163 | MaxVersion: ver.version, |
| 7164 | CipherSuites: signingCiphers, |
| 7165 | VerifySignatureAlgorithms: allAlgorithms, |
| 7166 | }, |
| 7167 | flags: []string{ |
| 7168 | "-cert-file", path.Join(*resourceDir, getShimCertificate(alg.cert)), |
| 7169 | "-key-file", path.Join(*resourceDir, getShimKey(alg.cert)), |
| 7170 | "-enable-all-curves", |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7171 | "-enable-ed25519", |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7172 | "-signing-prefs", strconv.Itoa(int(alg.id)), |
| 7173 | }, |
| 7174 | expectedPeerSignatureAlgorithm: alg.id, |
| 7175 | }) |
| 7176 | } |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7177 | } |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7178 | } |
| 7179 | |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7180 | // Test that algorithm selection takes the key type into account. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7181 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7182 | name: "ClientAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7183 | config: Config{ |
| 7184 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7185 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7186 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7187 | signatureECDSAWithP521AndSHA512, |
| 7188 | signatureRSAPKCS1WithSHA384, |
| 7189 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7190 | }, |
| 7191 | }, |
| 7192 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7193 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7194 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7195 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7196 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7197 | }) |
| 7198 | |
| 7199 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7200 | name: "ClientAuth-SignatureType-TLS13", |
| 7201 | config: Config{ |
| 7202 | ClientAuth: RequireAnyClientCert, |
| 7203 | MaxVersion: VersionTLS13, |
| 7204 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7205 | signatureECDSAWithP521AndSHA512, |
| 7206 | signatureRSAPKCS1WithSHA384, |
| 7207 | signatureRSAPSSWithSHA384, |
| 7208 | signatureECDSAWithSHA1, |
| 7209 | }, |
| 7210 | }, |
| 7211 | flags: []string{ |
| 7212 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7213 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7214 | }, |
| 7215 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7216 | }) |
| 7217 | |
| 7218 | testCases = append(testCases, testCase{ |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7219 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7220 | name: "ServerAuth-SignatureType", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7221 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7222 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7223 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7224 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7225 | signatureECDSAWithP521AndSHA512, |
| 7226 | signatureRSAPKCS1WithSHA384, |
| 7227 | signatureECDSAWithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7228 | }, |
| 7229 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7230 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA384, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7231 | }) |
| 7232 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7233 | testCases = append(testCases, testCase{ |
| 7234 | testType: serverTest, |
| 7235 | name: "ServerAuth-SignatureType-TLS13", |
| 7236 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7237 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7238 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7239 | signatureECDSAWithP521AndSHA512, |
| 7240 | signatureRSAPKCS1WithSHA384, |
| 7241 | signatureRSAPSSWithSHA384, |
| 7242 | signatureECDSAWithSHA1, |
| 7243 | }, |
| 7244 | }, |
| 7245 | expectedPeerSignatureAlgorithm: signatureRSAPSSWithSHA384, |
| 7246 | }) |
| 7247 | |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7248 | // Test that signature verification takes the key type into account. |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7249 | testCases = append(testCases, testCase{ |
| 7250 | testType: serverTest, |
| 7251 | name: "Verify-ClientAuth-SignatureType", |
| 7252 | config: Config{ |
| 7253 | MaxVersion: VersionTLS12, |
| 7254 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7255 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7256 | signatureRSAPKCS1WithSHA256, |
| 7257 | }, |
| 7258 | Bugs: ProtocolBugs{ |
| 7259 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7260 | }, |
| 7261 | }, |
| 7262 | flags: []string{ |
| 7263 | "-require-any-client-certificate", |
| 7264 | }, |
| 7265 | shouldFail: true, |
| 7266 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7267 | }) |
| 7268 | |
| 7269 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7270 | testType: serverTest, |
| 7271 | name: "Verify-ClientAuth-SignatureType-TLS13", |
| 7272 | config: Config{ |
| 7273 | MaxVersion: VersionTLS13, |
| 7274 | Certificates: []Certificate{rsaCertificate}, |
| 7275 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7276 | signatureRSAPSSWithSHA256, |
| 7277 | }, |
| 7278 | Bugs: ProtocolBugs{ |
| 7279 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7280 | }, |
| 7281 | }, |
| 7282 | flags: []string{ |
| 7283 | "-require-any-client-certificate", |
| 7284 | }, |
| 7285 | shouldFail: true, |
| 7286 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7287 | }) |
| 7288 | |
| 7289 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7290 | name: "Verify-ServerAuth-SignatureType", |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7291 | config: Config{ |
| 7292 | MaxVersion: VersionTLS12, |
| 7293 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7294 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | a95e9f3 | 2016-07-08 16:28:04 -0700 | [diff] [blame] | 7295 | signatureRSAPKCS1WithSHA256, |
| 7296 | }, |
| 7297 | Bugs: ProtocolBugs{ |
| 7298 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7299 | }, |
| 7300 | }, |
| 7301 | shouldFail: true, |
| 7302 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7303 | }) |
| 7304 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7305 | testCases = append(testCases, testCase{ |
| 7306 | name: "Verify-ServerAuth-SignatureType-TLS13", |
| 7307 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7308 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7309 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7310 | signatureRSAPSSWithSHA256, |
| 7311 | }, |
| 7312 | Bugs: ProtocolBugs{ |
| 7313 | SendSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7314 | }, |
| 7315 | }, |
| 7316 | shouldFail: true, |
| 7317 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7318 | }) |
| 7319 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7320 | // Test that, if the list is missing, the peer falls back to SHA-1 in |
| 7321 | // TLS 1.2, but not TLS 1.3. |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7322 | testCases = append(testCases, testCase{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7323 | name: "ClientAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7324 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7325 | MaxVersion: VersionTLS12, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7326 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7327 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7328 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7329 | }, |
| 7330 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7331 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7332 | }, |
| 7333 | }, |
| 7334 | flags: []string{ |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 7335 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7336 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7337 | }, |
| 7338 | }) |
| 7339 | |
| 7340 | testCases = append(testCases, testCase{ |
| 7341 | testType: serverTest, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7342 | name: "ServerAuth-SHA1-Fallback-RSA", |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7343 | config: Config{ |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7344 | MaxVersion: VersionTLS12, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7345 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7346 | signatureRSAPKCS1WithSHA1, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7347 | }, |
| 7348 | Bugs: ProtocolBugs{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7349 | NoSignatureAlgorithms: true, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7350 | }, |
| 7351 | }, |
David Benjamin | ee32bea | 2016-08-17 13:36:44 -0400 | [diff] [blame] | 7352 | flags: []string{ |
| 7353 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7354 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7355 | }, |
| 7356 | }) |
| 7357 | |
| 7358 | testCases = append(testCases, testCase{ |
| 7359 | name: "ClientAuth-SHA1-Fallback-ECDSA", |
| 7360 | config: Config{ |
| 7361 | MaxVersion: VersionTLS12, |
| 7362 | ClientAuth: RequireAnyClientCert, |
| 7363 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7364 | signatureECDSAWithSHA1, |
| 7365 | }, |
| 7366 | Bugs: ProtocolBugs{ |
| 7367 | NoSignatureAlgorithms: true, |
| 7368 | }, |
| 7369 | }, |
| 7370 | flags: []string{ |
| 7371 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7372 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7373 | }, |
| 7374 | }) |
| 7375 | |
| 7376 | testCases = append(testCases, testCase{ |
| 7377 | testType: serverTest, |
| 7378 | name: "ServerAuth-SHA1-Fallback-ECDSA", |
| 7379 | config: Config{ |
| 7380 | MaxVersion: VersionTLS12, |
| 7381 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7382 | signatureECDSAWithSHA1, |
| 7383 | }, |
| 7384 | Bugs: ProtocolBugs{ |
| 7385 | NoSignatureAlgorithms: true, |
| 7386 | }, |
| 7387 | }, |
| 7388 | flags: []string{ |
| 7389 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7390 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7391 | }, |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7392 | }) |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7393 | |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7394 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7395 | name: "ClientAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7396 | config: Config{ |
| 7397 | MaxVersion: VersionTLS13, |
| 7398 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7399 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7400 | signatureRSAPKCS1WithSHA1, |
| 7401 | }, |
| 7402 | Bugs: ProtocolBugs{ |
| 7403 | NoSignatureAlgorithms: true, |
| 7404 | }, |
| 7405 | }, |
| 7406 | flags: []string{ |
| 7407 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7408 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7409 | }, |
David Benjamin | 4890165 | 2016-08-01 12:12:47 -0400 | [diff] [blame] | 7410 | shouldFail: true, |
| 7411 | // An empty CertificateRequest signature algorithm list is a |
| 7412 | // syntax error in TLS 1.3. |
| 7413 | expectedError: ":DECODE_ERROR:", |
| 7414 | expectedLocalError: "remote error: error decoding message", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7415 | }) |
| 7416 | |
| 7417 | testCases = append(testCases, testCase{ |
| 7418 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7419 | name: "ServerAuth-NoFallback-TLS13", |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7420 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7421 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7422 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 51dd7d6 | 2016-07-08 16:07:01 -0700 | [diff] [blame] | 7423 | signatureRSAPKCS1WithSHA1, |
| 7424 | }, |
| 7425 | Bugs: ProtocolBugs{ |
| 7426 | NoSignatureAlgorithms: true, |
| 7427 | }, |
| 7428 | }, |
| 7429 | shouldFail: true, |
| 7430 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7431 | }) |
| 7432 | |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7433 | // Test that hash preferences are enforced. BoringSSL does not implement |
| 7434 | // MD5 signatures. |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7435 | testCases = append(testCases, testCase{ |
| 7436 | testType: serverTest, |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7437 | name: "ClientAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7438 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7439 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7440 | Certificates: []Certificate{rsaCertificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7441 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7442 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7443 | }, |
| 7444 | Bugs: ProtocolBugs{ |
| 7445 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7446 | }, |
| 7447 | }, |
| 7448 | flags: []string{"-require-any-client-certificate"}, |
| 7449 | shouldFail: true, |
| 7450 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7451 | }) |
| 7452 | |
| 7453 | testCases = append(testCases, testCase{ |
David Benjamin | bbfff7c | 2016-07-13 21:08:33 -0400 | [diff] [blame] | 7454 | name: "ServerAuth-Enforced", |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7455 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7456 | MaxVersion: VersionTLS12, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7457 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7458 | SignSignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7459 | signatureRSAPKCS1WithMD5, |
David Benjamin | 72dc783 | 2015-03-16 17:49:43 -0400 | [diff] [blame] | 7460 | }, |
| 7461 | Bugs: ProtocolBugs{ |
| 7462 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7463 | }, |
| 7464 | }, |
| 7465 | shouldFail: true, |
| 7466 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7467 | }) |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7468 | testCases = append(testCases, testCase{ |
| 7469 | testType: serverTest, |
| 7470 | name: "ClientAuth-Enforced-TLS13", |
| 7471 | config: Config{ |
| 7472 | MaxVersion: VersionTLS13, |
| 7473 | Certificates: []Certificate{rsaCertificate}, |
| 7474 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7475 | signatureRSAPKCS1WithMD5, |
| 7476 | }, |
| 7477 | Bugs: ProtocolBugs{ |
| 7478 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7479 | IgnoreSignatureVersionChecks: true, |
| 7480 | }, |
| 7481 | }, |
| 7482 | flags: []string{"-require-any-client-certificate"}, |
| 7483 | shouldFail: true, |
| 7484 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7485 | }) |
| 7486 | |
| 7487 | testCases = append(testCases, testCase{ |
| 7488 | name: "ServerAuth-Enforced-TLS13", |
| 7489 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7490 | MaxVersion: VersionTLS13, |
David Benjamin | b62d287 | 2016-07-18 14:55:02 +0200 | [diff] [blame] | 7491 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7492 | signatureRSAPKCS1WithMD5, |
| 7493 | }, |
| 7494 | Bugs: ProtocolBugs{ |
| 7495 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7496 | IgnoreSignatureVersionChecks: true, |
| 7497 | }, |
| 7498 | }, |
| 7499 | shouldFail: true, |
| 7500 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7501 | }) |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7502 | |
| 7503 | // Test that the agreed upon digest respects the client preferences and |
| 7504 | // the server digests. |
| 7505 | testCases = append(testCases, testCase{ |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7506 | name: "NoCommonAlgorithms-Digests", |
| 7507 | config: Config{ |
| 7508 | MaxVersion: VersionTLS12, |
| 7509 | ClientAuth: RequireAnyClientCert, |
| 7510 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7511 | signatureRSAPKCS1WithSHA512, |
| 7512 | signatureRSAPKCS1WithSHA1, |
| 7513 | }, |
| 7514 | }, |
| 7515 | flags: []string{ |
| 7516 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7517 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7518 | "-digest-prefs", "SHA256", |
| 7519 | }, |
| 7520 | shouldFail: true, |
| 7521 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7522 | }) |
| 7523 | testCases = append(testCases, testCase{ |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7524 | name: "NoCommonAlgorithms", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7525 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7526 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7527 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7528 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7529 | signatureRSAPKCS1WithSHA512, |
| 7530 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7531 | }, |
| 7532 | }, |
| 7533 | flags: []string{ |
| 7534 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7535 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7536 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7537 | }, |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7538 | shouldFail: true, |
| 7539 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7540 | }) |
| 7541 | testCases = append(testCases, testCase{ |
| 7542 | name: "NoCommonAlgorithms-TLS13", |
| 7543 | config: Config{ |
| 7544 | MaxVersion: VersionTLS13, |
| 7545 | ClientAuth: RequireAnyClientCert, |
| 7546 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7547 | signatureRSAPSSWithSHA512, |
| 7548 | signatureRSAPSSWithSHA384, |
| 7549 | }, |
| 7550 | }, |
| 7551 | flags: []string{ |
| 7552 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7553 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7554 | "-signing-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA256)), |
| 7555 | }, |
David Benjamin | ea9a0d5 | 2016-07-08 15:52:59 -0700 | [diff] [blame] | 7556 | shouldFail: true, |
| 7557 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7558 | }) |
| 7559 | testCases = append(testCases, testCase{ |
| 7560 | name: "Agree-Digest-SHA256", |
| 7561 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7562 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7563 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7564 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7565 | signatureRSAPKCS1WithSHA1, |
| 7566 | signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7567 | }, |
| 7568 | }, |
| 7569 | flags: []string{ |
| 7570 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7571 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7572 | "-digest-prefs", "SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7573 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7574 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7575 | }) |
| 7576 | testCases = append(testCases, testCase{ |
| 7577 | name: "Agree-Digest-SHA1", |
| 7578 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7579 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7580 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7581 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7582 | signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7583 | }, |
| 7584 | }, |
| 7585 | flags: []string{ |
| 7586 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7587 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7588 | "-digest-prefs", "SHA512,SHA256,SHA1", |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7589 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7590 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7591 | }) |
| 7592 | testCases = append(testCases, testCase{ |
| 7593 | name: "Agree-Digest-Default", |
| 7594 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7595 | MaxVersion: VersionTLS12, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7596 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7597 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7598 | signatureRSAPKCS1WithSHA256, |
| 7599 | signatureECDSAWithP256AndSHA256, |
| 7600 | signatureRSAPKCS1WithSHA1, |
| 7601 | signatureECDSAWithSHA1, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7602 | }, |
| 7603 | }, |
| 7604 | flags: []string{ |
| 7605 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7606 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7607 | }, |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 7608 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
Steven Valdez | 0d62f26 | 2015-09-04 12:41:04 -0400 | [diff] [blame] | 7609 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7610 | |
David Benjamin | ca3d545 | 2016-07-14 12:51:01 -0400 | [diff] [blame] | 7611 | // Test that the signing preference list may include extra algorithms |
| 7612 | // without negotiation problems. |
| 7613 | testCases = append(testCases, testCase{ |
| 7614 | testType: serverTest, |
| 7615 | name: "FilterExtraAlgorithms", |
| 7616 | config: Config{ |
| 7617 | MaxVersion: VersionTLS12, |
| 7618 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7619 | signatureRSAPKCS1WithSHA256, |
| 7620 | }, |
| 7621 | }, |
| 7622 | flags: []string{ |
| 7623 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 7624 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 7625 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg1)), |
| 7626 | "-signing-prefs", strconv.Itoa(int(signatureECDSAWithP256AndSHA256)), |
| 7627 | "-signing-prefs", strconv.Itoa(int(signatureRSAPKCS1WithSHA256)), |
| 7628 | "-signing-prefs", strconv.Itoa(int(fakeSigAlg2)), |
| 7629 | }, |
| 7630 | expectedPeerSignatureAlgorithm: signatureRSAPKCS1WithSHA256, |
| 7631 | }) |
| 7632 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7633 | // In TLS 1.2 and below, ECDSA uses the curve list rather than the |
| 7634 | // signature algorithms. |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7635 | testCases = append(testCases, testCase{ |
| 7636 | name: "CheckLeafCurve", |
| 7637 | config: Config{ |
| 7638 | MaxVersion: VersionTLS12, |
| 7639 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 7640 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7641 | }, |
| 7642 | flags: []string{"-p384-only"}, |
| 7643 | shouldFail: true, |
| 7644 | expectedError: ":BAD_ECC_CERT:", |
| 7645 | }) |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7646 | |
| 7647 | // In TLS 1.3, ECDSA does not use the ECDHE curve list. |
| 7648 | testCases = append(testCases, testCase{ |
| 7649 | name: "CheckLeafCurve-TLS13", |
| 7650 | config: Config{ |
| 7651 | MaxVersion: VersionTLS13, |
David Benjamin | 75ea5bb | 2016-07-08 17:43:29 -0700 | [diff] [blame] | 7652 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 7653 | }, |
| 7654 | flags: []string{"-p384-only"}, |
| 7655 | }) |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7656 | |
| 7657 | // In TLS 1.2, the ECDSA curve is not in the signature algorithm. |
| 7658 | testCases = append(testCases, testCase{ |
| 7659 | name: "ECDSACurveMismatch-Verify-TLS12", |
| 7660 | config: Config{ |
| 7661 | MaxVersion: VersionTLS12, |
| 7662 | CipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256}, |
| 7663 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7664 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7665 | signatureECDSAWithP384AndSHA384, |
| 7666 | }, |
| 7667 | }, |
| 7668 | }) |
| 7669 | |
| 7670 | // In TLS 1.3, the ECDSA curve comes from the signature algorithm. |
| 7671 | testCases = append(testCases, testCase{ |
| 7672 | name: "ECDSACurveMismatch-Verify-TLS13", |
| 7673 | config: Config{ |
| 7674 | MaxVersion: VersionTLS13, |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7675 | Certificates: []Certificate{ecdsaP256Certificate}, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7676 | SignSignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7677 | signatureECDSAWithP384AndSHA384, |
| 7678 | }, |
| 7679 | Bugs: ProtocolBugs{ |
| 7680 | SkipECDSACurveCheck: true, |
| 7681 | }, |
| 7682 | }, |
| 7683 | shouldFail: true, |
| 7684 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7685 | }) |
| 7686 | |
| 7687 | // Signature algorithm selection in TLS 1.3 should take the curve into |
| 7688 | // account. |
| 7689 | testCases = append(testCases, testCase{ |
| 7690 | testType: serverTest, |
| 7691 | name: "ECDSACurveMismatch-Sign-TLS13", |
| 7692 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 7693 | MaxVersion: VersionTLS13, |
David Benjamin | 7a41d37 | 2016-07-09 11:21:54 -0700 | [diff] [blame] | 7694 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
David Benjamin | 1fb125c | 2016-07-08 18:52:12 -0700 | [diff] [blame] | 7695 | signatureECDSAWithP384AndSHA384, |
| 7696 | signatureECDSAWithP256AndSHA256, |
| 7697 | }, |
| 7698 | }, |
| 7699 | flags: []string{ |
| 7700 | "-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 7701 | "-key-file", path.Join(*resourceDir, ecdsaP256KeyFile), |
| 7702 | }, |
| 7703 | expectedPeerSignatureAlgorithm: signatureECDSAWithP256AndSHA256, |
| 7704 | }) |
David Benjamin | 7944a9f | 2016-07-12 22:27:01 -0400 | [diff] [blame] | 7705 | |
| 7706 | // RSASSA-PSS with SHA-512 is too large for 1024-bit RSA. Test that the |
| 7707 | // server does not attempt to sign in that case. |
| 7708 | testCases = append(testCases, testCase{ |
| 7709 | testType: serverTest, |
| 7710 | name: "RSA-PSS-Large", |
| 7711 | config: Config{ |
| 7712 | MaxVersion: VersionTLS13, |
| 7713 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7714 | signatureRSAPSSWithSHA512, |
| 7715 | }, |
| 7716 | }, |
| 7717 | flags: []string{ |
| 7718 | "-cert-file", path.Join(*resourceDir, rsa1024CertificateFile), |
| 7719 | "-key-file", path.Join(*resourceDir, rsa1024KeyFile), |
| 7720 | }, |
| 7721 | shouldFail: true, |
| 7722 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7723 | }) |
David Benjamin | 57e929f | 2016-08-30 00:30:38 -0400 | [diff] [blame] | 7724 | |
| 7725 | // Test that RSA-PSS is enabled by default for TLS 1.2. |
| 7726 | testCases = append(testCases, testCase{ |
| 7727 | testType: clientTest, |
| 7728 | name: "RSA-PSS-Default-Verify", |
| 7729 | config: Config{ |
| 7730 | MaxVersion: VersionTLS12, |
| 7731 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7732 | signatureRSAPSSWithSHA256, |
| 7733 | }, |
| 7734 | }, |
| 7735 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7736 | }) |
| 7737 | |
| 7738 | testCases = append(testCases, testCase{ |
| 7739 | testType: serverTest, |
| 7740 | name: "RSA-PSS-Default-Sign", |
| 7741 | config: Config{ |
| 7742 | MaxVersion: VersionTLS12, |
| 7743 | VerifySignatureAlgorithms: []signatureAlgorithm{ |
| 7744 | signatureRSAPSSWithSHA256, |
| 7745 | }, |
| 7746 | }, |
| 7747 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 7748 | }) |
David Benjamin | 6952211 | 2017-03-28 15:38:29 -0500 | [diff] [blame] | 7749 | |
| 7750 | // TLS 1.1 and below has no way to advertise support for or negotiate |
| 7751 | // Ed25519's signature algorithm. |
| 7752 | testCases = append(testCases, testCase{ |
| 7753 | testType: clientTest, |
| 7754 | name: "NoEd25519-TLS11-ServerAuth-Verify", |
| 7755 | config: Config{ |
| 7756 | MaxVersion: VersionTLS11, |
| 7757 | Certificates: []Certificate{ed25519Certificate}, |
| 7758 | Bugs: ProtocolBugs{ |
| 7759 | // Sign with Ed25519 even though it is TLS 1.1. |
| 7760 | UseLegacySigningAlgorithm: signatureEd25519, |
| 7761 | }, |
| 7762 | }, |
| 7763 | flags: []string{"-enable-ed25519"}, |
| 7764 | shouldFail: true, |
| 7765 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 7766 | }) |
| 7767 | testCases = append(testCases, testCase{ |
| 7768 | testType: serverTest, |
| 7769 | name: "NoEd25519-TLS11-ServerAuth-Sign", |
| 7770 | config: Config{ |
| 7771 | MaxVersion: VersionTLS11, |
| 7772 | }, |
| 7773 | flags: []string{ |
| 7774 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 7775 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 7776 | }, |
| 7777 | shouldFail: true, |
| 7778 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7779 | }) |
| 7780 | testCases = append(testCases, testCase{ |
| 7781 | testType: serverTest, |
| 7782 | name: "NoEd25519-TLS11-ClientAuth-Verify", |
| 7783 | config: Config{ |
| 7784 | MaxVersion: VersionTLS11, |
| 7785 | Certificates: []Certificate{ed25519Certificate}, |
| 7786 | Bugs: ProtocolBugs{ |
| 7787 | // Sign with Ed25519 even though it is TLS 1.1. |
| 7788 | UseLegacySigningAlgorithm: signatureEd25519, |
| 7789 | }, |
| 7790 | }, |
| 7791 | flags: []string{ |
| 7792 | "-enable-ed25519", |
| 7793 | "-require-any-client-certificate", |
| 7794 | }, |
| 7795 | shouldFail: true, |
| 7796 | expectedError: ":PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE:", |
| 7797 | }) |
| 7798 | testCases = append(testCases, testCase{ |
| 7799 | testType: clientTest, |
| 7800 | name: "NoEd25519-TLS11-ClientAuth-Sign", |
| 7801 | config: Config{ |
| 7802 | MaxVersion: VersionTLS11, |
| 7803 | ClientAuth: RequireAnyClientCert, |
| 7804 | }, |
| 7805 | flags: []string{ |
| 7806 | "-cert-file", path.Join(*resourceDir, ed25519CertificateFile), |
| 7807 | "-key-file", path.Join(*resourceDir, ed25519KeyFile), |
| 7808 | }, |
| 7809 | shouldFail: true, |
| 7810 | expectedError: ":NO_COMMON_SIGNATURE_ALGORITHMS:", |
| 7811 | }) |
| 7812 | |
| 7813 | // Test Ed25519 is not advertised by default. |
| 7814 | testCases = append(testCases, testCase{ |
| 7815 | testType: clientTest, |
| 7816 | name: "Ed25519DefaultDisable-NoAdvertise", |
| 7817 | config: Config{ |
| 7818 | Certificates: []Certificate{ed25519Certificate}, |
| 7819 | }, |
| 7820 | shouldFail: true, |
| 7821 | expectedLocalError: "tls: no common signature algorithms", |
| 7822 | }) |
| 7823 | |
| 7824 | // Test Ed25519, when disabled, is not accepted if the peer ignores our |
| 7825 | // preferences. |
| 7826 | testCases = append(testCases, testCase{ |
| 7827 | testType: clientTest, |
| 7828 | name: "Ed25519DefaultDisable-NoAccept", |
| 7829 | config: Config{ |
| 7830 | Certificates: []Certificate{ed25519Certificate}, |
| 7831 | Bugs: ProtocolBugs{ |
| 7832 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7833 | }, |
| 7834 | }, |
| 7835 | shouldFail: true, |
| 7836 | expectedLocalError: "remote error: illegal parameter", |
| 7837 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7838 | }) |
David Benjamin | 71c21b4 | 2017-04-14 17:05:40 -0400 | [diff] [blame] | 7839 | |
| 7840 | // Test that configuring verify preferences changes what the client |
| 7841 | // advertises. |
| 7842 | testCases = append(testCases, testCase{ |
| 7843 | name: "VerifyPreferences-Advertised", |
| 7844 | config: Config{ |
| 7845 | Certificates: []Certificate{rsaCertificate}, |
| 7846 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7847 | signatureRSAPSSWithSHA256, |
| 7848 | signatureRSAPSSWithSHA384, |
| 7849 | signatureRSAPSSWithSHA512, |
| 7850 | }, |
| 7851 | }, |
| 7852 | flags: []string{ |
| 7853 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 7854 | "-expect-peer-signature-algorithm", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 7855 | }, |
| 7856 | }) |
| 7857 | |
| 7858 | // Test that the client advertises a set which the runner can find |
| 7859 | // nothing in common with. |
| 7860 | testCases = append(testCases, testCase{ |
| 7861 | name: "VerifyPreferences-NoCommonAlgorithms", |
| 7862 | config: Config{ |
| 7863 | Certificates: []Certificate{rsaCertificate}, |
| 7864 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7865 | signatureRSAPSSWithSHA256, |
| 7866 | signatureRSAPSSWithSHA512, |
| 7867 | }, |
| 7868 | }, |
| 7869 | flags: []string{ |
| 7870 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 7871 | }, |
| 7872 | shouldFail: true, |
| 7873 | expectedLocalError: "tls: no common signature algorithms", |
| 7874 | }) |
| 7875 | |
| 7876 | // Test that the client enforces its preferences when configured. |
| 7877 | testCases = append(testCases, testCase{ |
| 7878 | name: "VerifyPreferences-Enforced", |
| 7879 | config: Config{ |
| 7880 | Certificates: []Certificate{rsaCertificate}, |
| 7881 | SignSignatureAlgorithms: []signatureAlgorithm{ |
| 7882 | signatureRSAPSSWithSHA256, |
| 7883 | signatureRSAPSSWithSHA512, |
| 7884 | }, |
| 7885 | Bugs: ProtocolBugs{ |
| 7886 | IgnorePeerSignatureAlgorithmPreferences: true, |
| 7887 | }, |
| 7888 | }, |
| 7889 | flags: []string{ |
| 7890 | "-verify-prefs", strconv.Itoa(int(signatureRSAPSSWithSHA384)), |
| 7891 | }, |
| 7892 | shouldFail: true, |
| 7893 | expectedLocalError: "remote error: illegal parameter", |
| 7894 | expectedError: ":WRONG_SIGNATURE_TYPE:", |
| 7895 | }) |
| 7896 | |
| 7897 | // Test that explicitly configuring Ed25519 is as good as changing the |
| 7898 | // boolean toggle. |
| 7899 | testCases = append(testCases, testCase{ |
| 7900 | name: "VerifyPreferences-Ed25519", |
| 7901 | config: Config{ |
| 7902 | Certificates: []Certificate{ed25519Certificate}, |
| 7903 | }, |
| 7904 | flags: []string{ |
| 7905 | "-verify-prefs", strconv.Itoa(int(signatureEd25519)), |
| 7906 | }, |
| 7907 | }) |
David Benjamin | 000800a | 2014-11-14 01:43:59 -0500 | [diff] [blame] | 7908 | } |
| 7909 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7910 | // timeouts is the retransmit schedule for BoringSSL. It doubles and |
| 7911 | // caps at 60 seconds. On the 13th timeout, it gives up. |
| 7912 | var timeouts = []time.Duration{ |
| 7913 | 1 * time.Second, |
| 7914 | 2 * time.Second, |
| 7915 | 4 * time.Second, |
| 7916 | 8 * time.Second, |
| 7917 | 16 * time.Second, |
| 7918 | 32 * time.Second, |
| 7919 | 60 * time.Second, |
| 7920 | 60 * time.Second, |
| 7921 | 60 * time.Second, |
| 7922 | 60 * time.Second, |
| 7923 | 60 * time.Second, |
| 7924 | 60 * time.Second, |
| 7925 | 60 * time.Second, |
| 7926 | } |
| 7927 | |
Taylor Brandstetter | 376a0fe | 2016-05-10 19:30:28 -0700 | [diff] [blame] | 7928 | // shortTimeouts is an alternate set of timeouts which would occur if the |
| 7929 | // initial timeout duration was set to 250ms. |
| 7930 | var shortTimeouts = []time.Duration{ |
| 7931 | 250 * time.Millisecond, |
| 7932 | 500 * time.Millisecond, |
| 7933 | 1 * time.Second, |
| 7934 | 2 * time.Second, |
| 7935 | 4 * time.Second, |
| 7936 | 8 * time.Second, |
| 7937 | 16 * time.Second, |
| 7938 | 32 * time.Second, |
| 7939 | 60 * time.Second, |
| 7940 | 60 * time.Second, |
| 7941 | 60 * time.Second, |
| 7942 | 60 * time.Second, |
| 7943 | 60 * time.Second, |
| 7944 | } |
| 7945 | |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7946 | func addDTLSRetransmitTests() { |
David Benjamin | 585d7a4 | 2016-06-02 14:58:00 -0400 | [diff] [blame] | 7947 | // These tests work by coordinating some behavior on both the shim and |
| 7948 | // the runner. |
| 7949 | // |
| 7950 | // TimeoutSchedule configures the runner to send a series of timeout |
| 7951 | // opcodes to the shim (see packetAdaptor) immediately before reading |
| 7952 | // each peer handshake flight N. The timeout opcode both simulates a |
| 7953 | // timeout in the shim and acts as a synchronization point to help the |
| 7954 | // runner bracket each handshake flight. |
| 7955 | // |
| 7956 | // We assume the shim does not read from the channel eagerly. It must |
| 7957 | // first wait until it has sent flight N and is ready to receive |
| 7958 | // handshake flight N+1. At this point, it will process the timeout |
| 7959 | // opcode. It must then immediately respond with a timeout ACK and act |
| 7960 | // as if the shim was idle for the specified amount of time. |
| 7961 | // |
| 7962 | // The runner then drops all packets received before the ACK and |
| 7963 | // continues waiting for flight N. This ordering results in one attempt |
| 7964 | // at sending flight N to be dropped. For the test to complete, the |
| 7965 | // shim must send flight N again, testing that the shim implements DTLS |
| 7966 | // retransmit on a timeout. |
| 7967 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 7968 | // TODO(davidben): Add DTLS 1.3 versions of these tests. There will |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7969 | // likely be more epochs to cross and the final message's retransmit may |
| 7970 | // be more complex. |
| 7971 | |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7972 | // Test that this is indeed the timeout schedule. Stress all |
| 7973 | // four patterns of handshake. |
| 7974 | for i := 1; i < len(timeouts); i++ { |
| 7975 | number := strconv.Itoa(i) |
| 7976 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7977 | protocol: dtls, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7978 | name: "DTLS-Retransmit-Client-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7979 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7980 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7981 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7982 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7983 | }, |
| 7984 | }, |
| 7985 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7986 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7987 | }) |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7988 | testCases = append(testCases, testCase{ |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7989 | protocol: dtls, |
| 7990 | testType: serverTest, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7991 | name: "DTLS-Retransmit-Server-" + number, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7992 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 7993 | MaxVersion: VersionTLS12, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7994 | Bugs: ProtocolBugs{ |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7995 | TimeoutSchedule: timeouts[:i], |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 7996 | }, |
| 7997 | }, |
| 7998 | resumeSession: true, |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 7999 | flags: []string{"-async"}, |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8000 | }) |
| 8001 | } |
David Benjamin | 11c8289 | 2017-02-23 20:40:31 -0500 | [diff] [blame] | 8002 | |
| 8003 | // Test that exceeding the timeout schedule hits a read |
| 8004 | // timeout. |
| 8005 | testCases = append(testCases, testCase{ |
| 8006 | protocol: dtls, |
| 8007 | name: "DTLS-Retransmit-Timeout", |
| 8008 | config: Config{ |
| 8009 | MaxVersion: VersionTLS12, |
| 8010 | Bugs: ProtocolBugs{ |
| 8011 | TimeoutSchedule: timeouts, |
| 8012 | }, |
| 8013 | }, |
| 8014 | resumeSession: true, |
| 8015 | flags: []string{"-async"}, |
| 8016 | shouldFail: true, |
| 8017 | expectedError: ":READ_TIMEOUT_EXPIRED:", |
| 8018 | }) |
| 8019 | |
| 8020 | // Test that timeout handling has a fudge factor, due to API |
| 8021 | // problems. |
| 8022 | testCases = append(testCases, testCase{ |
| 8023 | protocol: dtls, |
| 8024 | name: "DTLS-Retransmit-Fudge", |
| 8025 | config: Config{ |
| 8026 | MaxVersion: VersionTLS12, |
| 8027 | Bugs: ProtocolBugs{ |
| 8028 | TimeoutSchedule: []time.Duration{ |
| 8029 | timeouts[0] - 10*time.Millisecond, |
| 8030 | }, |
| 8031 | }, |
| 8032 | }, |
| 8033 | resumeSession: true, |
| 8034 | flags: []string{"-async"}, |
| 8035 | }) |
| 8036 | |
| 8037 | // Test that the final Finished retransmitting isn't |
| 8038 | // duplicated if the peer badly fragments everything. |
| 8039 | testCases = append(testCases, testCase{ |
| 8040 | testType: serverTest, |
| 8041 | protocol: dtls, |
| 8042 | name: "DTLS-Retransmit-Fragmented", |
| 8043 | config: Config{ |
| 8044 | MaxVersion: VersionTLS12, |
| 8045 | Bugs: ProtocolBugs{ |
| 8046 | TimeoutSchedule: []time.Duration{timeouts[0]}, |
| 8047 | MaxHandshakeRecordLength: 2, |
| 8048 | }, |
| 8049 | }, |
| 8050 | flags: []string{"-async"}, |
| 8051 | }) |
| 8052 | |
| 8053 | // Test the timeout schedule when a shorter initial timeout duration is set. |
| 8054 | testCases = append(testCases, testCase{ |
| 8055 | protocol: dtls, |
| 8056 | name: "DTLS-Retransmit-Short-Client", |
| 8057 | config: Config{ |
| 8058 | MaxVersion: VersionTLS12, |
| 8059 | Bugs: ProtocolBugs{ |
| 8060 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8061 | }, |
| 8062 | }, |
| 8063 | resumeSession: true, |
| 8064 | flags: []string{ |
| 8065 | "-async", |
| 8066 | "-initial-timeout-duration-ms", "250", |
| 8067 | }, |
| 8068 | }) |
| 8069 | testCases = append(testCases, testCase{ |
| 8070 | protocol: dtls, |
| 8071 | testType: serverTest, |
| 8072 | name: "DTLS-Retransmit-Short-Server", |
| 8073 | config: Config{ |
| 8074 | MaxVersion: VersionTLS12, |
| 8075 | Bugs: ProtocolBugs{ |
| 8076 | TimeoutSchedule: shortTimeouts[:len(shortTimeouts)-1], |
| 8077 | }, |
| 8078 | }, |
| 8079 | resumeSession: true, |
| 8080 | flags: []string{ |
| 8081 | "-async", |
| 8082 | "-initial-timeout-duration-ms", "250", |
| 8083 | }, |
| 8084 | }) |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 8085 | } |
| 8086 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8087 | func addExportKeyingMaterialTests() { |
| 8088 | for _, vers := range tlsVersions { |
| 8089 | if vers.version == VersionSSL30 { |
| 8090 | continue |
| 8091 | } |
| 8092 | testCases = append(testCases, testCase{ |
| 8093 | name: "ExportKeyingMaterial-" + vers.name, |
| 8094 | config: Config{ |
| 8095 | MaxVersion: vers.version, |
| 8096 | }, |
| 8097 | exportKeyingMaterial: 1024, |
| 8098 | exportLabel: "label", |
| 8099 | exportContext: "context", |
| 8100 | useExportContext: true, |
| 8101 | }) |
| 8102 | testCases = append(testCases, testCase{ |
| 8103 | name: "ExportKeyingMaterial-NoContext-" + vers.name, |
| 8104 | config: Config{ |
| 8105 | MaxVersion: vers.version, |
| 8106 | }, |
| 8107 | exportKeyingMaterial: 1024, |
| 8108 | }) |
| 8109 | testCases = append(testCases, testCase{ |
| 8110 | name: "ExportKeyingMaterial-EmptyContext-" + vers.name, |
| 8111 | config: Config{ |
| 8112 | MaxVersion: vers.version, |
| 8113 | }, |
| 8114 | exportKeyingMaterial: 1024, |
| 8115 | useExportContext: true, |
| 8116 | }) |
| 8117 | testCases = append(testCases, testCase{ |
| 8118 | name: "ExportKeyingMaterial-Small-" + vers.name, |
| 8119 | config: Config{ |
| 8120 | MaxVersion: vers.version, |
| 8121 | }, |
| 8122 | exportKeyingMaterial: 1, |
| 8123 | exportLabel: "label", |
| 8124 | exportContext: "context", |
| 8125 | useExportContext: true, |
| 8126 | }) |
| 8127 | } |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8128 | |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8129 | testCases = append(testCases, testCase{ |
| 8130 | name: "ExportKeyingMaterial-SSL3", |
| 8131 | config: Config{ |
| 8132 | MaxVersion: VersionSSL30, |
| 8133 | }, |
| 8134 | exportKeyingMaterial: 1024, |
| 8135 | exportLabel: "label", |
| 8136 | exportContext: "context", |
| 8137 | useExportContext: true, |
| 8138 | shouldFail: true, |
| 8139 | expectedError: "failed to export keying material", |
| 8140 | }) |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8141 | |
| 8142 | // Exporters work during a False Start. |
| 8143 | testCases = append(testCases, testCase{ |
| 8144 | name: "ExportKeyingMaterial-FalseStart", |
| 8145 | config: Config{ |
| 8146 | MaxVersion: VersionTLS12, |
| 8147 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8148 | NextProtos: []string{"foo"}, |
| 8149 | Bugs: ProtocolBugs{ |
| 8150 | ExpectFalseStart: true, |
| 8151 | }, |
| 8152 | }, |
| 8153 | flags: []string{ |
| 8154 | "-false-start", |
| 8155 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8156 | "-expect-alpn", "foo", |
David Benjamin | 7bb1d29 | 2016-11-01 19:45:06 -0400 | [diff] [blame] | 8157 | }, |
| 8158 | shimWritesFirst: true, |
| 8159 | exportKeyingMaterial: 1024, |
| 8160 | exportLabel: "label", |
| 8161 | exportContext: "context", |
| 8162 | useExportContext: true, |
| 8163 | }) |
| 8164 | |
| 8165 | // Exporters do not work in the middle of a renegotiation. Test this by |
| 8166 | // triggering the exporter after every SSL_read call and configuring the |
| 8167 | // shim to run asynchronously. |
| 8168 | testCases = append(testCases, testCase{ |
| 8169 | name: "ExportKeyingMaterial-Renegotiate", |
| 8170 | config: Config{ |
| 8171 | MaxVersion: VersionTLS12, |
| 8172 | }, |
| 8173 | renegotiate: 1, |
| 8174 | flags: []string{ |
| 8175 | "-async", |
| 8176 | "-use-exporter-between-reads", |
| 8177 | "-renegotiate-freely", |
| 8178 | "-expect-total-renegotiations", "1", |
| 8179 | }, |
| 8180 | shouldFail: true, |
| 8181 | expectedError: "failed to export keying material", |
| 8182 | }) |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 8183 | } |
| 8184 | |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8185 | func addTLSUniqueTests() { |
| 8186 | for _, isClient := range []bool{false, true} { |
| 8187 | for _, isResumption := range []bool{false, true} { |
| 8188 | for _, hasEMS := range []bool{false, true} { |
| 8189 | var suffix string |
| 8190 | if isResumption { |
| 8191 | suffix = "Resume-" |
| 8192 | } else { |
| 8193 | suffix = "Full-" |
| 8194 | } |
| 8195 | |
| 8196 | if hasEMS { |
| 8197 | suffix += "EMS-" |
| 8198 | } else { |
| 8199 | suffix += "NoEMS-" |
| 8200 | } |
| 8201 | |
| 8202 | if isClient { |
| 8203 | suffix += "Client" |
| 8204 | } else { |
| 8205 | suffix += "Server" |
| 8206 | } |
| 8207 | |
| 8208 | test := testCase{ |
| 8209 | name: "TLSUnique-" + suffix, |
| 8210 | testTLSUnique: true, |
| 8211 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8212 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8213 | Bugs: ProtocolBugs{ |
| 8214 | NoExtendedMasterSecret: !hasEMS, |
| 8215 | }, |
| 8216 | }, |
| 8217 | } |
| 8218 | |
| 8219 | if isResumption { |
| 8220 | test.resumeSession = true |
| 8221 | test.resumeConfig = &Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8222 | MaxVersion: VersionTLS12, |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 8223 | Bugs: ProtocolBugs{ |
| 8224 | NoExtendedMasterSecret: !hasEMS, |
| 8225 | }, |
| 8226 | } |
| 8227 | } |
| 8228 | |
| 8229 | if isResumption && !hasEMS { |
| 8230 | test.shouldFail = true |
| 8231 | test.expectedError = "failed to get tls-unique" |
| 8232 | } |
| 8233 | |
| 8234 | testCases = append(testCases, test) |
| 8235 | } |
| 8236 | } |
| 8237 | } |
| 8238 | } |
| 8239 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8240 | func addCustomExtensionTests() { |
| 8241 | expectedContents := "custom extension" |
| 8242 | emptyString := "" |
| 8243 | |
| 8244 | for _, isClient := range []bool{false, true} { |
| 8245 | suffix := "Server" |
| 8246 | flag := "-enable-server-custom-extension" |
| 8247 | testType := serverTest |
| 8248 | if isClient { |
| 8249 | suffix = "Client" |
| 8250 | flag = "-enable-client-custom-extension" |
| 8251 | testType = clientTest |
| 8252 | } |
| 8253 | |
| 8254 | testCases = append(testCases, testCase{ |
| 8255 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8256 | name: "CustomExtensions-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8257 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8258 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8259 | Bugs: ProtocolBugs{ |
| 8260 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8261 | ExpectedCustomExtension: &expectedContents, |
| 8262 | }, |
| 8263 | }, |
| 8264 | flags: []string{flag}, |
| 8265 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8266 | testCases = append(testCases, testCase{ |
| 8267 | testType: testType, |
| 8268 | name: "CustomExtensions-" + suffix + "-TLS13", |
| 8269 | config: Config{ |
| 8270 | MaxVersion: VersionTLS13, |
| 8271 | Bugs: ProtocolBugs{ |
| 8272 | CustomExtension: expectedContents, |
| 8273 | ExpectedCustomExtension: &expectedContents, |
| 8274 | }, |
| 8275 | }, |
| 8276 | flags: []string{flag}, |
| 8277 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8278 | |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 8279 | // 0-RTT is not currently supported with Custom Extensions. |
| 8280 | testCases = append(testCases, testCase{ |
| 8281 | testType: testType, |
| 8282 | name: "CustomExtensions-" + suffix + "-EarlyData", |
| 8283 | config: Config{ |
| 8284 | MaxVersion: VersionTLS13, |
| 8285 | Bugs: ProtocolBugs{ |
| 8286 | CustomExtension: expectedContents, |
| 8287 | ExpectedCustomExtension: &expectedContents, |
| 8288 | }, |
| 8289 | }, |
| 8290 | shouldFail: true, |
| 8291 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8292 | flags: []string{flag, "-enable-early-data"}, |
| 8293 | }) |
| 8294 | |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8295 | // If the parse callback fails, the handshake should also fail. |
| 8296 | testCases = append(testCases, testCase{ |
| 8297 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8298 | name: "CustomExtensions-ParseError-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8299 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8300 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8301 | Bugs: ProtocolBugs{ |
| 8302 | CustomExtension: expectedContents + "foo", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8303 | ExpectedCustomExtension: &expectedContents, |
| 8304 | }, |
| 8305 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8306 | flags: []string{flag}, |
| 8307 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8308 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8309 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8310 | testCases = append(testCases, testCase{ |
| 8311 | testType: testType, |
| 8312 | name: "CustomExtensions-ParseError-" + suffix + "-TLS13", |
| 8313 | config: Config{ |
| 8314 | MaxVersion: VersionTLS13, |
| 8315 | Bugs: ProtocolBugs{ |
| 8316 | CustomExtension: expectedContents + "foo", |
| 8317 | ExpectedCustomExtension: &expectedContents, |
| 8318 | }, |
| 8319 | }, |
| 8320 | flags: []string{flag}, |
| 8321 | shouldFail: true, |
| 8322 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8323 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8324 | |
| 8325 | // If the add callback fails, the handshake should also fail. |
| 8326 | testCases = append(testCases, testCase{ |
| 8327 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8328 | name: "CustomExtensions-FailAdd-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8329 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8330 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8331 | Bugs: ProtocolBugs{ |
| 8332 | CustomExtension: expectedContents, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8333 | ExpectedCustomExtension: &expectedContents, |
| 8334 | }, |
| 8335 | }, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8336 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8337 | shouldFail: true, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8338 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8339 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8340 | testCases = append(testCases, testCase{ |
| 8341 | testType: testType, |
| 8342 | name: "CustomExtensions-FailAdd-" + suffix + "-TLS13", |
| 8343 | config: Config{ |
| 8344 | MaxVersion: VersionTLS13, |
| 8345 | Bugs: ProtocolBugs{ |
| 8346 | CustomExtension: expectedContents, |
| 8347 | ExpectedCustomExtension: &expectedContents, |
| 8348 | }, |
| 8349 | }, |
| 8350 | flags: []string{flag, "-custom-extension-fail-add"}, |
| 8351 | shouldFail: true, |
| 8352 | expectedError: ":CUSTOM_EXTENSION_ERROR:", |
| 8353 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8354 | |
| 8355 | // If the add callback returns zero, no extension should be |
| 8356 | // added. |
| 8357 | skipCustomExtension := expectedContents |
| 8358 | if isClient { |
| 8359 | // For the case where the client skips sending the |
| 8360 | // custom extension, the server must not “echo” it. |
| 8361 | skipCustomExtension = "" |
| 8362 | } |
| 8363 | testCases = append(testCases, testCase{ |
| 8364 | testType: testType, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8365 | name: "CustomExtensions-Skip-" + suffix, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8366 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8367 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8368 | Bugs: ProtocolBugs{ |
| 8369 | CustomExtension: skipCustomExtension, |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8370 | ExpectedCustomExtension: &emptyString, |
| 8371 | }, |
| 8372 | }, |
| 8373 | flags: []string{flag, "-custom-extension-skip"}, |
| 8374 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8375 | testCases = append(testCases, testCase{ |
| 8376 | testType: testType, |
| 8377 | name: "CustomExtensions-Skip-" + suffix + "-TLS13", |
| 8378 | config: Config{ |
| 8379 | MaxVersion: VersionTLS13, |
| 8380 | Bugs: ProtocolBugs{ |
| 8381 | CustomExtension: skipCustomExtension, |
| 8382 | ExpectedCustomExtension: &emptyString, |
| 8383 | }, |
| 8384 | }, |
| 8385 | flags: []string{flag, "-custom-extension-skip"}, |
| 8386 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8387 | } |
| 8388 | |
| 8389 | // The custom extension add callback should not be called if the client |
| 8390 | // doesn't send the extension. |
| 8391 | testCases = append(testCases, testCase{ |
| 8392 | testType: serverTest, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8393 | name: "CustomExtensions-NotCalled-Server", |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8394 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8395 | MaxVersion: VersionTLS12, |
David Benjamin | 399e7c9 | 2015-07-30 23:01:27 -0400 | [diff] [blame] | 8396 | Bugs: ProtocolBugs{ |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8397 | ExpectedCustomExtension: &emptyString, |
| 8398 | }, |
| 8399 | }, |
| 8400 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 8401 | }) |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8402 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8403 | testCases = append(testCases, testCase{ |
| 8404 | testType: serverTest, |
| 8405 | name: "CustomExtensions-NotCalled-Server-TLS13", |
| 8406 | config: Config{ |
| 8407 | MaxVersion: VersionTLS13, |
| 8408 | Bugs: ProtocolBugs{ |
| 8409 | ExpectedCustomExtension: &emptyString, |
| 8410 | }, |
| 8411 | }, |
| 8412 | flags: []string{"-enable-server-custom-extension", "-custom-extension-fail-add"}, |
| 8413 | }) |
| 8414 | |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8415 | // Test an unknown extension from the server. |
| 8416 | testCases = append(testCases, testCase{ |
| 8417 | testType: clientTest, |
| 8418 | name: "UnknownExtension-Client", |
| 8419 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8420 | MaxVersion: VersionTLS12, |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8421 | Bugs: ProtocolBugs{ |
| 8422 | CustomExtension: expectedContents, |
| 8423 | }, |
| 8424 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8425 | shouldFail: true, |
| 8426 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8427 | expectedLocalError: "remote error: unsupported extension", |
Adam Langley | 2deb984 | 2015-08-07 11:15:37 -0700 | [diff] [blame] | 8428 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8429 | testCases = append(testCases, testCase{ |
| 8430 | testType: clientTest, |
| 8431 | name: "UnknownExtension-Client-TLS13", |
| 8432 | config: Config{ |
| 8433 | MaxVersion: VersionTLS13, |
| 8434 | Bugs: ProtocolBugs{ |
| 8435 | CustomExtension: expectedContents, |
| 8436 | }, |
| 8437 | }, |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8438 | shouldFail: true, |
| 8439 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8440 | expectedLocalError: "remote error: unsupported extension", |
| 8441 | }) |
David Benjamin | 490469f | 2016-10-05 22:44:38 -0400 | [diff] [blame] | 8442 | testCases = append(testCases, testCase{ |
| 8443 | testType: clientTest, |
| 8444 | name: "UnknownUnencryptedExtension-Client-TLS13", |
| 8445 | config: Config{ |
| 8446 | MaxVersion: VersionTLS13, |
| 8447 | Bugs: ProtocolBugs{ |
| 8448 | CustomUnencryptedExtension: expectedContents, |
| 8449 | }, |
| 8450 | }, |
| 8451 | shouldFail: true, |
| 8452 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8453 | // The shim must send an alert, but alerts at this point do not |
| 8454 | // get successfully decrypted by the runner. |
| 8455 | expectedLocalError: "local error: bad record MAC", |
| 8456 | }) |
| 8457 | testCases = append(testCases, testCase{ |
| 8458 | testType: clientTest, |
| 8459 | name: "UnexpectedUnencryptedExtension-Client-TLS13", |
| 8460 | config: Config{ |
| 8461 | MaxVersion: VersionTLS13, |
| 8462 | Bugs: ProtocolBugs{ |
| 8463 | SendUnencryptedALPN: "foo", |
| 8464 | }, |
| 8465 | }, |
| 8466 | flags: []string{ |
| 8467 | "-advertise-alpn", "\x03foo\x03bar", |
| 8468 | }, |
| 8469 | shouldFail: true, |
| 8470 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8471 | // The shim must send an alert, but alerts at this point do not |
| 8472 | // get successfully decrypted by the runner. |
| 8473 | expectedLocalError: "local error: bad record MAC", |
| 8474 | }) |
David Benjamin | 0c40a96 | 2016-08-01 12:05:50 -0400 | [diff] [blame] | 8475 | |
| 8476 | // Test a known but unoffered extension from the server. |
| 8477 | testCases = append(testCases, testCase{ |
| 8478 | testType: clientTest, |
| 8479 | name: "UnofferedExtension-Client", |
| 8480 | config: Config{ |
| 8481 | MaxVersion: VersionTLS12, |
| 8482 | Bugs: ProtocolBugs{ |
| 8483 | SendALPN: "alpn", |
| 8484 | }, |
| 8485 | }, |
| 8486 | shouldFail: true, |
| 8487 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8488 | expectedLocalError: "remote error: unsupported extension", |
| 8489 | }) |
| 8490 | testCases = append(testCases, testCase{ |
| 8491 | testType: clientTest, |
| 8492 | name: "UnofferedExtension-Client-TLS13", |
| 8493 | config: Config{ |
| 8494 | MaxVersion: VersionTLS13, |
| 8495 | Bugs: ProtocolBugs{ |
| 8496 | SendALPN: "alpn", |
| 8497 | }, |
| 8498 | }, |
| 8499 | shouldFail: true, |
| 8500 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 8501 | expectedLocalError: "remote error: unsupported extension", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8502 | }) |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 8503 | } |
| 8504 | |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8505 | func addRSAClientKeyExchangeTests() { |
| 8506 | for bad := RSABadValue(1); bad < NumRSABadValues; bad++ { |
| 8507 | testCases = append(testCases, testCase{ |
| 8508 | testType: serverTest, |
| 8509 | name: fmt.Sprintf("BadRSAClientKeyExchange-%d", bad), |
| 8510 | config: Config{ |
| 8511 | // Ensure the ClientHello version and final |
| 8512 | // version are different, to detect if the |
| 8513 | // server uses the wrong one. |
| 8514 | MaxVersion: VersionTLS11, |
Matt Braithwaite | 07e7806 | 2016-08-21 14:50:43 -0700 | [diff] [blame] | 8515 | CipherSuites: []uint16{TLS_RSA_WITH_3DES_EDE_CBC_SHA}, |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8516 | Bugs: ProtocolBugs{ |
| 8517 | BadRSAClientKeyExchange: bad, |
| 8518 | }, |
| 8519 | }, |
| 8520 | shouldFail: true, |
| 8521 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8522 | }) |
| 8523 | } |
David Benjamin | e63d9d7 | 2016-09-19 18:27:34 -0400 | [diff] [blame] | 8524 | |
| 8525 | // The server must compare whatever was in ClientHello.version for the |
| 8526 | // RSA premaster. |
| 8527 | testCases = append(testCases, testCase{ |
| 8528 | testType: serverTest, |
| 8529 | name: "SendClientVersion-RSA", |
| 8530 | config: Config{ |
| 8531 | CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, |
| 8532 | Bugs: ProtocolBugs{ |
| 8533 | SendClientVersion: 0x1234, |
| 8534 | }, |
| 8535 | }, |
| 8536 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 8537 | }) |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 8538 | } |
| 8539 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8540 | var testCurves = []struct { |
| 8541 | name string |
| 8542 | id CurveID |
| 8543 | }{ |
Adam Langley | 764ab98 | 2017-03-10 18:01:30 -0800 | [diff] [blame] | 8544 | {"P-224", CurveP224}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8545 | {"P-256", CurveP256}, |
| 8546 | {"P-384", CurveP384}, |
| 8547 | {"P-521", CurveP521}, |
David Benjamin | 4298d77 | 2015-12-19 00:18:25 -0500 | [diff] [blame] | 8548 | {"X25519", CurveX25519}, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8549 | } |
| 8550 | |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8551 | const bogusCurve = 0x1234 |
| 8552 | |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8553 | func addCurveTests() { |
| 8554 | for _, curve := range testCurves { |
| 8555 | testCases = append(testCases, testCase{ |
| 8556 | name: "CurveTest-Client-" + curve.name, |
| 8557 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8558 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8559 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8560 | CurvePreferences: []CurveID{curve.id}, |
| 8561 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8562 | flags: []string{ |
| 8563 | "-enable-all-curves", |
| 8564 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8565 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8566 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8567 | }) |
| 8568 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8569 | name: "CurveTest-Client-" + curve.name + "-TLS13", |
| 8570 | config: Config{ |
| 8571 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8572 | CurvePreferences: []CurveID{curve.id}, |
| 8573 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8574 | flags: []string{ |
| 8575 | "-enable-all-curves", |
| 8576 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8577 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8578 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8579 | }) |
| 8580 | testCases = append(testCases, testCase{ |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8581 | testType: serverTest, |
| 8582 | name: "CurveTest-Server-" + curve.name, |
| 8583 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8584 | MaxVersion: VersionTLS12, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8585 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8586 | CurvePreferences: []CurveID{curve.id}, |
| 8587 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8588 | flags: []string{ |
| 8589 | "-enable-all-curves", |
| 8590 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8591 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8592 | expectedCurveID: curve.id, |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8593 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8594 | testCases = append(testCases, testCase{ |
| 8595 | testType: serverTest, |
| 8596 | name: "CurveTest-Server-" + curve.name + "-TLS13", |
| 8597 | config: Config{ |
| 8598 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8599 | CurvePreferences: []CurveID{curve.id}, |
| 8600 | }, |
David Benjamin | 5c4e857 | 2016-08-19 17:44:53 -0400 | [diff] [blame] | 8601 | flags: []string{ |
| 8602 | "-enable-all-curves", |
| 8603 | "-expect-curve-id", strconv.Itoa(int(curve.id)), |
| 8604 | }, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 8605 | expectedCurveID: curve.id, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8606 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8607 | } |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8608 | |
| 8609 | // The server must be tolerant to bogus curves. |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8610 | testCases = append(testCases, testCase{ |
| 8611 | testType: serverTest, |
| 8612 | name: "UnknownCurve", |
| 8613 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8614 | MaxVersion: VersionTLS12, |
David Benjamin | 241ae83 | 2016-01-15 03:04:54 -0500 | [diff] [blame] | 8615 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8616 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8617 | }, |
| 8618 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8619 | |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8620 | // The server must be tolerant to bogus curves. |
| 8621 | testCases = append(testCases, testCase{ |
| 8622 | testType: serverTest, |
| 8623 | name: "UnknownCurve-TLS13", |
| 8624 | config: Config{ |
| 8625 | MaxVersion: VersionTLS13, |
| 8626 | CurvePreferences: []CurveID{bogusCurve, CurveP256}, |
| 8627 | }, |
| 8628 | }) |
| 8629 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8630 | // The server must not consider ECDHE ciphers when there are no |
| 8631 | // supported curves. |
| 8632 | testCases = append(testCases, testCase{ |
| 8633 | testType: serverTest, |
| 8634 | name: "NoSupportedCurves", |
| 8635 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8636 | MaxVersion: VersionTLS12, |
| 8637 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8638 | Bugs: ProtocolBugs{ |
| 8639 | NoSupportedCurves: true, |
| 8640 | }, |
| 8641 | }, |
| 8642 | shouldFail: true, |
| 8643 | expectedError: ":NO_SHARED_CIPHER:", |
| 8644 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8645 | testCases = append(testCases, testCase{ |
| 8646 | testType: serverTest, |
| 8647 | name: "NoSupportedCurves-TLS13", |
| 8648 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8649 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8650 | Bugs: ProtocolBugs{ |
| 8651 | NoSupportedCurves: true, |
| 8652 | }, |
| 8653 | }, |
| 8654 | shouldFail: true, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8655 | expectedError: ":NO_SHARED_GROUP:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8656 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8657 | |
| 8658 | // The server must fall back to another cipher when there are no |
| 8659 | // supported curves. |
| 8660 | testCases = append(testCases, testCase{ |
| 8661 | testType: serverTest, |
| 8662 | name: "NoCommonCurves", |
| 8663 | config: Config{ |
| 8664 | MaxVersion: VersionTLS12, |
| 8665 | CipherSuites: []uint16{ |
| 8666 | TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 8667 | TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8668 | }, |
| 8669 | CurvePreferences: []CurveID{CurveP224}, |
| 8670 | }, |
Matthew Braithwaite | cedc6f1 | 2017-03-15 19:20:23 -0700 | [diff] [blame] | 8671 | expectedCipher: TLS_RSA_WITH_AES_128_GCM_SHA256, |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8672 | }) |
| 8673 | |
| 8674 | // The client must reject bogus curves and disabled curves. |
| 8675 | testCases = append(testCases, testCase{ |
| 8676 | name: "BadECDHECurve", |
| 8677 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8678 | MaxVersion: VersionTLS12, |
| 8679 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8680 | Bugs: ProtocolBugs{ |
| 8681 | SendCurve: bogusCurve, |
| 8682 | }, |
| 8683 | }, |
| 8684 | shouldFail: true, |
| 8685 | expectedError: ":WRONG_CURVE:", |
| 8686 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8687 | testCases = append(testCases, testCase{ |
| 8688 | name: "BadECDHECurve-TLS13", |
| 8689 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8690 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8691 | Bugs: ProtocolBugs{ |
| 8692 | SendCurve: bogusCurve, |
| 8693 | }, |
| 8694 | }, |
| 8695 | shouldFail: true, |
| 8696 | expectedError: ":WRONG_CURVE:", |
| 8697 | }) |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8698 | |
| 8699 | testCases = append(testCases, testCase{ |
| 8700 | name: "UnsupportedCurve", |
| 8701 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8702 | MaxVersion: VersionTLS12, |
| 8703 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8704 | CurvePreferences: []CurveID{CurveP256}, |
| 8705 | Bugs: ProtocolBugs{ |
| 8706 | IgnorePeerCurvePreferences: true, |
| 8707 | }, |
| 8708 | }, |
| 8709 | flags: []string{"-p384-only"}, |
| 8710 | shouldFail: true, |
| 8711 | expectedError: ":WRONG_CURVE:", |
| 8712 | }) |
| 8713 | |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8714 | testCases = append(testCases, testCase{ |
| 8715 | // TODO(davidben): Add a TLS 1.3 version where |
| 8716 | // HelloRetryRequest requests an unsupported curve. |
| 8717 | name: "UnsupportedCurve-ServerHello-TLS13", |
| 8718 | config: Config{ |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 8719 | MaxVersion: VersionTLS13, |
David Benjamin | 4f92157 | 2016-07-17 14:20:10 +0200 | [diff] [blame] | 8720 | CurvePreferences: []CurveID{CurveP384}, |
| 8721 | Bugs: ProtocolBugs{ |
| 8722 | SendCurve: CurveP256, |
| 8723 | }, |
| 8724 | }, |
| 8725 | flags: []string{"-p384-only"}, |
| 8726 | shouldFail: true, |
| 8727 | expectedError: ":WRONG_CURVE:", |
| 8728 | }) |
| 8729 | |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8730 | // Test invalid curve points. |
| 8731 | testCases = append(testCases, testCase{ |
| 8732 | name: "InvalidECDHPoint-Client", |
| 8733 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8734 | MaxVersion: VersionTLS12, |
| 8735 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8736 | CurvePreferences: []CurveID{CurveP256}, |
| 8737 | Bugs: ProtocolBugs{ |
| 8738 | InvalidECDHPoint: true, |
| 8739 | }, |
| 8740 | }, |
| 8741 | shouldFail: true, |
| 8742 | expectedError: ":INVALID_ENCODING:", |
| 8743 | }) |
| 8744 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8745 | name: "InvalidECDHPoint-Client-TLS13", |
| 8746 | config: Config{ |
| 8747 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8748 | CurvePreferences: []CurveID{CurveP256}, |
| 8749 | Bugs: ProtocolBugs{ |
| 8750 | InvalidECDHPoint: true, |
| 8751 | }, |
| 8752 | }, |
| 8753 | shouldFail: true, |
| 8754 | expectedError: ":INVALID_ENCODING:", |
| 8755 | }) |
| 8756 | testCases = append(testCases, testCase{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8757 | testType: serverTest, |
| 8758 | name: "InvalidECDHPoint-Server", |
| 8759 | config: Config{ |
David Benjamin | 4c3ddf7 | 2016-06-29 18:13:53 -0400 | [diff] [blame] | 8760 | MaxVersion: VersionTLS12, |
| 8761 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8762 | CurvePreferences: []CurveID{CurveP256}, |
| 8763 | Bugs: ProtocolBugs{ |
| 8764 | InvalidECDHPoint: true, |
| 8765 | }, |
| 8766 | }, |
| 8767 | shouldFail: true, |
| 8768 | expectedError: ":INVALID_ENCODING:", |
| 8769 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8770 | testCases = append(testCases, testCase{ |
| 8771 | testType: serverTest, |
| 8772 | name: "InvalidECDHPoint-Server-TLS13", |
| 8773 | config: Config{ |
| 8774 | MaxVersion: VersionTLS13, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 8775 | CurvePreferences: []CurveID{CurveP256}, |
| 8776 | Bugs: ProtocolBugs{ |
| 8777 | InvalidECDHPoint: true, |
| 8778 | }, |
| 8779 | }, |
| 8780 | shouldFail: true, |
| 8781 | expectedError: ":INVALID_ENCODING:", |
| 8782 | }) |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8783 | |
| 8784 | // The previous curve ID should be reported on TLS 1.2 resumption. |
| 8785 | testCases = append(testCases, testCase{ |
| 8786 | name: "CurveID-Resume-Client", |
| 8787 | config: Config{ |
| 8788 | MaxVersion: VersionTLS12, |
| 8789 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8790 | CurvePreferences: []CurveID{CurveX25519}, |
| 8791 | }, |
| 8792 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8793 | resumeSession: true, |
| 8794 | }) |
| 8795 | testCases = append(testCases, testCase{ |
| 8796 | testType: serverTest, |
| 8797 | name: "CurveID-Resume-Server", |
| 8798 | config: Config{ |
| 8799 | MaxVersion: VersionTLS12, |
| 8800 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 8801 | CurvePreferences: []CurveID{CurveX25519}, |
| 8802 | }, |
| 8803 | flags: []string{"-expect-curve-id", strconv.Itoa(int(CurveX25519))}, |
| 8804 | resumeSession: true, |
| 8805 | }) |
| 8806 | |
| 8807 | // TLS 1.3 allows resuming at a differet curve. If this happens, the new |
| 8808 | // one should be reported. |
| 8809 | testCases = append(testCases, testCase{ |
| 8810 | name: "CurveID-Resume-Client-TLS13", |
| 8811 | config: Config{ |
| 8812 | MaxVersion: VersionTLS13, |
| 8813 | CurvePreferences: []CurveID{CurveX25519}, |
| 8814 | }, |
| 8815 | resumeConfig: &Config{ |
| 8816 | MaxVersion: VersionTLS13, |
| 8817 | CurvePreferences: []CurveID{CurveP256}, |
| 8818 | }, |
| 8819 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8820 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8821 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8822 | }, |
| 8823 | resumeSession: true, |
| 8824 | }) |
| 8825 | testCases = append(testCases, testCase{ |
| 8826 | testType: serverTest, |
| 8827 | name: "CurveID-Resume-Server-TLS13", |
| 8828 | config: Config{ |
| 8829 | MaxVersion: VersionTLS13, |
| 8830 | CurvePreferences: []CurveID{CurveX25519}, |
| 8831 | }, |
| 8832 | resumeConfig: &Config{ |
| 8833 | MaxVersion: VersionTLS13, |
| 8834 | CurvePreferences: []CurveID{CurveP256}, |
| 8835 | }, |
| 8836 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 8837 | "-on-initial-expect-curve-id", strconv.Itoa(int(CurveX25519)), |
| 8838 | "-on-resume-expect-curve-id", strconv.Itoa(int(CurveP256)), |
David Benjamin | 8a55ce4 | 2016-12-11 03:03:42 -0500 | [diff] [blame] | 8839 | }, |
| 8840 | resumeSession: true, |
| 8841 | }) |
David Benjamin | a81967b | 2016-12-22 09:16:57 -0500 | [diff] [blame] | 8842 | |
| 8843 | // Server-sent point formats are legal in TLS 1.2, but not in TLS 1.3. |
| 8844 | testCases = append(testCases, testCase{ |
| 8845 | name: "PointFormat-ServerHello-TLS12", |
| 8846 | config: Config{ |
| 8847 | MaxVersion: VersionTLS12, |
| 8848 | Bugs: ProtocolBugs{ |
| 8849 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8850 | }, |
| 8851 | }, |
| 8852 | }) |
| 8853 | testCases = append(testCases, testCase{ |
| 8854 | name: "PointFormat-EncryptedExtensions-TLS13", |
| 8855 | config: Config{ |
| 8856 | MaxVersion: VersionTLS13, |
| 8857 | Bugs: ProtocolBugs{ |
| 8858 | SendSupportedPointFormats: []byte{pointFormatUncompressed}, |
| 8859 | }, |
| 8860 | }, |
| 8861 | shouldFail: true, |
| 8862 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8863 | }) |
| 8864 | |
| 8865 | // Test that we tolerate unknown point formats, as long as |
| 8866 | // pointFormatUncompressed is present. Limit ciphers to ECDHE ciphers to |
| 8867 | // check they are still functional. |
| 8868 | testCases = append(testCases, testCase{ |
| 8869 | name: "PointFormat-Client-Tolerance", |
| 8870 | config: Config{ |
| 8871 | MaxVersion: VersionTLS12, |
| 8872 | Bugs: ProtocolBugs{ |
| 8873 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8874 | }, |
| 8875 | }, |
| 8876 | }) |
| 8877 | testCases = append(testCases, testCase{ |
| 8878 | testType: serverTest, |
| 8879 | name: "PointFormat-Server-Tolerance", |
| 8880 | config: Config{ |
| 8881 | MaxVersion: VersionTLS12, |
| 8882 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8883 | Bugs: ProtocolBugs{ |
| 8884 | SendSupportedPointFormats: []byte{42, pointFormatUncompressed, 99, pointFormatCompressedPrime}, |
| 8885 | }, |
| 8886 | }, |
| 8887 | }) |
| 8888 | |
| 8889 | // Test TLS 1.2 does not require the point format extension to be |
| 8890 | // present. |
| 8891 | testCases = append(testCases, testCase{ |
| 8892 | name: "PointFormat-Client-Missing", |
| 8893 | config: Config{ |
| 8894 | MaxVersion: VersionTLS12, |
| 8895 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8896 | Bugs: ProtocolBugs{ |
| 8897 | SendSupportedPointFormats: []byte{}, |
| 8898 | }, |
| 8899 | }, |
| 8900 | }) |
| 8901 | testCases = append(testCases, testCase{ |
| 8902 | testType: serverTest, |
| 8903 | name: "PointFormat-Server-Missing", |
| 8904 | config: Config{ |
| 8905 | MaxVersion: VersionTLS12, |
| 8906 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256}, |
| 8907 | Bugs: ProtocolBugs{ |
| 8908 | SendSupportedPointFormats: []byte{}, |
| 8909 | }, |
| 8910 | }, |
| 8911 | }) |
| 8912 | |
| 8913 | // If the point format extension is present, uncompressed points must be |
| 8914 | // offered. BoringSSL requires this whether or not ECDHE is used. |
| 8915 | testCases = append(testCases, testCase{ |
| 8916 | name: "PointFormat-Client-MissingUncompressed", |
| 8917 | config: Config{ |
| 8918 | MaxVersion: VersionTLS12, |
| 8919 | Bugs: ProtocolBugs{ |
| 8920 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8921 | }, |
| 8922 | }, |
| 8923 | shouldFail: true, |
| 8924 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8925 | }) |
| 8926 | testCases = append(testCases, testCase{ |
| 8927 | testType: serverTest, |
| 8928 | name: "PointFormat-Server-MissingUncompressed", |
| 8929 | config: Config{ |
| 8930 | MaxVersion: VersionTLS12, |
| 8931 | Bugs: ProtocolBugs{ |
| 8932 | SendSupportedPointFormats: []byte{pointFormatCompressedPrime}, |
| 8933 | }, |
| 8934 | }, |
| 8935 | shouldFail: true, |
| 8936 | expectedError: ":ERROR_PARSING_EXTENSION:", |
| 8937 | }) |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 8938 | } |
| 8939 | |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 8940 | func addTLS13RecordTests() { |
| 8941 | testCases = append(testCases, testCase{ |
| 8942 | name: "TLS13-RecordPadding", |
| 8943 | config: Config{ |
| 8944 | MaxVersion: VersionTLS13, |
| 8945 | MinVersion: VersionTLS13, |
| 8946 | Bugs: ProtocolBugs{ |
| 8947 | RecordPadding: 10, |
| 8948 | }, |
| 8949 | }, |
| 8950 | }) |
| 8951 | |
| 8952 | testCases = append(testCases, testCase{ |
| 8953 | name: "TLS13-EmptyRecords", |
| 8954 | config: Config{ |
| 8955 | MaxVersion: VersionTLS13, |
| 8956 | MinVersion: VersionTLS13, |
| 8957 | Bugs: ProtocolBugs{ |
| 8958 | OmitRecordContents: true, |
| 8959 | }, |
| 8960 | }, |
| 8961 | shouldFail: true, |
| 8962 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8963 | }) |
| 8964 | |
| 8965 | testCases = append(testCases, testCase{ |
| 8966 | name: "TLS13-OnlyPadding", |
| 8967 | config: Config{ |
| 8968 | MaxVersion: VersionTLS13, |
| 8969 | MinVersion: VersionTLS13, |
| 8970 | Bugs: ProtocolBugs{ |
| 8971 | OmitRecordContents: true, |
| 8972 | RecordPadding: 10, |
| 8973 | }, |
| 8974 | }, |
| 8975 | shouldFail: true, |
| 8976 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 8977 | }) |
| 8978 | |
| 8979 | testCases = append(testCases, testCase{ |
| 8980 | name: "TLS13-WrongOuterRecord", |
| 8981 | config: Config{ |
| 8982 | MaxVersion: VersionTLS13, |
| 8983 | MinVersion: VersionTLS13, |
| 8984 | Bugs: ProtocolBugs{ |
| 8985 | OuterRecordType: recordTypeHandshake, |
| 8986 | }, |
| 8987 | }, |
| 8988 | shouldFail: true, |
| 8989 | expectedError: ":INVALID_OUTER_RECORD_TYPE:", |
| 8990 | }) |
| 8991 | } |
| 8992 | |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 8993 | func addSessionTicketTests() { |
| 8994 | testCases = append(testCases, testCase{ |
| 8995 | // In TLS 1.2 and below, empty NewSessionTicket messages |
| 8996 | // mean the server changed its mind on sending a ticket. |
| 8997 | name: "SendEmptySessionTicket", |
| 8998 | config: Config{ |
| 8999 | MaxVersion: VersionTLS12, |
| 9000 | Bugs: ProtocolBugs{ |
| 9001 | SendEmptySessionTicket: true, |
| 9002 | }, |
| 9003 | }, |
| 9004 | flags: []string{"-expect-no-session"}, |
| 9005 | }) |
| 9006 | |
| 9007 | // Test that the server ignores unknown PSK modes. |
| 9008 | testCases = append(testCases, testCase{ |
| 9009 | testType: serverTest, |
| 9010 | name: "TLS13-SendUnknownModeSessionTicket-Server", |
| 9011 | config: Config{ |
| 9012 | MaxVersion: VersionTLS13, |
| 9013 | Bugs: ProtocolBugs{ |
| 9014 | SendPSKKeyExchangeModes: []byte{0x1a, pskDHEKEMode, 0x2a}, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9015 | }, |
| 9016 | }, |
| 9017 | resumeSession: true, |
| 9018 | expectedResumeVersion: VersionTLS13, |
| 9019 | }) |
| 9020 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9021 | // Test that the server does not send session tickets with no matching key exchange mode. |
| 9022 | testCases = append(testCases, testCase{ |
| 9023 | testType: serverTest, |
| 9024 | name: "TLS13-ExpectNoSessionTicketOnBadKEMode-Server", |
| 9025 | config: Config{ |
| 9026 | MaxVersion: VersionTLS13, |
| 9027 | Bugs: ProtocolBugs{ |
| 9028 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9029 | ExpectNoNewSessionTicket: true, |
| 9030 | }, |
| 9031 | }, |
| 9032 | }) |
| 9033 | |
| 9034 | // 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] | 9035 | testCases = append(testCases, testCase{ |
| 9036 | testType: serverTest, |
| 9037 | name: "TLS13-SendBadKEModeSessionTicket-Server", |
| 9038 | config: Config{ |
| 9039 | MaxVersion: VersionTLS13, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9040 | }, |
| 9041 | resumeConfig: &Config{ |
| 9042 | MaxVersion: VersionTLS13, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9043 | Bugs: ProtocolBugs{ |
| 9044 | SendPSKKeyExchangeModes: []byte{0x1a}, |
| 9045 | }, |
| 9046 | }, |
| 9047 | resumeSession: true, |
| 9048 | expectResumeRejected: true, |
| 9049 | }) |
| 9050 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9051 | // Test that the client ticket age is sent correctly. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9052 | testCases = append(testCases, testCase{ |
| 9053 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9054 | name: "TLS13-TestValidTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9055 | config: Config{ |
| 9056 | MaxVersion: VersionTLS13, |
| 9057 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9058 | ExpectTicketAge: 10 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9059 | }, |
| 9060 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9061 | resumeSession: true, |
| 9062 | flags: []string{ |
| 9063 | "-resumption-delay", "10", |
| 9064 | }, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9065 | }) |
| 9066 | |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9067 | // Test that the client ticket age is enforced. |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9068 | testCases = append(testCases, testCase{ |
| 9069 | testType: clientTest, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9070 | name: "TLS13-TestBadTicketAge-Client", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9071 | config: Config{ |
| 9072 | MaxVersion: VersionTLS13, |
| 9073 | Bugs: ProtocolBugs{ |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9074 | ExpectTicketAge: 1000 * time.Second, |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9075 | }, |
| 9076 | }, |
Steven Valdez | a833c35 | 2016-11-01 13:39:36 -0400 | [diff] [blame] | 9077 | resumeSession: true, |
| 9078 | shouldFail: true, |
| 9079 | expectedLocalError: "tls: invalid ticket age", |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9080 | }) |
| 9081 | |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9082 | // Test that the server's ticket age skew reporting works. |
| 9083 | testCases = append(testCases, testCase{ |
| 9084 | testType: serverTest, |
| 9085 | name: "TLS13-TicketAgeSkew-Forward", |
| 9086 | config: Config{ |
| 9087 | MaxVersion: VersionTLS13, |
| 9088 | Bugs: ProtocolBugs{ |
| 9089 | SendTicketAge: 15 * time.Second, |
| 9090 | }, |
| 9091 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9092 | resumeSession: true, |
| 9093 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9094 | flags: []string{ |
| 9095 | "-resumption-delay", "10", |
| 9096 | "-expect-ticket-age-skew", "5", |
| 9097 | }, |
| 9098 | }) |
| 9099 | testCases = append(testCases, testCase{ |
| 9100 | testType: serverTest, |
| 9101 | name: "TLS13-TicketAgeSkew-Backward", |
| 9102 | config: Config{ |
| 9103 | MaxVersion: VersionTLS13, |
| 9104 | Bugs: ProtocolBugs{ |
| 9105 | SendTicketAge: 5 * time.Second, |
| 9106 | }, |
| 9107 | }, |
David Benjamin | 065d733 | 2017-03-26 10:51:43 -0500 | [diff] [blame] | 9108 | resumeSession: true, |
| 9109 | resumeRenewedSession: true, |
David Benjamin | 35ac5b7 | 2017-03-03 15:05:56 -0500 | [diff] [blame] | 9110 | flags: []string{ |
| 9111 | "-resumption-delay", "10", |
| 9112 | "-expect-ticket-age-skew", "-5", |
| 9113 | }, |
| 9114 | }) |
| 9115 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9116 | testCases = append(testCases, testCase{ |
| 9117 | testType: clientTest, |
| 9118 | name: "TLS13-SendTicketEarlyDataInfo", |
| 9119 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9120 | MaxVersion: VersionTLS13, |
| 9121 | MaxEarlyDataSize: 16384, |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9122 | }, |
| 9123 | flags: []string{ |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9124 | "-enable-early-data", |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9125 | "-expect-early-data-info", |
| 9126 | }, |
| 9127 | }) |
| 9128 | |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9129 | // Test that 0-RTT tickets are ignored in clients unless opted in. |
| 9130 | testCases = append(testCases, testCase{ |
| 9131 | testType: clientTest, |
| 9132 | name: "TLS13-SendTicketEarlyDataInfo-Disabled", |
| 9133 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9134 | MaxVersion: VersionTLS13, |
| 9135 | MaxEarlyDataSize: 16384, |
David Benjamin | 9b16066 | 2017-01-25 19:53:43 -0500 | [diff] [blame] | 9136 | }, |
| 9137 | }) |
| 9138 | |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9139 | testCases = append(testCases, testCase{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9140 | testType: clientTest, |
| 9141 | name: "TLS13-DuplicateTicketEarlyDataInfo", |
| 9142 | config: Config{ |
Nick Harper | ab20cec | 2016-12-19 17:38:41 -0800 | [diff] [blame] | 9143 | MaxVersion: VersionTLS13, |
| 9144 | MaxEarlyDataSize: 16384, |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9145 | Bugs: ProtocolBugs{ |
David Benjamin | 9c33ae8 | 2017-01-08 06:04:43 -0500 | [diff] [blame] | 9146 | DuplicateTicketEarlyDataInfo: true, |
| 9147 | }, |
| 9148 | }, |
| 9149 | shouldFail: true, |
| 9150 | expectedError: ":DUPLICATE_EXTENSION:", |
| 9151 | expectedLocalError: "remote error: illegal parameter", |
| 9152 | }) |
| 9153 | |
| 9154 | testCases = append(testCases, testCase{ |
Steven Valdez | 08b65f4 | 2016-12-07 15:29:45 -0500 | [diff] [blame] | 9155 | testType: serverTest, |
| 9156 | name: "TLS13-ExpectTicketEarlyDataInfo", |
| 9157 | config: Config{ |
| 9158 | MaxVersion: VersionTLS13, |
| 9159 | Bugs: ProtocolBugs{ |
| 9160 | ExpectTicketEarlyDataInfo: true, |
| 9161 | }, |
| 9162 | }, |
| 9163 | flags: []string{ |
| 9164 | "-enable-early-data", |
| 9165 | }, |
| 9166 | }) |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9167 | |
| 9168 | // Test that, in TLS 1.3, the server-offered NewSessionTicket lifetime |
| 9169 | // is honored. |
| 9170 | testCases = append(testCases, testCase{ |
| 9171 | testType: clientTest, |
| 9172 | name: "TLS13-HonorServerSessionTicketLifetime", |
| 9173 | config: Config{ |
| 9174 | MaxVersion: VersionTLS13, |
| 9175 | Bugs: ProtocolBugs{ |
| 9176 | SendTicketLifetime: 20 * time.Second, |
| 9177 | }, |
| 9178 | }, |
| 9179 | flags: []string{ |
| 9180 | "-resumption-delay", "19", |
| 9181 | }, |
| 9182 | resumeSession: true, |
| 9183 | }) |
| 9184 | testCases = append(testCases, testCase{ |
| 9185 | testType: clientTest, |
| 9186 | name: "TLS13-HonorServerSessionTicketLifetime-2", |
| 9187 | config: Config{ |
| 9188 | MaxVersion: VersionTLS13, |
| 9189 | Bugs: ProtocolBugs{ |
| 9190 | SendTicketLifetime: 20 * time.Second, |
| 9191 | // The client should not offer the expired session. |
| 9192 | ExpectNoTLS13PSK: true, |
| 9193 | }, |
| 9194 | }, |
| 9195 | flags: []string{ |
| 9196 | "-resumption-delay", "21", |
| 9197 | }, |
David Benjamin | 023d419 | 2017-02-06 13:49:07 -0500 | [diff] [blame] | 9198 | resumeSession: true, |
David Benjamin | 17b3083 | 2017-01-28 14:00:32 -0500 | [diff] [blame] | 9199 | expectResumeRejected: true, |
| 9200 | }) |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 9201 | } |
| 9202 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9203 | func addChangeCipherSpecTests() { |
| 9204 | // Test missing ChangeCipherSpecs. |
| 9205 | testCases = append(testCases, testCase{ |
| 9206 | name: "SkipChangeCipherSpec-Client", |
| 9207 | config: Config{ |
| 9208 | MaxVersion: VersionTLS12, |
| 9209 | Bugs: ProtocolBugs{ |
| 9210 | SkipChangeCipherSpec: true, |
| 9211 | }, |
| 9212 | }, |
| 9213 | shouldFail: true, |
| 9214 | expectedError: ":UNEXPECTED_RECORD:", |
| 9215 | }) |
| 9216 | testCases = append(testCases, testCase{ |
| 9217 | testType: serverTest, |
| 9218 | name: "SkipChangeCipherSpec-Server", |
| 9219 | config: Config{ |
| 9220 | MaxVersion: VersionTLS12, |
| 9221 | Bugs: ProtocolBugs{ |
| 9222 | SkipChangeCipherSpec: true, |
| 9223 | }, |
| 9224 | }, |
| 9225 | shouldFail: true, |
| 9226 | expectedError: ":UNEXPECTED_RECORD:", |
| 9227 | }) |
| 9228 | testCases = append(testCases, testCase{ |
| 9229 | testType: serverTest, |
| 9230 | name: "SkipChangeCipherSpec-Server-NPN", |
| 9231 | config: Config{ |
| 9232 | MaxVersion: VersionTLS12, |
| 9233 | NextProtos: []string{"bar"}, |
| 9234 | Bugs: ProtocolBugs{ |
| 9235 | SkipChangeCipherSpec: true, |
| 9236 | }, |
| 9237 | }, |
| 9238 | flags: []string{ |
| 9239 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9240 | }, |
| 9241 | shouldFail: true, |
| 9242 | expectedError: ":UNEXPECTED_RECORD:", |
| 9243 | }) |
| 9244 | |
| 9245 | // Test synchronization between the handshake and ChangeCipherSpec. |
| 9246 | // Partial post-CCS handshake messages before ChangeCipherSpec should be |
| 9247 | // rejected. Test both with and without handshake packing to handle both |
| 9248 | // when the partial post-CCS message is in its own record and when it is |
| 9249 | // attached to the pre-CCS message. |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9250 | for _, packed := range []bool{false, true} { |
| 9251 | var suffix string |
| 9252 | if packed { |
| 9253 | suffix = "-Packed" |
| 9254 | } |
| 9255 | |
| 9256 | testCases = append(testCases, testCase{ |
| 9257 | name: "FragmentAcrossChangeCipherSpec-Client" + suffix, |
| 9258 | config: Config{ |
| 9259 | MaxVersion: VersionTLS12, |
| 9260 | Bugs: ProtocolBugs{ |
| 9261 | FragmentAcrossChangeCipherSpec: true, |
| 9262 | PackHandshakeFlight: packed, |
| 9263 | }, |
| 9264 | }, |
| 9265 | shouldFail: true, |
| 9266 | expectedError: ":UNEXPECTED_RECORD:", |
| 9267 | }) |
| 9268 | testCases = append(testCases, testCase{ |
| 9269 | name: "FragmentAcrossChangeCipherSpec-Client-Resume" + suffix, |
| 9270 | config: Config{ |
| 9271 | MaxVersion: VersionTLS12, |
| 9272 | }, |
| 9273 | resumeSession: true, |
| 9274 | resumeConfig: &Config{ |
| 9275 | MaxVersion: VersionTLS12, |
| 9276 | Bugs: ProtocolBugs{ |
| 9277 | FragmentAcrossChangeCipherSpec: true, |
| 9278 | PackHandshakeFlight: packed, |
| 9279 | }, |
| 9280 | }, |
| 9281 | shouldFail: true, |
| 9282 | expectedError: ":UNEXPECTED_RECORD:", |
| 9283 | }) |
| 9284 | testCases = append(testCases, testCase{ |
| 9285 | testType: serverTest, |
| 9286 | name: "FragmentAcrossChangeCipherSpec-Server" + suffix, |
| 9287 | config: Config{ |
| 9288 | MaxVersion: VersionTLS12, |
| 9289 | Bugs: ProtocolBugs{ |
| 9290 | FragmentAcrossChangeCipherSpec: true, |
| 9291 | PackHandshakeFlight: packed, |
| 9292 | }, |
| 9293 | }, |
| 9294 | shouldFail: true, |
| 9295 | expectedError: ":UNEXPECTED_RECORD:", |
| 9296 | }) |
| 9297 | testCases = append(testCases, testCase{ |
| 9298 | testType: serverTest, |
| 9299 | name: "FragmentAcrossChangeCipherSpec-Server-Resume" + suffix, |
| 9300 | config: Config{ |
| 9301 | MaxVersion: VersionTLS12, |
| 9302 | }, |
| 9303 | resumeSession: true, |
| 9304 | resumeConfig: &Config{ |
| 9305 | MaxVersion: VersionTLS12, |
| 9306 | Bugs: ProtocolBugs{ |
| 9307 | FragmentAcrossChangeCipherSpec: true, |
| 9308 | PackHandshakeFlight: packed, |
| 9309 | }, |
| 9310 | }, |
| 9311 | shouldFail: true, |
| 9312 | expectedError: ":UNEXPECTED_RECORD:", |
| 9313 | }) |
| 9314 | testCases = append(testCases, testCase{ |
| 9315 | testType: serverTest, |
| 9316 | name: "FragmentAcrossChangeCipherSpec-Server-NPN" + suffix, |
| 9317 | config: Config{ |
| 9318 | MaxVersion: VersionTLS12, |
| 9319 | NextProtos: []string{"bar"}, |
| 9320 | Bugs: ProtocolBugs{ |
| 9321 | FragmentAcrossChangeCipherSpec: true, |
| 9322 | PackHandshakeFlight: packed, |
| 9323 | }, |
| 9324 | }, |
| 9325 | flags: []string{ |
| 9326 | "-advertise-npn", "\x03foo\x03bar\x03baz", |
| 9327 | }, |
| 9328 | shouldFail: true, |
| 9329 | expectedError: ":UNEXPECTED_RECORD:", |
| 9330 | }) |
| 9331 | } |
| 9332 | |
David Benjamin | 6167281 | 2016-07-14 23:10:43 -0400 | [diff] [blame] | 9333 | // Test that, in DTLS, ChangeCipherSpec is not allowed when there are |
| 9334 | // messages in the handshake queue. Do this by testing the server |
| 9335 | // reading the client Finished, reversing the flight so Finished comes |
| 9336 | // first. |
| 9337 | testCases = append(testCases, testCase{ |
| 9338 | protocol: dtls, |
| 9339 | testType: serverTest, |
| 9340 | name: "SendUnencryptedFinished-DTLS", |
| 9341 | config: Config{ |
| 9342 | MaxVersion: VersionTLS12, |
| 9343 | Bugs: ProtocolBugs{ |
| 9344 | SendUnencryptedFinished: true, |
| 9345 | ReverseHandshakeFragments: true, |
| 9346 | }, |
| 9347 | }, |
| 9348 | shouldFail: true, |
| 9349 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9350 | }) |
| 9351 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9352 | // Test synchronization between encryption changes and the handshake in |
| 9353 | // TLS 1.3, where ChangeCipherSpec is implicit. |
| 9354 | testCases = append(testCases, testCase{ |
| 9355 | name: "PartialEncryptedExtensionsWithServerHello", |
| 9356 | config: Config{ |
| 9357 | MaxVersion: VersionTLS13, |
| 9358 | Bugs: ProtocolBugs{ |
| 9359 | PartialEncryptedExtensionsWithServerHello: true, |
| 9360 | }, |
| 9361 | }, |
| 9362 | shouldFail: true, |
| 9363 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9364 | }) |
| 9365 | testCases = append(testCases, testCase{ |
| 9366 | testType: serverTest, |
| 9367 | name: "PartialClientFinishedWithClientHello", |
| 9368 | config: Config{ |
| 9369 | MaxVersion: VersionTLS13, |
| 9370 | Bugs: ProtocolBugs{ |
| 9371 | PartialClientFinishedWithClientHello: true, |
| 9372 | }, |
| 9373 | }, |
| 9374 | shouldFail: true, |
| 9375 | expectedError: ":BUFFERED_MESSAGES_ON_CIPHER_CHANGE:", |
| 9376 | }) |
| 9377 | |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 9378 | // Test that early ChangeCipherSpecs are handled correctly. |
| 9379 | testCases = append(testCases, testCase{ |
| 9380 | testType: serverTest, |
| 9381 | name: "EarlyChangeCipherSpec-server-1", |
| 9382 | config: Config{ |
| 9383 | MaxVersion: VersionTLS12, |
| 9384 | Bugs: ProtocolBugs{ |
| 9385 | EarlyChangeCipherSpec: 1, |
| 9386 | }, |
| 9387 | }, |
| 9388 | shouldFail: true, |
| 9389 | expectedError: ":UNEXPECTED_RECORD:", |
| 9390 | }) |
| 9391 | testCases = append(testCases, testCase{ |
| 9392 | testType: serverTest, |
| 9393 | name: "EarlyChangeCipherSpec-server-2", |
| 9394 | config: Config{ |
| 9395 | MaxVersion: VersionTLS12, |
| 9396 | Bugs: ProtocolBugs{ |
| 9397 | EarlyChangeCipherSpec: 2, |
| 9398 | }, |
| 9399 | }, |
| 9400 | shouldFail: true, |
| 9401 | expectedError: ":UNEXPECTED_RECORD:", |
| 9402 | }) |
| 9403 | testCases = append(testCases, testCase{ |
| 9404 | protocol: dtls, |
| 9405 | name: "StrayChangeCipherSpec", |
| 9406 | config: Config{ |
| 9407 | // TODO(davidben): Once DTLS 1.3 exists, test |
| 9408 | // that stray ChangeCipherSpec messages are |
| 9409 | // rejected. |
| 9410 | MaxVersion: VersionTLS12, |
| 9411 | Bugs: ProtocolBugs{ |
| 9412 | StrayChangeCipherSpec: true, |
| 9413 | }, |
| 9414 | }, |
| 9415 | }) |
| 9416 | |
| 9417 | // Test that the contents of ChangeCipherSpec are checked. |
| 9418 | testCases = append(testCases, testCase{ |
| 9419 | name: "BadChangeCipherSpec-1", |
| 9420 | config: Config{ |
| 9421 | MaxVersion: VersionTLS12, |
| 9422 | Bugs: ProtocolBugs{ |
| 9423 | BadChangeCipherSpec: []byte{2}, |
| 9424 | }, |
| 9425 | }, |
| 9426 | shouldFail: true, |
| 9427 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9428 | }) |
| 9429 | testCases = append(testCases, testCase{ |
| 9430 | name: "BadChangeCipherSpec-2", |
| 9431 | config: Config{ |
| 9432 | MaxVersion: VersionTLS12, |
| 9433 | Bugs: ProtocolBugs{ |
| 9434 | BadChangeCipherSpec: []byte{1, 1}, |
| 9435 | }, |
| 9436 | }, |
| 9437 | shouldFail: true, |
| 9438 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9439 | }) |
| 9440 | testCases = append(testCases, testCase{ |
| 9441 | protocol: dtls, |
| 9442 | name: "BadChangeCipherSpec-DTLS-1", |
| 9443 | config: Config{ |
| 9444 | MaxVersion: VersionTLS12, |
| 9445 | Bugs: ProtocolBugs{ |
| 9446 | BadChangeCipherSpec: []byte{2}, |
| 9447 | }, |
| 9448 | }, |
| 9449 | shouldFail: true, |
| 9450 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9451 | }) |
| 9452 | testCases = append(testCases, testCase{ |
| 9453 | protocol: dtls, |
| 9454 | name: "BadChangeCipherSpec-DTLS-2", |
| 9455 | config: Config{ |
| 9456 | MaxVersion: VersionTLS12, |
| 9457 | Bugs: ProtocolBugs{ |
| 9458 | BadChangeCipherSpec: []byte{1, 1}, |
| 9459 | }, |
| 9460 | }, |
| 9461 | shouldFail: true, |
| 9462 | expectedError: ":BAD_CHANGE_CIPHER_SPEC:", |
| 9463 | }) |
| 9464 | } |
| 9465 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9466 | type perMessageTest struct { |
| 9467 | messageType uint8 |
| 9468 | test testCase |
| 9469 | } |
| 9470 | |
| 9471 | // makePerMessageTests returns a series of test templates which cover each |
| 9472 | // message in the TLS handshake. These may be used with bugs like |
| 9473 | // WrongMessageType to fully test a per-message bug. |
| 9474 | func makePerMessageTests() []perMessageTest { |
| 9475 | var ret []perMessageTest |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9476 | for _, protocol := range []protocol{tls, dtls} { |
| 9477 | var suffix string |
| 9478 | if protocol == dtls { |
| 9479 | suffix = "-DTLS" |
| 9480 | } |
| 9481 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9482 | ret = append(ret, perMessageTest{ |
| 9483 | messageType: typeClientHello, |
| 9484 | test: testCase{ |
| 9485 | protocol: protocol, |
| 9486 | testType: serverTest, |
| 9487 | name: "ClientHello" + suffix, |
| 9488 | config: Config{ |
| 9489 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9490 | }, |
| 9491 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9492 | }) |
| 9493 | |
| 9494 | if protocol == dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9495 | ret = append(ret, perMessageTest{ |
| 9496 | messageType: typeHelloVerifyRequest, |
| 9497 | test: testCase{ |
| 9498 | protocol: protocol, |
| 9499 | name: "HelloVerifyRequest" + suffix, |
| 9500 | config: Config{ |
| 9501 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9502 | }, |
| 9503 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9504 | }) |
| 9505 | } |
| 9506 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9507 | ret = append(ret, perMessageTest{ |
| 9508 | messageType: typeServerHello, |
| 9509 | test: testCase{ |
| 9510 | protocol: protocol, |
| 9511 | name: "ServerHello" + suffix, |
| 9512 | config: Config{ |
| 9513 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9514 | }, |
| 9515 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9516 | }) |
| 9517 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9518 | ret = append(ret, perMessageTest{ |
| 9519 | messageType: typeCertificate, |
| 9520 | test: testCase{ |
| 9521 | protocol: protocol, |
| 9522 | name: "ServerCertificate" + suffix, |
| 9523 | config: Config{ |
| 9524 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9525 | }, |
| 9526 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9527 | }) |
| 9528 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9529 | ret = append(ret, perMessageTest{ |
| 9530 | messageType: typeCertificateStatus, |
| 9531 | test: testCase{ |
| 9532 | protocol: protocol, |
| 9533 | name: "CertificateStatus" + suffix, |
| 9534 | config: Config{ |
| 9535 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9536 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9537 | flags: []string{"-enable-ocsp-stapling"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9538 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9539 | }) |
| 9540 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9541 | ret = append(ret, perMessageTest{ |
| 9542 | messageType: typeServerKeyExchange, |
| 9543 | test: testCase{ |
| 9544 | protocol: protocol, |
| 9545 | name: "ServerKeyExchange" + suffix, |
| 9546 | config: Config{ |
| 9547 | MaxVersion: VersionTLS12, |
| 9548 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9549 | }, |
| 9550 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9551 | }) |
| 9552 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9553 | ret = append(ret, perMessageTest{ |
| 9554 | messageType: typeCertificateRequest, |
| 9555 | test: testCase{ |
| 9556 | protocol: protocol, |
| 9557 | name: "CertificateRequest" + suffix, |
| 9558 | config: Config{ |
| 9559 | MaxVersion: VersionTLS12, |
| 9560 | ClientAuth: RequireAnyClientCert, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9561 | }, |
| 9562 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9563 | }) |
| 9564 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9565 | ret = append(ret, perMessageTest{ |
| 9566 | messageType: typeServerHelloDone, |
| 9567 | test: testCase{ |
| 9568 | protocol: protocol, |
| 9569 | name: "ServerHelloDone" + suffix, |
| 9570 | config: Config{ |
| 9571 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9572 | }, |
| 9573 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9574 | }) |
| 9575 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9576 | ret = append(ret, perMessageTest{ |
| 9577 | messageType: typeCertificate, |
| 9578 | test: testCase{ |
| 9579 | testType: serverTest, |
| 9580 | protocol: protocol, |
| 9581 | name: "ClientCertificate" + suffix, |
| 9582 | config: Config{ |
| 9583 | Certificates: []Certificate{rsaCertificate}, |
| 9584 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9585 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9586 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9587 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9588 | }) |
| 9589 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9590 | ret = append(ret, perMessageTest{ |
| 9591 | messageType: typeCertificateVerify, |
| 9592 | test: testCase{ |
| 9593 | testType: serverTest, |
| 9594 | protocol: protocol, |
| 9595 | name: "CertificateVerify" + suffix, |
| 9596 | config: Config{ |
| 9597 | Certificates: []Certificate{rsaCertificate}, |
| 9598 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9599 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9600 | flags: []string{"-require-any-client-certificate"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9601 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9602 | }) |
| 9603 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9604 | ret = append(ret, perMessageTest{ |
| 9605 | messageType: typeClientKeyExchange, |
| 9606 | test: testCase{ |
| 9607 | testType: serverTest, |
| 9608 | protocol: protocol, |
| 9609 | name: "ClientKeyExchange" + suffix, |
| 9610 | config: Config{ |
| 9611 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9612 | }, |
| 9613 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9614 | }) |
| 9615 | |
| 9616 | if protocol != dtls { |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9617 | ret = append(ret, perMessageTest{ |
| 9618 | messageType: typeNextProtocol, |
| 9619 | test: testCase{ |
| 9620 | testType: serverTest, |
| 9621 | protocol: protocol, |
| 9622 | name: "NextProtocol" + suffix, |
| 9623 | config: Config{ |
| 9624 | MaxVersion: VersionTLS12, |
| 9625 | NextProtos: []string{"bar"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9626 | }, |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9627 | flags: []string{"-advertise-npn", "\x03foo\x03bar\x03baz"}, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9628 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9629 | }) |
| 9630 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9631 | ret = append(ret, perMessageTest{ |
| 9632 | messageType: typeChannelID, |
| 9633 | test: testCase{ |
| 9634 | testType: serverTest, |
| 9635 | protocol: protocol, |
| 9636 | name: "ChannelID" + suffix, |
| 9637 | config: Config{ |
| 9638 | MaxVersion: VersionTLS12, |
| 9639 | ChannelID: channelIDKey, |
| 9640 | }, |
| 9641 | flags: []string{ |
| 9642 | "-expect-channel-id", |
| 9643 | base64.StdEncoding.EncodeToString(channelIDBytes), |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9644 | }, |
| 9645 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9646 | }) |
| 9647 | } |
| 9648 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9649 | ret = append(ret, perMessageTest{ |
| 9650 | messageType: typeFinished, |
| 9651 | test: testCase{ |
| 9652 | testType: serverTest, |
| 9653 | protocol: protocol, |
| 9654 | name: "ClientFinished" + suffix, |
| 9655 | config: Config{ |
| 9656 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9657 | }, |
| 9658 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9659 | }) |
| 9660 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9661 | ret = append(ret, perMessageTest{ |
| 9662 | messageType: typeNewSessionTicket, |
| 9663 | test: testCase{ |
| 9664 | protocol: protocol, |
| 9665 | name: "NewSessionTicket" + suffix, |
| 9666 | config: Config{ |
| 9667 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9668 | }, |
| 9669 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9670 | }) |
| 9671 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9672 | ret = append(ret, perMessageTest{ |
| 9673 | messageType: typeFinished, |
| 9674 | test: testCase{ |
| 9675 | protocol: protocol, |
| 9676 | name: "ServerFinished" + suffix, |
| 9677 | config: Config{ |
| 9678 | MaxVersion: VersionTLS12, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9679 | }, |
| 9680 | }, |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9681 | }) |
| 9682 | |
| 9683 | } |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9684 | |
| 9685 | ret = append(ret, perMessageTest{ |
| 9686 | messageType: typeClientHello, |
| 9687 | test: testCase{ |
| 9688 | testType: serverTest, |
| 9689 | name: "TLS13-ClientHello", |
| 9690 | config: Config{ |
| 9691 | MaxVersion: VersionTLS13, |
| 9692 | }, |
| 9693 | }, |
| 9694 | }) |
| 9695 | |
| 9696 | ret = append(ret, perMessageTest{ |
| 9697 | messageType: typeServerHello, |
| 9698 | test: testCase{ |
| 9699 | name: "TLS13-ServerHello", |
| 9700 | config: Config{ |
| 9701 | MaxVersion: VersionTLS13, |
| 9702 | }, |
| 9703 | }, |
| 9704 | }) |
| 9705 | |
| 9706 | ret = append(ret, perMessageTest{ |
| 9707 | messageType: typeEncryptedExtensions, |
| 9708 | test: testCase{ |
| 9709 | name: "TLS13-EncryptedExtensions", |
| 9710 | config: Config{ |
| 9711 | MaxVersion: VersionTLS13, |
| 9712 | }, |
| 9713 | }, |
| 9714 | }) |
| 9715 | |
| 9716 | ret = append(ret, perMessageTest{ |
| 9717 | messageType: typeCertificateRequest, |
| 9718 | test: testCase{ |
| 9719 | name: "TLS13-CertificateRequest", |
| 9720 | config: Config{ |
| 9721 | MaxVersion: VersionTLS13, |
| 9722 | ClientAuth: RequireAnyClientCert, |
| 9723 | }, |
| 9724 | }, |
| 9725 | }) |
| 9726 | |
| 9727 | ret = append(ret, perMessageTest{ |
| 9728 | messageType: typeCertificate, |
| 9729 | test: testCase{ |
| 9730 | name: "TLS13-ServerCertificate", |
| 9731 | config: Config{ |
| 9732 | MaxVersion: VersionTLS13, |
| 9733 | }, |
| 9734 | }, |
| 9735 | }) |
| 9736 | |
| 9737 | ret = append(ret, perMessageTest{ |
| 9738 | messageType: typeCertificateVerify, |
| 9739 | test: testCase{ |
| 9740 | name: "TLS13-ServerCertificateVerify", |
| 9741 | config: Config{ |
| 9742 | MaxVersion: VersionTLS13, |
| 9743 | }, |
| 9744 | }, |
| 9745 | }) |
| 9746 | |
| 9747 | ret = append(ret, perMessageTest{ |
| 9748 | messageType: typeFinished, |
| 9749 | test: testCase{ |
| 9750 | name: "TLS13-ServerFinished", |
| 9751 | config: Config{ |
| 9752 | MaxVersion: VersionTLS13, |
| 9753 | }, |
| 9754 | }, |
| 9755 | }) |
| 9756 | |
| 9757 | ret = append(ret, perMessageTest{ |
| 9758 | messageType: typeCertificate, |
| 9759 | test: testCase{ |
| 9760 | testType: serverTest, |
| 9761 | name: "TLS13-ClientCertificate", |
| 9762 | config: Config{ |
| 9763 | Certificates: []Certificate{rsaCertificate}, |
| 9764 | MaxVersion: VersionTLS13, |
| 9765 | }, |
| 9766 | flags: []string{"-require-any-client-certificate"}, |
| 9767 | }, |
| 9768 | }) |
| 9769 | |
| 9770 | ret = append(ret, perMessageTest{ |
| 9771 | messageType: typeCertificateVerify, |
| 9772 | test: testCase{ |
| 9773 | testType: serverTest, |
| 9774 | name: "TLS13-ClientCertificateVerify", |
| 9775 | config: Config{ |
| 9776 | Certificates: []Certificate{rsaCertificate}, |
| 9777 | MaxVersion: VersionTLS13, |
| 9778 | }, |
| 9779 | flags: []string{"-require-any-client-certificate"}, |
| 9780 | }, |
| 9781 | }) |
| 9782 | |
| 9783 | ret = append(ret, perMessageTest{ |
| 9784 | messageType: typeFinished, |
| 9785 | test: testCase{ |
| 9786 | testType: serverTest, |
| 9787 | name: "TLS13-ClientFinished", |
| 9788 | config: Config{ |
| 9789 | MaxVersion: VersionTLS13, |
| 9790 | }, |
| 9791 | }, |
| 9792 | }) |
| 9793 | |
| 9794 | return ret |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 9795 | } |
| 9796 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9797 | func addWrongMessageTypeTests() { |
| 9798 | for _, t := range makePerMessageTests() { |
| 9799 | t.test.name = "WrongMessageType-" + t.test.name |
| 9800 | t.test.config.Bugs.SendWrongMessageType = t.messageType |
| 9801 | t.test.shouldFail = true |
| 9802 | t.test.expectedError = ":UNEXPECTED_MESSAGE:" |
| 9803 | t.test.expectedLocalError = "remote error: unexpected message" |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9804 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9805 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9806 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9807 | // an unencrypted alert while the server expects |
| 9808 | // encryption, so the alert is not readable by runner. |
| 9809 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9810 | } |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9811 | |
David Benjamin | cd2c806 | 2016-09-09 11:28:16 -0400 | [diff] [blame] | 9812 | testCases = append(testCases, t.test) |
| 9813 | } |
David Benjamin | ebacdee | 2017-04-08 11:00:45 -0400 | [diff] [blame] | 9814 | |
| 9815 | // The processing order for TLS 1.3 version negotiation is such that one |
| 9816 | // may accidentally accept a HelloRetryRequest in lieu of ServerHello in |
| 9817 | // TLS 1.2. Test that we do not do this. |
| 9818 | testCases = append(testCases, testCase{ |
| 9819 | name: "SendServerHelloAsHelloRetryRequest", |
| 9820 | config: Config{ |
| 9821 | MaxVersion: VersionTLS12, |
| 9822 | Bugs: ProtocolBugs{ |
| 9823 | SendServerHelloAsHelloRetryRequest: true, |
| 9824 | }, |
| 9825 | }, |
| 9826 | shouldFail: true, |
| 9827 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 9828 | expectedLocalError: "remote error: unexpected message", |
| 9829 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9830 | } |
| 9831 | |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 9832 | func addTrailingMessageDataTests() { |
| 9833 | for _, t := range makePerMessageTests() { |
| 9834 | t.test.name = "TrailingMessageData-" + t.test.name |
| 9835 | t.test.config.Bugs.SendTrailingMessageData = t.messageType |
| 9836 | t.test.shouldFail = true |
| 9837 | t.test.expectedError = ":DECODE_ERROR:" |
| 9838 | t.test.expectedLocalError = "remote error: error decoding message" |
| 9839 | |
| 9840 | if t.test.config.MaxVersion >= VersionTLS13 && t.messageType == typeServerHello { |
| 9841 | // In TLS 1.3, a bad ServerHello means the client sends |
| 9842 | // an unencrypted alert while the server expects |
| 9843 | // encryption, so the alert is not readable by runner. |
| 9844 | t.test.expectedLocalError = "local error: bad record MAC" |
| 9845 | } |
| 9846 | |
| 9847 | if t.messageType == typeFinished { |
| 9848 | // Bad Finished messages read as the verify data having |
| 9849 | // the wrong length. |
| 9850 | t.test.expectedError = ":DIGEST_CHECK_FAILED:" |
| 9851 | t.test.expectedLocalError = "remote error: error decrypting message" |
| 9852 | } |
| 9853 | |
| 9854 | testCases = append(testCases, t.test) |
| 9855 | } |
| 9856 | } |
| 9857 | |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9858 | func addTLS13HandshakeTests() { |
| 9859 | testCases = append(testCases, testCase{ |
| 9860 | testType: clientTest, |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9861 | name: "NegotiatePSKResumption-TLS13", |
| 9862 | config: Config{ |
| 9863 | MaxVersion: VersionTLS13, |
| 9864 | Bugs: ProtocolBugs{ |
| 9865 | NegotiatePSKResumption: true, |
| 9866 | }, |
| 9867 | }, |
| 9868 | resumeSession: true, |
| 9869 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9870 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 803c77a | 2016-09-06 14:13:43 -0400 | [diff] [blame] | 9871 | }) |
| 9872 | |
| 9873 | testCases = append(testCases, testCase{ |
| 9874 | testType: clientTest, |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9875 | name: "MissingKeyShare-Client", |
| 9876 | config: Config{ |
| 9877 | MaxVersion: VersionTLS13, |
| 9878 | Bugs: ProtocolBugs{ |
| 9879 | MissingKeyShare: true, |
| 9880 | }, |
| 9881 | }, |
| 9882 | shouldFail: true, |
David Benjamin | db5bd72 | 2016-12-08 18:21:27 -0500 | [diff] [blame] | 9883 | expectedError: ":MISSING_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9884 | }) |
| 9885 | |
| 9886 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 9887 | testType: serverTest, |
| 9888 | name: "MissingKeyShare-Server", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9889 | config: Config{ |
| 9890 | MaxVersion: VersionTLS13, |
| 9891 | Bugs: ProtocolBugs{ |
| 9892 | MissingKeyShare: true, |
| 9893 | }, |
| 9894 | }, |
| 9895 | shouldFail: true, |
| 9896 | expectedError: ":MISSING_KEY_SHARE:", |
| 9897 | }) |
| 9898 | |
| 9899 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9900 | testType: serverTest, |
| 9901 | name: "DuplicateKeyShares", |
| 9902 | config: Config{ |
| 9903 | MaxVersion: VersionTLS13, |
| 9904 | Bugs: ProtocolBugs{ |
| 9905 | DuplicateKeyShares: true, |
| 9906 | }, |
| 9907 | }, |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 9908 | shouldFail: true, |
| 9909 | expectedError: ":DUPLICATE_KEY_SHARE:", |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 9910 | }) |
| 9911 | |
| 9912 | testCases = append(testCases, testCase{ |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9913 | testType: serverTest, |
| 9914 | name: "SkipEarlyData", |
| 9915 | config: Config{ |
| 9916 | MaxVersion: VersionTLS13, |
| 9917 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9918 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9919 | }, |
| 9920 | }, |
| 9921 | }) |
| 9922 | |
| 9923 | testCases = append(testCases, testCase{ |
| 9924 | testType: serverTest, |
| 9925 | name: "SkipEarlyData-OmitEarlyDataExtension", |
| 9926 | config: Config{ |
| 9927 | MaxVersion: VersionTLS13, |
| 9928 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9929 | SendFakeEarlyDataLength: 4, |
| 9930 | OmitEarlyDataExtension: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9931 | }, |
| 9932 | }, |
| 9933 | shouldFail: true, |
| 9934 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9935 | }) |
| 9936 | |
| 9937 | testCases = append(testCases, testCase{ |
| 9938 | testType: serverTest, |
| 9939 | name: "SkipEarlyData-TooMuchData", |
| 9940 | config: Config{ |
| 9941 | MaxVersion: VersionTLS13, |
| 9942 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9943 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9944 | }, |
| 9945 | }, |
| 9946 | shouldFail: true, |
| 9947 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 9948 | }) |
| 9949 | |
| 9950 | testCases = append(testCases, testCase{ |
| 9951 | testType: serverTest, |
| 9952 | name: "SkipEarlyData-Interleaved", |
| 9953 | config: Config{ |
| 9954 | MaxVersion: VersionTLS13, |
| 9955 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9956 | SendFakeEarlyDataLength: 4, |
| 9957 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9958 | }, |
| 9959 | }, |
| 9960 | shouldFail: true, |
| 9961 | expectedError: ":DECRYPTION_FAILED_OR_BAD_RECORD_MAC:", |
| 9962 | }) |
| 9963 | |
| 9964 | testCases = append(testCases, testCase{ |
| 9965 | testType: serverTest, |
| 9966 | name: "SkipEarlyData-EarlyDataInTLS12", |
| 9967 | config: Config{ |
| 9968 | MaxVersion: VersionTLS13, |
| 9969 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9970 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9971 | }, |
| 9972 | }, |
| 9973 | shouldFail: true, |
| 9974 | expectedError: ":UNEXPECTED_RECORD:", |
| 9975 | flags: []string{"-max-version", strconv.Itoa(VersionTLS12)}, |
| 9976 | }) |
| 9977 | |
| 9978 | testCases = append(testCases, testCase{ |
| 9979 | testType: serverTest, |
| 9980 | name: "SkipEarlyData-HRR", |
| 9981 | config: Config{ |
| 9982 | MaxVersion: VersionTLS13, |
| 9983 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9984 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9985 | }, |
| 9986 | DefaultCurves: []CurveID{}, |
| 9987 | }, |
| 9988 | }) |
| 9989 | |
| 9990 | testCases = append(testCases, testCase{ |
| 9991 | testType: serverTest, |
| 9992 | name: "SkipEarlyData-HRR-Interleaved", |
| 9993 | config: Config{ |
| 9994 | MaxVersion: VersionTLS13, |
| 9995 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 9996 | SendFakeEarlyDataLength: 4, |
| 9997 | InterleaveEarlyData: true, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 9998 | }, |
| 9999 | DefaultCurves: []CurveID{}, |
| 10000 | }, |
| 10001 | shouldFail: true, |
| 10002 | expectedError: ":UNEXPECTED_RECORD:", |
| 10003 | }) |
| 10004 | |
| 10005 | testCases = append(testCases, testCase{ |
| 10006 | testType: serverTest, |
| 10007 | name: "SkipEarlyData-HRR-TooMuchData", |
| 10008 | config: Config{ |
| 10009 | MaxVersion: VersionTLS13, |
| 10010 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10011 | SendFakeEarlyDataLength: 16384 + 1, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10012 | }, |
| 10013 | DefaultCurves: []CurveID{}, |
| 10014 | }, |
| 10015 | shouldFail: true, |
| 10016 | expectedError: ":TOO_MUCH_SKIPPED_EARLY_DATA:", |
| 10017 | }) |
| 10018 | |
| 10019 | // Test that skipping early data looking for cleartext correctly |
| 10020 | // processes an alert record. |
| 10021 | testCases = append(testCases, testCase{ |
| 10022 | testType: serverTest, |
| 10023 | name: "SkipEarlyData-HRR-FatalAlert", |
| 10024 | config: Config{ |
| 10025 | MaxVersion: VersionTLS13, |
| 10026 | Bugs: ProtocolBugs{ |
Nick Harper | f2511f1 | 2016-12-06 16:02:31 -0800 | [diff] [blame] | 10027 | SendEarlyAlert: true, |
| 10028 | SendFakeEarlyDataLength: 4, |
Steven Valdez | a4ee74d | 2016-11-29 13:36:45 -0500 | [diff] [blame] | 10029 | }, |
| 10030 | DefaultCurves: []CurveID{}, |
| 10031 | }, |
| 10032 | shouldFail: true, |
| 10033 | expectedError: ":SSLV3_ALERT_HANDSHAKE_FAILURE:", |
| 10034 | }) |
| 10035 | |
| 10036 | testCases = append(testCases, testCase{ |
| 10037 | testType: serverTest, |
| 10038 | name: "SkipEarlyData-SecondClientHelloEarlyData", |
| 10039 | config: Config{ |
| 10040 | MaxVersion: VersionTLS13, |
| 10041 | Bugs: ProtocolBugs{ |
| 10042 | SendEarlyDataOnSecondClientHello: true, |
| 10043 | }, |
| 10044 | DefaultCurves: []CurveID{}, |
| 10045 | }, |
| 10046 | shouldFail: true, |
| 10047 | expectedLocalError: "remote error: bad record MAC", |
| 10048 | }) |
| 10049 | |
| 10050 | testCases = append(testCases, testCase{ |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10051 | testType: clientTest, |
| 10052 | name: "EmptyEncryptedExtensions", |
| 10053 | config: Config{ |
| 10054 | MaxVersion: VersionTLS13, |
| 10055 | Bugs: ProtocolBugs{ |
| 10056 | EmptyEncryptedExtensions: true, |
| 10057 | }, |
| 10058 | }, |
| 10059 | shouldFail: true, |
| 10060 | expectedLocalError: "remote error: error decoding message", |
| 10061 | }) |
| 10062 | |
| 10063 | testCases = append(testCases, testCase{ |
| 10064 | testType: clientTest, |
| 10065 | name: "EncryptedExtensionsWithKeyShare", |
| 10066 | config: Config{ |
| 10067 | MaxVersion: VersionTLS13, |
| 10068 | Bugs: ProtocolBugs{ |
| 10069 | EncryptedExtensionsWithKeyShare: true, |
| 10070 | }, |
| 10071 | }, |
| 10072 | shouldFail: true, |
| 10073 | expectedLocalError: "remote error: unsupported extension", |
| 10074 | }) |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10075 | |
| 10076 | testCases = append(testCases, testCase{ |
| 10077 | testType: serverTest, |
| 10078 | name: "SendHelloRetryRequest", |
| 10079 | config: Config{ |
| 10080 | MaxVersion: VersionTLS13, |
| 10081 | // Require a HelloRetryRequest for every curve. |
| 10082 | DefaultCurves: []CurveID{}, |
| 10083 | }, |
| 10084 | expectedCurveID: CurveX25519, |
| 10085 | }) |
| 10086 | |
| 10087 | testCases = append(testCases, testCase{ |
| 10088 | testType: serverTest, |
| 10089 | name: "SendHelloRetryRequest-2", |
| 10090 | config: Config{ |
| 10091 | MaxVersion: VersionTLS13, |
| 10092 | DefaultCurves: []CurveID{CurveP384}, |
| 10093 | }, |
| 10094 | // Although the ClientHello did not predict our preferred curve, |
| 10095 | // we always select it whether it is predicted or not. |
| 10096 | expectedCurveID: CurveX25519, |
| 10097 | }) |
| 10098 | |
| 10099 | testCases = append(testCases, testCase{ |
| 10100 | name: "UnknownCurve-HelloRetryRequest", |
| 10101 | config: Config{ |
| 10102 | MaxVersion: VersionTLS13, |
| 10103 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10104 | CurvePreferences: []CurveID{CurveP384}, |
| 10105 | Bugs: ProtocolBugs{ |
| 10106 | SendHelloRetryRequestCurve: bogusCurve, |
| 10107 | }, |
| 10108 | }, |
| 10109 | shouldFail: true, |
| 10110 | expectedError: ":WRONG_CURVE:", |
| 10111 | }) |
| 10112 | |
| 10113 | testCases = append(testCases, testCase{ |
| 10114 | name: "DisabledCurve-HelloRetryRequest", |
| 10115 | config: Config{ |
| 10116 | MaxVersion: VersionTLS13, |
| 10117 | CurvePreferences: []CurveID{CurveP256}, |
| 10118 | Bugs: ProtocolBugs{ |
| 10119 | IgnorePeerCurvePreferences: true, |
| 10120 | }, |
| 10121 | }, |
| 10122 | flags: []string{"-p384-only"}, |
| 10123 | shouldFail: true, |
| 10124 | expectedError: ":WRONG_CURVE:", |
| 10125 | }) |
| 10126 | |
| 10127 | testCases = append(testCases, testCase{ |
| 10128 | name: "UnnecessaryHelloRetryRequest", |
| 10129 | config: Config{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10130 | MaxVersion: VersionTLS13, |
| 10131 | CurvePreferences: []CurveID{CurveX25519}, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10132 | Bugs: ProtocolBugs{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10133 | SendHelloRetryRequestCurve: CurveX25519, |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10134 | }, |
| 10135 | }, |
| 10136 | shouldFail: true, |
| 10137 | expectedError: ":WRONG_CURVE:", |
| 10138 | }) |
| 10139 | |
| 10140 | testCases = append(testCases, testCase{ |
| 10141 | name: "SecondHelloRetryRequest", |
| 10142 | config: Config{ |
| 10143 | MaxVersion: VersionTLS13, |
| 10144 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10145 | CurvePreferences: []CurveID{CurveP384}, |
| 10146 | Bugs: ProtocolBugs{ |
| 10147 | SecondHelloRetryRequest: true, |
| 10148 | }, |
| 10149 | }, |
| 10150 | shouldFail: true, |
| 10151 | expectedError: ":UNEXPECTED_MESSAGE:", |
| 10152 | }) |
| 10153 | |
| 10154 | testCases = append(testCases, testCase{ |
David Benjamin | 3baa6e1 | 2016-10-07 21:10:38 -0400 | [diff] [blame] | 10155 | name: "HelloRetryRequest-Empty", |
| 10156 | config: Config{ |
| 10157 | MaxVersion: VersionTLS13, |
| 10158 | Bugs: ProtocolBugs{ |
| 10159 | AlwaysSendHelloRetryRequest: true, |
| 10160 | }, |
| 10161 | }, |
| 10162 | shouldFail: true, |
| 10163 | expectedError: ":DECODE_ERROR:", |
| 10164 | }) |
| 10165 | |
| 10166 | testCases = append(testCases, testCase{ |
| 10167 | name: "HelloRetryRequest-DuplicateCurve", |
| 10168 | config: Config{ |
| 10169 | MaxVersion: VersionTLS13, |
| 10170 | // P-384 requires a HelloRetryRequest against BoringSSL's default |
| 10171 | // configuration. Assert this ExpectMissingKeyShare. |
| 10172 | CurvePreferences: []CurveID{CurveP384}, |
| 10173 | Bugs: ProtocolBugs{ |
| 10174 | ExpectMissingKeyShare: true, |
| 10175 | DuplicateHelloRetryRequestExtensions: true, |
| 10176 | }, |
| 10177 | }, |
| 10178 | shouldFail: true, |
| 10179 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10180 | expectedLocalError: "remote error: illegal parameter", |
| 10181 | }) |
| 10182 | |
| 10183 | testCases = append(testCases, testCase{ |
| 10184 | name: "HelloRetryRequest-Cookie", |
| 10185 | config: Config{ |
| 10186 | MaxVersion: VersionTLS13, |
| 10187 | Bugs: ProtocolBugs{ |
| 10188 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10189 | }, |
| 10190 | }, |
| 10191 | }) |
| 10192 | |
| 10193 | testCases = append(testCases, testCase{ |
| 10194 | name: "HelloRetryRequest-DuplicateCookie", |
| 10195 | config: Config{ |
| 10196 | MaxVersion: VersionTLS13, |
| 10197 | Bugs: ProtocolBugs{ |
| 10198 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10199 | DuplicateHelloRetryRequestExtensions: true, |
| 10200 | }, |
| 10201 | }, |
| 10202 | shouldFail: true, |
| 10203 | expectedError: ":DUPLICATE_EXTENSION:", |
| 10204 | expectedLocalError: "remote error: illegal parameter", |
| 10205 | }) |
| 10206 | |
| 10207 | testCases = append(testCases, testCase{ |
| 10208 | name: "HelloRetryRequest-EmptyCookie", |
| 10209 | config: Config{ |
| 10210 | MaxVersion: VersionTLS13, |
| 10211 | Bugs: ProtocolBugs{ |
| 10212 | SendHelloRetryRequestCookie: []byte{}, |
| 10213 | }, |
| 10214 | }, |
| 10215 | shouldFail: true, |
| 10216 | expectedError: ":DECODE_ERROR:", |
| 10217 | }) |
| 10218 | |
| 10219 | testCases = append(testCases, testCase{ |
| 10220 | name: "HelloRetryRequest-Cookie-Curve", |
| 10221 | config: Config{ |
| 10222 | MaxVersion: VersionTLS13, |
| 10223 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10224 | CurvePreferences: []CurveID{CurveP384}, |
| 10225 | Bugs: ProtocolBugs{ |
| 10226 | SendHelloRetryRequestCookie: []byte("cookie"), |
| 10227 | ExpectMissingKeyShare: true, |
| 10228 | }, |
| 10229 | }, |
| 10230 | }) |
| 10231 | |
| 10232 | testCases = append(testCases, testCase{ |
| 10233 | name: "HelloRetryRequest-Unknown", |
| 10234 | config: Config{ |
| 10235 | MaxVersion: VersionTLS13, |
| 10236 | Bugs: ProtocolBugs{ |
| 10237 | CustomHelloRetryRequestExtension: "extension", |
| 10238 | }, |
| 10239 | }, |
| 10240 | shouldFail: true, |
| 10241 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10242 | expectedLocalError: "remote error: unsupported extension", |
| 10243 | }) |
| 10244 | |
| 10245 | testCases = append(testCases, testCase{ |
Steven Valdez | 5440fe0 | 2016-07-18 12:40:30 -0400 | [diff] [blame] | 10246 | testType: serverTest, |
| 10247 | name: "SecondClientHelloMissingKeyShare", |
| 10248 | config: Config{ |
| 10249 | MaxVersion: VersionTLS13, |
| 10250 | DefaultCurves: []CurveID{}, |
| 10251 | Bugs: ProtocolBugs{ |
| 10252 | SecondClientHelloMissingKeyShare: true, |
| 10253 | }, |
| 10254 | }, |
| 10255 | shouldFail: true, |
| 10256 | expectedError: ":MISSING_KEY_SHARE:", |
| 10257 | }) |
| 10258 | |
| 10259 | testCases = append(testCases, testCase{ |
| 10260 | testType: serverTest, |
| 10261 | name: "SecondClientHelloWrongCurve", |
| 10262 | config: Config{ |
| 10263 | MaxVersion: VersionTLS13, |
| 10264 | DefaultCurves: []CurveID{}, |
| 10265 | Bugs: ProtocolBugs{ |
| 10266 | MisinterpretHelloRetryRequestCurve: CurveP521, |
| 10267 | }, |
| 10268 | }, |
| 10269 | shouldFail: true, |
| 10270 | expectedError: ":WRONG_CURVE:", |
| 10271 | }) |
| 10272 | |
| 10273 | testCases = append(testCases, testCase{ |
| 10274 | name: "HelloRetryRequestVersionMismatch", |
| 10275 | config: Config{ |
| 10276 | MaxVersion: VersionTLS13, |
| 10277 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10278 | CurvePreferences: []CurveID{CurveP384}, |
| 10279 | Bugs: ProtocolBugs{ |
| 10280 | SendServerHelloVersion: 0x0305, |
| 10281 | }, |
| 10282 | }, |
| 10283 | shouldFail: true, |
| 10284 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 10285 | }) |
| 10286 | |
| 10287 | testCases = append(testCases, testCase{ |
| 10288 | name: "HelloRetryRequestCurveMismatch", |
| 10289 | config: Config{ |
| 10290 | MaxVersion: VersionTLS13, |
| 10291 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10292 | CurvePreferences: []CurveID{CurveP384}, |
| 10293 | Bugs: ProtocolBugs{ |
| 10294 | // Send P-384 (correct) in the HelloRetryRequest. |
| 10295 | SendHelloRetryRequestCurve: CurveP384, |
| 10296 | // But send P-256 in the ServerHello. |
| 10297 | SendCurve: CurveP256, |
| 10298 | }, |
| 10299 | }, |
| 10300 | shouldFail: true, |
| 10301 | expectedError: ":WRONG_CURVE:", |
| 10302 | }) |
| 10303 | |
| 10304 | // Test the server selecting a curve that requires a HelloRetryRequest |
| 10305 | // without sending it. |
| 10306 | testCases = append(testCases, testCase{ |
| 10307 | name: "SkipHelloRetryRequest", |
| 10308 | config: Config{ |
| 10309 | MaxVersion: VersionTLS13, |
| 10310 | // P-384 requires HelloRetryRequest in BoringSSL. |
| 10311 | CurvePreferences: []CurveID{CurveP384}, |
| 10312 | Bugs: ProtocolBugs{ |
| 10313 | SkipHelloRetryRequest: true, |
| 10314 | }, |
| 10315 | }, |
| 10316 | shouldFail: true, |
| 10317 | expectedError: ":WRONG_CURVE:", |
| 10318 | }) |
David Benjamin | 8a8349b | 2016-08-18 02:32:23 -0400 | [diff] [blame] | 10319 | |
| 10320 | testCases = append(testCases, testCase{ |
| 10321 | name: "TLS13-RequestContextInHandshake", |
| 10322 | config: Config{ |
| 10323 | MaxVersion: VersionTLS13, |
| 10324 | MinVersion: VersionTLS13, |
| 10325 | ClientAuth: RequireAnyClientCert, |
| 10326 | Bugs: ProtocolBugs{ |
| 10327 | SendRequestContext: []byte("request context"), |
| 10328 | }, |
| 10329 | }, |
| 10330 | flags: []string{ |
| 10331 | "-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 10332 | "-key-file", path.Join(*resourceDir, rsaKeyFile), |
| 10333 | }, |
| 10334 | shouldFail: true, |
| 10335 | expectedError: ":DECODE_ERROR:", |
| 10336 | }) |
David Benjamin | 7e1f984 | 2016-09-20 19:24:40 -0400 | [diff] [blame] | 10337 | |
| 10338 | testCases = append(testCases, testCase{ |
| 10339 | testType: serverTest, |
| 10340 | name: "TLS13-TrailingKeyShareData", |
| 10341 | config: Config{ |
| 10342 | MaxVersion: VersionTLS13, |
| 10343 | Bugs: ProtocolBugs{ |
| 10344 | TrailingKeyShareData: true, |
| 10345 | }, |
| 10346 | }, |
| 10347 | shouldFail: true, |
| 10348 | expectedError: ":DECODE_ERROR:", |
| 10349 | }) |
David Benjamin | 7f78df4 | 2016-10-05 22:33:19 -0400 | [diff] [blame] | 10350 | |
| 10351 | testCases = append(testCases, testCase{ |
| 10352 | name: "TLS13-AlwaysSelectPSKIdentity", |
| 10353 | config: Config{ |
| 10354 | MaxVersion: VersionTLS13, |
| 10355 | Bugs: ProtocolBugs{ |
| 10356 | AlwaysSelectPSKIdentity: true, |
| 10357 | }, |
| 10358 | }, |
| 10359 | shouldFail: true, |
| 10360 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10361 | }) |
| 10362 | |
| 10363 | testCases = append(testCases, testCase{ |
| 10364 | name: "TLS13-InvalidPSKIdentity", |
| 10365 | config: Config{ |
| 10366 | MaxVersion: VersionTLS13, |
| 10367 | Bugs: ProtocolBugs{ |
| 10368 | SelectPSKIdentityOnResume: 1, |
| 10369 | }, |
| 10370 | }, |
| 10371 | resumeSession: true, |
| 10372 | shouldFail: true, |
| 10373 | expectedError: ":PSK_IDENTITY_NOT_FOUND:", |
| 10374 | }) |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 10375 | |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 10376 | testCases = append(testCases, testCase{ |
| 10377 | testType: serverTest, |
| 10378 | name: "TLS13-ExtraPSKIdentity", |
| 10379 | config: Config{ |
| 10380 | MaxVersion: VersionTLS13, |
| 10381 | Bugs: ProtocolBugs{ |
David Benjamin | aedf303 | 2016-12-01 16:47:56 -0500 | [diff] [blame] | 10382 | ExtraPSKIdentity: true, |
| 10383 | SendExtraPSKBinder: true, |
Steven Valdez | af3b8a9 | 2016-11-01 12:49:22 -0400 | [diff] [blame] | 10384 | }, |
| 10385 | }, |
| 10386 | resumeSession: true, |
| 10387 | }) |
| 10388 | |
David Benjamin | 1286bee | 2016-10-07 15:25:06 -0400 | [diff] [blame] | 10389 | // Test that unknown NewSessionTicket extensions are tolerated. |
| 10390 | testCases = append(testCases, testCase{ |
| 10391 | name: "TLS13-CustomTicketExtension", |
| 10392 | config: Config{ |
| 10393 | MaxVersion: VersionTLS13, |
| 10394 | Bugs: ProtocolBugs{ |
| 10395 | CustomTicketExtension: "1234", |
| 10396 | }, |
| 10397 | }, |
| 10398 | }) |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10399 | |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10400 | testCases = append(testCases, testCase{ |
| 10401 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10402 | name: "TLS13-EarlyData-Reject-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10403 | config: Config{ |
| 10404 | MaxVersion: VersionTLS13, |
| 10405 | MaxEarlyDataSize: 16384, |
| 10406 | }, |
| 10407 | resumeConfig: &Config{ |
| 10408 | MaxVersion: VersionTLS13, |
| 10409 | MaxEarlyDataSize: 16384, |
| 10410 | Bugs: ProtocolBugs{ |
| 10411 | AlwaysRejectEarlyData: true, |
| 10412 | }, |
| 10413 | }, |
| 10414 | resumeSession: true, |
| 10415 | flags: []string{ |
| 10416 | "-enable-early-data", |
| 10417 | "-expect-early-data-info", |
| 10418 | "-expect-reject-early-data", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10419 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10420 | }, |
| 10421 | }) |
| 10422 | |
| 10423 | testCases = append(testCases, testCase{ |
| 10424 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10425 | name: "TLS13-EarlyData-RejectTicket-Client", |
| 10426 | config: Config{ |
| 10427 | MaxVersion: VersionTLS13, |
| 10428 | MaxEarlyDataSize: 16384, |
| 10429 | Certificates: []Certificate{rsaCertificate}, |
| 10430 | }, |
| 10431 | resumeConfig: &Config{ |
| 10432 | MaxVersion: VersionTLS13, |
| 10433 | MaxEarlyDataSize: 16384, |
| 10434 | Certificates: []Certificate{ecdsaP256Certificate}, |
| 10435 | SessionTicketsDisabled: true, |
| 10436 | }, |
| 10437 | resumeSession: true, |
| 10438 | expectResumeRejected: true, |
| 10439 | flags: []string{ |
| 10440 | "-enable-early-data", |
| 10441 | "-expect-early-data-info", |
| 10442 | "-expect-reject-early-data", |
| 10443 | "-on-resume-shim-writes-first", |
| 10444 | "-on-initial-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 10445 | "-on-resume-expect-peer-cert-file", path.Join(*resourceDir, rsaCertificateFile), |
| 10446 | "-on-retry-expect-peer-cert-file", path.Join(*resourceDir, ecdsaP256CertificateFile), |
| 10447 | // Session tickets are disabled, so the runner will not send a ticket. |
| 10448 | "-on-retry-expect-no-session", |
| 10449 | }, |
| 10450 | }) |
| 10451 | |
| 10452 | testCases = append(testCases, testCase{ |
| 10453 | testType: clientTest, |
| 10454 | name: "TLS13-EarlyData-HRR-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10455 | config: Config{ |
| 10456 | MaxVersion: VersionTLS13, |
| 10457 | MaxEarlyDataSize: 16384, |
| 10458 | }, |
| 10459 | resumeConfig: &Config{ |
| 10460 | MaxVersion: VersionTLS13, |
| 10461 | MaxEarlyDataSize: 16384, |
| 10462 | Bugs: ProtocolBugs{ |
| 10463 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 10464 | }, |
| 10465 | }, |
| 10466 | resumeSession: true, |
| 10467 | flags: []string{ |
| 10468 | "-enable-early-data", |
| 10469 | "-expect-early-data-info", |
| 10470 | "-expect-reject-early-data", |
| 10471 | }, |
| 10472 | }) |
| 10473 | |
| 10474 | // The client must check the server does not send the early_data |
| 10475 | // extension while rejecting the session. |
| 10476 | testCases = append(testCases, testCase{ |
| 10477 | testType: clientTest, |
| 10478 | name: "TLS13-EarlyDataWithoutResume-Client", |
| 10479 | config: Config{ |
| 10480 | MaxVersion: VersionTLS13, |
| 10481 | MaxEarlyDataSize: 16384, |
| 10482 | }, |
| 10483 | resumeConfig: &Config{ |
| 10484 | MaxVersion: VersionTLS13, |
| 10485 | SessionTicketsDisabled: true, |
| 10486 | Bugs: ProtocolBugs{ |
| 10487 | SendEarlyDataExtension: true, |
| 10488 | }, |
| 10489 | }, |
| 10490 | resumeSession: true, |
| 10491 | flags: []string{ |
| 10492 | "-enable-early-data", |
| 10493 | "-expect-early-data-info", |
| 10494 | }, |
| 10495 | shouldFail: true, |
| 10496 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10497 | }) |
| 10498 | |
| 10499 | // The client must fail with a dedicated error code if the server |
| 10500 | // responds with TLS 1.2 when offering 0-RTT. |
| 10501 | testCases = append(testCases, testCase{ |
| 10502 | testType: clientTest, |
| 10503 | name: "TLS13-EarlyDataVersionDowngrade-Client", |
| 10504 | config: Config{ |
| 10505 | MaxVersion: VersionTLS13, |
| 10506 | MaxEarlyDataSize: 16384, |
| 10507 | }, |
| 10508 | resumeConfig: &Config{ |
| 10509 | MaxVersion: VersionTLS12, |
| 10510 | }, |
| 10511 | resumeSession: true, |
| 10512 | flags: []string{ |
| 10513 | "-enable-early-data", |
| 10514 | "-expect-early-data-info", |
| 10515 | }, |
| 10516 | shouldFail: true, |
| 10517 | expectedError: ":WRONG_VERSION_ON_EARLY_DATA:", |
| 10518 | }) |
| 10519 | |
| 10520 | // Test that the client rejects an (unsolicited) early_data extension if |
| 10521 | // the server sent an HRR. |
| 10522 | testCases = append(testCases, testCase{ |
| 10523 | testType: clientTest, |
| 10524 | name: "TLS13-ServerAcceptsEarlyDataOnHRR-Client", |
| 10525 | config: Config{ |
| 10526 | MaxVersion: VersionTLS13, |
| 10527 | MaxEarlyDataSize: 16384, |
| 10528 | }, |
| 10529 | resumeConfig: &Config{ |
| 10530 | MaxVersion: VersionTLS13, |
| 10531 | MaxEarlyDataSize: 16384, |
| 10532 | Bugs: ProtocolBugs{ |
| 10533 | SendHelloRetryRequestCookie: []byte{1, 2, 3, 4}, |
| 10534 | SendEarlyDataExtension: true, |
| 10535 | }, |
| 10536 | }, |
| 10537 | resumeSession: true, |
| 10538 | flags: []string{ |
| 10539 | "-enable-early-data", |
| 10540 | "-expect-early-data-info", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10541 | "-expect-reject-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10542 | }, |
| 10543 | shouldFail: true, |
| 10544 | expectedError: ":UNEXPECTED_EXTENSION:", |
| 10545 | }) |
| 10546 | |
| 10547 | fooString := "foo" |
| 10548 | barString := "bar" |
| 10549 | |
| 10550 | // Test that the client reports the correct ALPN after a 0-RTT reject |
| 10551 | // that changed it. |
| 10552 | testCases = append(testCases, testCase{ |
| 10553 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10554 | name: "TLS13-EarlyData-ALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10555 | config: Config{ |
| 10556 | MaxVersion: VersionTLS13, |
| 10557 | MaxEarlyDataSize: 16384, |
| 10558 | Bugs: ProtocolBugs{ |
| 10559 | ALPNProtocol: &fooString, |
| 10560 | }, |
| 10561 | }, |
| 10562 | resumeConfig: &Config{ |
| 10563 | MaxVersion: VersionTLS13, |
| 10564 | MaxEarlyDataSize: 16384, |
| 10565 | Bugs: ProtocolBugs{ |
| 10566 | ALPNProtocol: &barString, |
| 10567 | }, |
| 10568 | }, |
| 10569 | resumeSession: true, |
| 10570 | flags: []string{ |
| 10571 | "-advertise-alpn", "\x03foo\x03bar", |
| 10572 | "-enable-early-data", |
| 10573 | "-expect-early-data-info", |
| 10574 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10575 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10576 | "-on-resume-expect-alpn", "foo", |
| 10577 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10578 | }, |
| 10579 | }) |
| 10580 | |
| 10581 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 10582 | // ALPN was omitted from the first connection. |
| 10583 | testCases = append(testCases, testCase{ |
| 10584 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10585 | name: "TLS13-EarlyData-ALPNOmitted1-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10586 | config: Config{ |
| 10587 | MaxVersion: VersionTLS13, |
| 10588 | MaxEarlyDataSize: 16384, |
| 10589 | }, |
| 10590 | resumeConfig: &Config{ |
| 10591 | MaxVersion: VersionTLS13, |
| 10592 | MaxEarlyDataSize: 16384, |
| 10593 | NextProtos: []string{"foo"}, |
| 10594 | }, |
| 10595 | resumeSession: true, |
| 10596 | flags: []string{ |
| 10597 | "-advertise-alpn", "\x03foo\x03bar", |
| 10598 | "-enable-early-data", |
| 10599 | "-expect-early-data-info", |
| 10600 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10601 | "-on-initial-expect-alpn", "", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10602 | "-on-resume-expect-alpn", "", |
| 10603 | "-on-retry-expect-alpn", "foo", |
| 10604 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10605 | }, |
| 10606 | }) |
| 10607 | |
| 10608 | // Test that the client reports the correct ALPN after a 0-RTT reject if |
| 10609 | // ALPN was omitted from the second connection. |
| 10610 | testCases = append(testCases, testCase{ |
| 10611 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10612 | name: "TLS13-EarlyData-ALPNOmitted2-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10613 | config: Config{ |
| 10614 | MaxVersion: VersionTLS13, |
| 10615 | MaxEarlyDataSize: 16384, |
| 10616 | NextProtos: []string{"foo"}, |
| 10617 | }, |
| 10618 | resumeConfig: &Config{ |
| 10619 | MaxVersion: VersionTLS13, |
| 10620 | MaxEarlyDataSize: 16384, |
| 10621 | }, |
| 10622 | resumeSession: true, |
| 10623 | flags: []string{ |
| 10624 | "-advertise-alpn", "\x03foo\x03bar", |
| 10625 | "-enable-early-data", |
| 10626 | "-expect-early-data-info", |
| 10627 | "-expect-reject-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10628 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10629 | "-on-resume-expect-alpn", "foo", |
| 10630 | "-on-retry-expect-alpn", "", |
| 10631 | "-on-resume-shim-writes-first", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10632 | }, |
| 10633 | }) |
| 10634 | |
| 10635 | // Test that the client enforces ALPN match on 0-RTT accept. |
| 10636 | testCases = append(testCases, testCase{ |
| 10637 | testType: clientTest, |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10638 | name: "TLS13-EarlyData-BadALPNMismatch-Client", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10639 | config: Config{ |
| 10640 | MaxVersion: VersionTLS13, |
| 10641 | MaxEarlyDataSize: 16384, |
| 10642 | Bugs: ProtocolBugs{ |
| 10643 | ALPNProtocol: &fooString, |
| 10644 | }, |
| 10645 | }, |
| 10646 | resumeConfig: &Config{ |
| 10647 | MaxVersion: VersionTLS13, |
| 10648 | MaxEarlyDataSize: 16384, |
| 10649 | Bugs: ProtocolBugs{ |
| 10650 | AlwaysAcceptEarlyData: true, |
| 10651 | ALPNProtocol: &barString, |
| 10652 | }, |
| 10653 | }, |
| 10654 | resumeSession: true, |
| 10655 | flags: []string{ |
| 10656 | "-advertise-alpn", "\x03foo\x03bar", |
| 10657 | "-enable-early-data", |
| 10658 | "-expect-early-data-info", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10659 | "-on-initial-expect-alpn", "foo", |
Steven Valdez | e831a81 | 2017-03-09 14:56:07 -0500 | [diff] [blame] | 10660 | "-on-resume-expect-alpn", "foo", |
| 10661 | "-on-retry-expect-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10662 | }, |
| 10663 | shouldFail: true, |
| 10664 | expectedError: ":ALPN_MISMATCH_ON_EARLY_DATA:", |
| 10665 | }) |
| 10666 | |
| 10667 | // Test that the server correctly rejects 0-RTT when the previous |
| 10668 | // session did not allow early data on resumption. |
| 10669 | testCases = append(testCases, testCase{ |
| 10670 | testType: serverTest, |
| 10671 | name: "TLS13-EarlyData-NonZeroRTTSession-Server", |
| 10672 | config: Config{ |
| 10673 | MaxVersion: VersionTLS13, |
| 10674 | }, |
| 10675 | resumeConfig: &Config{ |
| 10676 | MaxVersion: VersionTLS13, |
| 10677 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10678 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10679 | ExpectEarlyDataAccepted: false, |
| 10680 | }, |
| 10681 | }, |
| 10682 | resumeSession: true, |
| 10683 | flags: []string{ |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10684 | "-on-resume-enable-early-data", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10685 | "-expect-reject-early-data", |
| 10686 | }, |
| 10687 | }) |
| 10688 | |
| 10689 | // Test that we reject early data where ALPN is omitted from the first |
| 10690 | // connection. |
| 10691 | testCases = append(testCases, testCase{ |
| 10692 | testType: serverTest, |
| 10693 | name: "TLS13-EarlyData-ALPNOmitted1-Server", |
| 10694 | config: Config{ |
| 10695 | MaxVersion: VersionTLS13, |
| 10696 | NextProtos: []string{}, |
| 10697 | }, |
| 10698 | resumeConfig: &Config{ |
| 10699 | MaxVersion: VersionTLS13, |
| 10700 | NextProtos: []string{"foo"}, |
| 10701 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10702 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10703 | ExpectEarlyDataAccepted: false, |
| 10704 | }, |
| 10705 | }, |
| 10706 | resumeSession: true, |
| 10707 | flags: []string{ |
| 10708 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10709 | "-on-initial-select-alpn", "", |
| 10710 | "-on-resume-select-alpn", "foo", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10711 | }, |
| 10712 | }) |
| 10713 | |
| 10714 | // Test that we reject early data where ALPN is omitted from the second |
| 10715 | // connection. |
| 10716 | testCases = append(testCases, testCase{ |
| 10717 | testType: serverTest, |
| 10718 | name: "TLS13-EarlyData-ALPNOmitted2-Server", |
| 10719 | config: Config{ |
| 10720 | MaxVersion: VersionTLS13, |
| 10721 | NextProtos: []string{"foo"}, |
| 10722 | }, |
| 10723 | resumeConfig: &Config{ |
| 10724 | MaxVersion: VersionTLS13, |
| 10725 | NextProtos: []string{}, |
| 10726 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10727 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10728 | ExpectEarlyDataAccepted: false, |
| 10729 | }, |
| 10730 | }, |
| 10731 | resumeSession: true, |
| 10732 | flags: []string{ |
| 10733 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10734 | "-on-initial-select-alpn", "foo", |
| 10735 | "-on-resume-select-alpn", "", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10736 | }, |
| 10737 | }) |
| 10738 | |
| 10739 | // Test that we reject early data with mismatched ALPN. |
| 10740 | testCases = append(testCases, testCase{ |
| 10741 | testType: serverTest, |
| 10742 | name: "TLS13-EarlyData-ALPNMismatch-Server", |
| 10743 | config: Config{ |
| 10744 | MaxVersion: VersionTLS13, |
| 10745 | NextProtos: []string{"foo"}, |
| 10746 | }, |
| 10747 | resumeConfig: &Config{ |
| 10748 | MaxVersion: VersionTLS13, |
| 10749 | NextProtos: []string{"bar"}, |
| 10750 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10751 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10752 | ExpectEarlyDataAccepted: false, |
| 10753 | }, |
| 10754 | }, |
| 10755 | resumeSession: true, |
| 10756 | flags: []string{ |
| 10757 | "-enable-early-data", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 10758 | "-on-initial-select-alpn", "foo", |
| 10759 | "-on-resume-select-alpn", "bar", |
Steven Valdez | 2d85062 | 2017-01-11 11:34:52 -0500 | [diff] [blame] | 10760 | }, |
| 10761 | }) |
| 10762 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10763 | // Test that the client offering 0-RTT and Channel ID forbids the server |
| 10764 | // from accepting both. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 10765 | testCases = append(testCases, testCase{ |
| 10766 | testType: clientTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10767 | name: "TLS13-EarlyDataChannelID-AcceptBoth-Client", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 10768 | config: Config{ |
| 10769 | MaxVersion: VersionTLS13, |
| 10770 | MaxEarlyDataSize: 16384, |
| 10771 | RequestChannelID: true, |
| 10772 | }, |
| 10773 | resumeSession: true, |
| 10774 | expectChannelID: true, |
| 10775 | shouldFail: true, |
| 10776 | expectedError: ":CHANNEL_ID_ON_EARLY_DATA:", |
| 10777 | flags: []string{ |
| 10778 | "-enable-early-data", |
| 10779 | "-expect-early-data-info", |
| 10780 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 10781 | }, |
| 10782 | }) |
| 10783 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10784 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 10785 | // to decline 0-RTT. |
| 10786 | testCases = append(testCases, testCase{ |
| 10787 | testType: clientTest, |
| 10788 | name: "TLS13-EarlyDataChannelID-AcceptChannelID-Client", |
| 10789 | config: Config{ |
| 10790 | MaxVersion: VersionTLS13, |
| 10791 | MaxEarlyDataSize: 16384, |
| 10792 | RequestChannelID: true, |
| 10793 | Bugs: ProtocolBugs{ |
| 10794 | AlwaysRejectEarlyData: true, |
| 10795 | }, |
| 10796 | }, |
| 10797 | resumeSession: true, |
| 10798 | expectChannelID: true, |
| 10799 | flags: []string{ |
| 10800 | "-enable-early-data", |
| 10801 | "-expect-early-data-info", |
| 10802 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 10803 | "-expect-reject-early-data", |
| 10804 | }, |
| 10805 | }) |
| 10806 | |
| 10807 | // Test that the client offering Channel ID and 0-RTT allows the server |
| 10808 | // to decline Channel ID. |
| 10809 | testCases = append(testCases, testCase{ |
| 10810 | testType: clientTest, |
| 10811 | name: "TLS13-EarlyDataChannelID-AcceptEarlyData-Client", |
| 10812 | config: Config{ |
| 10813 | MaxVersion: VersionTLS13, |
| 10814 | MaxEarlyDataSize: 16384, |
| 10815 | }, |
| 10816 | resumeSession: true, |
| 10817 | flags: []string{ |
| 10818 | "-enable-early-data", |
| 10819 | "-expect-early-data-info", |
| 10820 | "-send-channel-id", path.Join(*resourceDir, channelIDKeyFile), |
| 10821 | "-expect-accept-early-data", |
| 10822 | }, |
| 10823 | }) |
| 10824 | |
| 10825 | // Test that the server supporting Channel ID and 0-RTT declines 0-RTT |
| 10826 | // if it would negotiate Channel ID. |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 10827 | testCases = append(testCases, testCase{ |
| 10828 | testType: serverTest, |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10829 | name: "TLS13-EarlyDataChannelID-OfferBoth-Server", |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 10830 | config: Config{ |
| 10831 | MaxVersion: VersionTLS13, |
| 10832 | ChannelID: channelIDKey, |
| 10833 | Bugs: ProtocolBugs{ |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10834 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
Steven Valdez | 2a07072 | 2017-03-25 20:54:16 -0500 | [diff] [blame] | 10835 | ExpectEarlyDataAccepted: false, |
| 10836 | }, |
| 10837 | }, |
| 10838 | resumeSession: true, |
| 10839 | expectChannelID: true, |
| 10840 | flags: []string{ |
| 10841 | "-enable-early-data", |
| 10842 | "-expect-reject-early-data", |
| 10843 | "-expect-channel-id", |
| 10844 | base64.StdEncoding.EncodeToString(channelIDBytes), |
| 10845 | }, |
| 10846 | }) |
| 10847 | |
David Benjamin | 6bb507b | 2017-03-29 16:35:57 -0500 | [diff] [blame] | 10848 | // Test that the server supporting Channel ID and 0-RTT accepts 0-RTT |
| 10849 | // if not offered Channel ID. |
| 10850 | testCases = append(testCases, testCase{ |
| 10851 | testType: serverTest, |
| 10852 | name: "TLS13-EarlyDataChannelID-OfferEarlyData-Server", |
| 10853 | config: Config{ |
| 10854 | MaxVersion: VersionTLS13, |
| 10855 | Bugs: ProtocolBugs{ |
| 10856 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 10857 | ExpectEarlyDataAccepted: true, |
| 10858 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 10859 | }, |
| 10860 | }, |
| 10861 | resumeSession: true, |
| 10862 | expectChannelID: false, |
| 10863 | flags: []string{ |
| 10864 | "-enable-early-data", |
| 10865 | "-expect-accept-early-data", |
| 10866 | "-enable-channel-id", |
| 10867 | }, |
| 10868 | }) |
| 10869 | |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 10870 | // Test that the server rejects 0-RTT streams without end_of_early_data. |
| 10871 | // The subsequent records should fail to decrypt. |
| 10872 | testCases = append(testCases, testCase{ |
| 10873 | testType: serverTest, |
| 10874 | name: "TLS13-EarlyData-SkipEndOfEarlyData", |
| 10875 | config: Config{ |
| 10876 | MaxVersion: VersionTLS13, |
| 10877 | Bugs: ProtocolBugs{ |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10878 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
David Benjamin | 32c8927 | 2017-03-26 13:54:21 -0500 | [diff] [blame] | 10879 | ExpectEarlyDataAccepted: true, |
| 10880 | SkipEndOfEarlyData: true, |
| 10881 | }, |
| 10882 | }, |
| 10883 | resumeSession: true, |
| 10884 | flags: []string{"-enable-early-data"}, |
| 10885 | shouldFail: true, |
| 10886 | expectedLocalError: "remote error: bad record MAC", |
| 10887 | expectedError: ":BAD_DECRYPT:", |
| 10888 | }) |
Steven Valdez | 681eb6a | 2016-12-19 13:19:29 -0500 | [diff] [blame] | 10889 | |
| 10890 | testCases = append(testCases, testCase{ |
| 10891 | testType: serverTest, |
| 10892 | name: "TLS13-EarlyData-UnexpectedHandshake-Server", |
| 10893 | config: Config{ |
| 10894 | MaxVersion: VersionTLS13, |
| 10895 | }, |
| 10896 | resumeConfig: &Config{ |
| 10897 | MaxVersion: VersionTLS13, |
| 10898 | Bugs: ProtocolBugs{ |
| 10899 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 10900 | SendStrayEarlyHandshake: true, |
| 10901 | ExpectEarlyDataAccepted: true}, |
| 10902 | }, |
| 10903 | resumeSession: true, |
| 10904 | shouldFail: true, |
| 10905 | expectedError: ":UNEXPECTED_RECORD:", |
| 10906 | expectedLocalError: "remote error: unexpected message", |
| 10907 | flags: []string{ |
| 10908 | "-enable-early-data", |
| 10909 | }, |
| 10910 | }) |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 10911 | } |
| 10912 | |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 10913 | func addTLS13CipherPreferenceTests() { |
| 10914 | // Test that client preference is honored if the shim has AES hardware |
| 10915 | // and ChaCha20-Poly1305 is preferred otherwise. |
| 10916 | testCases = append(testCases, testCase{ |
| 10917 | testType: serverTest, |
| 10918 | name: "TLS13-CipherPreference-Server-ChaCha20-AES", |
| 10919 | config: Config{ |
| 10920 | MaxVersion: VersionTLS13, |
| 10921 | CipherSuites: []uint16{ |
| 10922 | TLS_CHACHA20_POLY1305_SHA256, |
| 10923 | TLS_AES_128_GCM_SHA256, |
| 10924 | }, |
| 10925 | }, |
| 10926 | flags: []string{ |
| 10927 | "-expect-cipher-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10928 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10929 | }, |
| 10930 | }) |
| 10931 | |
| 10932 | testCases = append(testCases, testCase{ |
| 10933 | testType: serverTest, |
| 10934 | name: "TLS13-CipherPreference-Server-AES-ChaCha20", |
| 10935 | config: Config{ |
| 10936 | MaxVersion: VersionTLS13, |
| 10937 | CipherSuites: []uint16{ |
| 10938 | TLS_AES_128_GCM_SHA256, |
| 10939 | TLS_CHACHA20_POLY1305_SHA256, |
| 10940 | }, |
| 10941 | }, |
| 10942 | flags: []string{ |
| 10943 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 10944 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10945 | }, |
| 10946 | }) |
| 10947 | |
| 10948 | // Test that the client orders ChaCha20-Poly1305 and AES-GCM based on |
| 10949 | // whether it has AES hardware. |
| 10950 | testCases = append(testCases, testCase{ |
| 10951 | name: "TLS13-CipherPreference-Client", |
| 10952 | config: Config{ |
| 10953 | MaxVersion: VersionTLS13, |
| 10954 | // Use the client cipher order. (This is the default but |
| 10955 | // is listed to be explicit.) |
| 10956 | PreferServerCipherSuites: false, |
| 10957 | }, |
| 10958 | flags: []string{ |
| 10959 | "-expect-cipher-aes", strconv.Itoa(int(TLS_AES_128_GCM_SHA256)), |
| 10960 | "-expect-cipher-no-aes", strconv.Itoa(int(TLS_CHACHA20_POLY1305_SHA256)), |
| 10961 | }, |
| 10962 | }) |
| 10963 | } |
| 10964 | |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 10965 | func addPeekTests() { |
| 10966 | // Test SSL_peek works, including on empty records. |
| 10967 | testCases = append(testCases, testCase{ |
| 10968 | name: "Peek-Basic", |
| 10969 | sendEmptyRecords: 1, |
| 10970 | flags: []string{"-peek-then-read"}, |
| 10971 | }) |
| 10972 | |
| 10973 | // Test SSL_peek can drive the initial handshake. |
| 10974 | testCases = append(testCases, testCase{ |
| 10975 | name: "Peek-ImplicitHandshake", |
| 10976 | flags: []string{ |
| 10977 | "-peek-then-read", |
| 10978 | "-implicit-handshake", |
| 10979 | }, |
| 10980 | }) |
| 10981 | |
| 10982 | // Test SSL_peek can discover and drive a renegotiation. |
| 10983 | testCases = append(testCases, testCase{ |
| 10984 | name: "Peek-Renegotiate", |
| 10985 | config: Config{ |
| 10986 | MaxVersion: VersionTLS12, |
| 10987 | }, |
| 10988 | renegotiate: 1, |
| 10989 | flags: []string{ |
| 10990 | "-peek-then-read", |
| 10991 | "-renegotiate-freely", |
| 10992 | "-expect-total-renegotiations", "1", |
| 10993 | }, |
| 10994 | }) |
| 10995 | |
| 10996 | // Test SSL_peek can discover a close_notify. |
| 10997 | testCases = append(testCases, testCase{ |
| 10998 | name: "Peek-Shutdown", |
| 10999 | config: Config{ |
| 11000 | Bugs: ProtocolBugs{ |
| 11001 | ExpectCloseNotify: true, |
| 11002 | }, |
| 11003 | }, |
| 11004 | flags: []string{ |
| 11005 | "-peek-then-read", |
| 11006 | "-check-close-notify", |
| 11007 | }, |
| 11008 | }) |
| 11009 | |
| 11010 | // Test SSL_peek can discover an alert. |
| 11011 | testCases = append(testCases, testCase{ |
| 11012 | name: "Peek-Alert", |
| 11013 | config: Config{ |
| 11014 | Bugs: ProtocolBugs{ |
| 11015 | SendSpuriousAlert: alertRecordOverflow, |
| 11016 | }, |
| 11017 | }, |
| 11018 | flags: []string{"-peek-then-read"}, |
| 11019 | shouldFail: true, |
| 11020 | expectedError: ":TLSV1_ALERT_RECORD_OVERFLOW:", |
| 11021 | }) |
| 11022 | |
| 11023 | // Test SSL_peek can handle KeyUpdate. |
| 11024 | testCases = append(testCases, testCase{ |
| 11025 | name: "Peek-KeyUpdate", |
| 11026 | config: Config{ |
| 11027 | MaxVersion: VersionTLS13, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11028 | }, |
Steven Valdez | c4aa727 | 2016-10-03 12:25:56 -0400 | [diff] [blame] | 11029 | sendKeyUpdates: 1, |
| 11030 | keyUpdateRequest: keyUpdateNotRequested, |
| 11031 | flags: []string{"-peek-then-read"}, |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11032 | }) |
| 11033 | } |
| 11034 | |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11035 | func addRecordVersionTests() { |
| 11036 | for _, ver := range tlsVersions { |
| 11037 | // Test that the record version is enforced. |
| 11038 | testCases = append(testCases, testCase{ |
| 11039 | name: "CheckRecordVersion-" + ver.name, |
| 11040 | config: Config{ |
| 11041 | MinVersion: ver.version, |
| 11042 | MaxVersion: ver.version, |
| 11043 | Bugs: ProtocolBugs{ |
| 11044 | SendRecordVersion: 0x03ff, |
| 11045 | }, |
| 11046 | }, |
| 11047 | shouldFail: true, |
| 11048 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11049 | }) |
| 11050 | |
| 11051 | // Test that the ClientHello may use any record version, for |
| 11052 | // compatibility reasons. |
| 11053 | testCases = append(testCases, testCase{ |
| 11054 | testType: serverTest, |
| 11055 | name: "LooseInitialRecordVersion-" + ver.name, |
| 11056 | config: Config{ |
| 11057 | MinVersion: ver.version, |
| 11058 | MaxVersion: ver.version, |
| 11059 | Bugs: ProtocolBugs{ |
| 11060 | SendInitialRecordVersion: 0x03ff, |
| 11061 | }, |
| 11062 | }, |
| 11063 | }) |
| 11064 | |
| 11065 | // Test that garbage ClientHello record versions are rejected. |
| 11066 | testCases = append(testCases, testCase{ |
| 11067 | testType: serverTest, |
| 11068 | name: "GarbageInitialRecordVersion-" + ver.name, |
| 11069 | config: Config{ |
| 11070 | MinVersion: ver.version, |
| 11071 | MaxVersion: ver.version, |
| 11072 | Bugs: ProtocolBugs{ |
| 11073 | SendInitialRecordVersion: 0xffff, |
| 11074 | }, |
| 11075 | }, |
| 11076 | shouldFail: true, |
| 11077 | expectedError: ":WRONG_VERSION_NUMBER:", |
| 11078 | }) |
| 11079 | } |
| 11080 | } |
| 11081 | |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11082 | func addCertificateTests() { |
| 11083 | // Test that a certificate chain with intermediate may be sent and |
| 11084 | // received as both client and server. |
| 11085 | for _, ver := range tlsVersions { |
| 11086 | testCases = append(testCases, testCase{ |
| 11087 | testType: clientTest, |
| 11088 | name: "SendReceiveIntermediate-Client-" + ver.name, |
| 11089 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11090 | MinVersion: ver.version, |
| 11091 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11092 | Certificates: []Certificate{rsaChainCertificate}, |
| 11093 | ClientAuth: RequireAnyClientCert, |
| 11094 | }, |
| 11095 | expectPeerCertificate: &rsaChainCertificate, |
| 11096 | flags: []string{ |
| 11097 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11098 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11099 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11100 | }, |
| 11101 | }) |
| 11102 | |
| 11103 | testCases = append(testCases, testCase{ |
| 11104 | testType: serverTest, |
| 11105 | name: "SendReceiveIntermediate-Server-" + ver.name, |
| 11106 | config: Config{ |
Adam Langley | cd6cfb0 | 2016-12-06 15:11:00 -0800 | [diff] [blame] | 11107 | MinVersion: ver.version, |
| 11108 | MaxVersion: ver.version, |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11109 | Certificates: []Certificate{rsaChainCertificate}, |
| 11110 | }, |
| 11111 | expectPeerCertificate: &rsaChainCertificate, |
| 11112 | flags: []string{ |
| 11113 | "-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11114 | "-key-file", path.Join(*resourceDir, rsaChainKeyFile), |
| 11115 | "-require-any-client-certificate", |
| 11116 | "-expect-peer-cert-file", path.Join(*resourceDir, rsaChainCertificateFile), |
| 11117 | }, |
| 11118 | }) |
| 11119 | } |
| 11120 | } |
| 11121 | |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11122 | func addRetainOnlySHA256ClientCertTests() { |
| 11123 | for _, ver := range tlsVersions { |
| 11124 | // Test that enabling |
| 11125 | // SSL_CTX_set_retain_only_sha256_of_client_certs without |
| 11126 | // actually requesting a client certificate is a no-op. |
| 11127 | testCases = append(testCases, testCase{ |
| 11128 | testType: serverTest, |
| 11129 | name: "RetainOnlySHA256-NoCert-" + ver.name, |
| 11130 | config: Config{ |
| 11131 | MinVersion: ver.version, |
| 11132 | MaxVersion: ver.version, |
| 11133 | }, |
| 11134 | flags: []string{ |
| 11135 | "-retain-only-sha256-client-cert-initial", |
| 11136 | "-retain-only-sha256-client-cert-resume", |
| 11137 | }, |
| 11138 | resumeSession: true, |
| 11139 | }) |
| 11140 | |
| 11141 | // Test that when retaining only a SHA-256 certificate is |
| 11142 | // enabled, the hash appears as expected. |
| 11143 | testCases = append(testCases, testCase{ |
| 11144 | testType: serverTest, |
| 11145 | name: "RetainOnlySHA256-Cert-" + ver.name, |
| 11146 | config: Config{ |
| 11147 | MinVersion: ver.version, |
| 11148 | MaxVersion: ver.version, |
| 11149 | Certificates: []Certificate{rsaCertificate}, |
| 11150 | }, |
| 11151 | flags: []string{ |
| 11152 | "-verify-peer", |
| 11153 | "-retain-only-sha256-client-cert-initial", |
| 11154 | "-retain-only-sha256-client-cert-resume", |
| 11155 | "-expect-sha256-client-cert-initial", |
| 11156 | "-expect-sha256-client-cert-resume", |
| 11157 | }, |
| 11158 | resumeSession: true, |
| 11159 | }) |
| 11160 | |
| 11161 | // Test that when the config changes from on to off, a |
| 11162 | // resumption is rejected because the server now wants the full |
| 11163 | // certificate chain. |
| 11164 | testCases = append(testCases, testCase{ |
| 11165 | testType: serverTest, |
| 11166 | name: "RetainOnlySHA256-OnOff-" + ver.name, |
| 11167 | config: Config{ |
| 11168 | MinVersion: ver.version, |
| 11169 | MaxVersion: ver.version, |
| 11170 | Certificates: []Certificate{rsaCertificate}, |
| 11171 | }, |
| 11172 | flags: []string{ |
| 11173 | "-verify-peer", |
| 11174 | "-retain-only-sha256-client-cert-initial", |
| 11175 | "-expect-sha256-client-cert-initial", |
| 11176 | }, |
| 11177 | resumeSession: true, |
| 11178 | expectResumeRejected: true, |
| 11179 | }) |
| 11180 | |
| 11181 | // Test that when the config changes from off to on, a |
| 11182 | // resumption is rejected because the server now wants just the |
| 11183 | // hash. |
| 11184 | testCases = append(testCases, testCase{ |
| 11185 | testType: serverTest, |
| 11186 | name: "RetainOnlySHA256-OffOn-" + ver.name, |
| 11187 | config: Config{ |
| 11188 | MinVersion: ver.version, |
| 11189 | MaxVersion: ver.version, |
| 11190 | Certificates: []Certificate{rsaCertificate}, |
| 11191 | }, |
| 11192 | flags: []string{ |
| 11193 | "-verify-peer", |
| 11194 | "-retain-only-sha256-client-cert-resume", |
| 11195 | "-expect-sha256-client-cert-resume", |
| 11196 | }, |
| 11197 | resumeSession: true, |
| 11198 | expectResumeRejected: true, |
| 11199 | }) |
| 11200 | } |
| 11201 | } |
| 11202 | |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 11203 | func addECDSAKeyUsageTests() { |
| 11204 | p256 := elliptic.P256() |
| 11205 | priv, err := ecdsa.GenerateKey(p256, rand.Reader) |
| 11206 | if err != nil { |
| 11207 | panic(err) |
| 11208 | } |
| 11209 | |
| 11210 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) |
| 11211 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) |
| 11212 | if err != nil { |
| 11213 | panic(err) |
| 11214 | } |
| 11215 | |
| 11216 | template := x509.Certificate{ |
| 11217 | SerialNumber: serialNumber, |
| 11218 | Subject: pkix.Name{ |
| 11219 | Organization: []string{"Acme Co"}, |
| 11220 | }, |
| 11221 | NotBefore: time.Now(), |
| 11222 | NotAfter: time.Now(), |
| 11223 | |
| 11224 | // An ECC certificate with only the keyAgreement key usgae may |
| 11225 | // be used with ECDH, but not ECDSA. |
| 11226 | KeyUsage: x509.KeyUsageKeyAgreement, |
| 11227 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, |
| 11228 | BasicConstraintsValid: true, |
| 11229 | } |
| 11230 | |
| 11231 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) |
| 11232 | if err != nil { |
| 11233 | panic(err) |
| 11234 | } |
| 11235 | |
| 11236 | cert := Certificate{ |
| 11237 | Certificate: [][]byte{derBytes}, |
| 11238 | PrivateKey: priv, |
| 11239 | } |
| 11240 | |
| 11241 | for _, ver := range tlsVersions { |
| 11242 | if ver.version < VersionTLS12 { |
| 11243 | continue |
| 11244 | } |
| 11245 | |
| 11246 | testCases = append(testCases, testCase{ |
| 11247 | testType: clientTest, |
| 11248 | name: "ECDSAKeyUsage-" + ver.name, |
| 11249 | config: Config{ |
| 11250 | MinVersion: ver.version, |
| 11251 | MaxVersion: ver.version, |
| 11252 | Certificates: []Certificate{cert}, |
| 11253 | }, |
| 11254 | shouldFail: true, |
| 11255 | expectedError: ":ECC_CERT_NOT_FOR_SIGNING:", |
| 11256 | }) |
| 11257 | } |
| 11258 | } |
| 11259 | |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 11260 | func addExtraHandshakeTests() { |
| 11261 | // An extra SSL_do_handshake is normally a no-op. These tests use -async |
| 11262 | // to ensure there is no transport I/O. |
| 11263 | testCases = append(testCases, testCase{ |
| 11264 | testType: clientTest, |
| 11265 | name: "ExtraHandshake-Client-TLS12", |
| 11266 | config: Config{ |
| 11267 | MinVersion: VersionTLS12, |
| 11268 | MaxVersion: VersionTLS12, |
| 11269 | }, |
| 11270 | flags: []string{ |
| 11271 | "-async", |
| 11272 | "-no-op-extra-handshake", |
| 11273 | }, |
| 11274 | }) |
| 11275 | testCases = append(testCases, testCase{ |
| 11276 | testType: serverTest, |
| 11277 | name: "ExtraHandshake-Server-TLS12", |
| 11278 | config: Config{ |
| 11279 | MinVersion: VersionTLS12, |
| 11280 | MaxVersion: VersionTLS12, |
| 11281 | }, |
| 11282 | flags: []string{ |
| 11283 | "-async", |
| 11284 | "-no-op-extra-handshake", |
| 11285 | }, |
| 11286 | }) |
| 11287 | testCases = append(testCases, testCase{ |
| 11288 | testType: clientTest, |
| 11289 | name: "ExtraHandshake-Client-TLS13", |
| 11290 | config: Config{ |
| 11291 | MinVersion: VersionTLS13, |
| 11292 | MaxVersion: VersionTLS13, |
| 11293 | }, |
| 11294 | flags: []string{ |
| 11295 | "-async", |
| 11296 | "-no-op-extra-handshake", |
| 11297 | }, |
| 11298 | }) |
| 11299 | testCases = append(testCases, testCase{ |
| 11300 | testType: serverTest, |
| 11301 | name: "ExtraHandshake-Server-TLS13", |
| 11302 | config: Config{ |
| 11303 | MinVersion: VersionTLS13, |
| 11304 | MaxVersion: VersionTLS13, |
| 11305 | }, |
| 11306 | flags: []string{ |
| 11307 | "-async", |
| 11308 | "-no-op-extra-handshake", |
| 11309 | }, |
| 11310 | }) |
| 11311 | |
| 11312 | // An extra SSL_do_handshake is a no-op in server 0-RTT. |
| 11313 | testCases = append(testCases, testCase{ |
| 11314 | testType: serverTest, |
| 11315 | name: "ExtraHandshake-Server-EarlyData-TLS13", |
| 11316 | config: Config{ |
| 11317 | MaxVersion: VersionTLS13, |
| 11318 | MinVersion: VersionTLS13, |
| 11319 | Bugs: ProtocolBugs{ |
| 11320 | SendEarlyData: [][]byte{{1, 2, 3, 4}}, |
| 11321 | ExpectEarlyDataAccepted: true, |
| 11322 | ExpectHalfRTTData: [][]byte{{254, 253, 252, 251}}, |
| 11323 | }, |
| 11324 | }, |
| 11325 | messageCount: 2, |
| 11326 | resumeSession: true, |
| 11327 | flags: []string{ |
| 11328 | "-async", |
| 11329 | "-enable-early-data", |
| 11330 | "-expect-accept-early-data", |
| 11331 | "-no-op-extra-handshake", |
| 11332 | }, |
| 11333 | }) |
| 11334 | |
| 11335 | // An extra SSL_do_handshake drives the handshake to completion in False |
| 11336 | // Start. We test this by handshaking twice and asserting the False |
| 11337 | // Start does not appear to happen. See AlertBeforeFalseStartTest for |
| 11338 | // how the test works. |
| 11339 | testCases = append(testCases, testCase{ |
| 11340 | testType: clientTest, |
| 11341 | name: "ExtraHandshake-FalseStart", |
| 11342 | config: Config{ |
| 11343 | MaxVersion: VersionTLS12, |
| 11344 | CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, |
| 11345 | NextProtos: []string{"foo"}, |
| 11346 | Bugs: ProtocolBugs{ |
| 11347 | ExpectFalseStart: true, |
| 11348 | AlertBeforeFalseStartTest: alertAccessDenied, |
| 11349 | }, |
| 11350 | }, |
| 11351 | flags: []string{ |
| 11352 | "-handshake-twice", |
| 11353 | "-false-start", |
| 11354 | "-advertise-alpn", "\x03foo", |
Steven Valdez | 873ebc9 | 2017-05-09 12:12:58 -0400 | [diff] [blame] | 11355 | "-expect-alpn", "foo", |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 11356 | }, |
| 11357 | shimWritesFirst: true, |
| 11358 | shouldFail: true, |
| 11359 | expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", |
| 11360 | expectedLocalError: "tls: peer did not false start: EOF", |
| 11361 | }) |
| 11362 | } |
| 11363 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11364 | 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] | 11365 | defer wg.Done() |
| 11366 | |
| 11367 | for test := range c { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 11368 | var err error |
| 11369 | |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 11370 | if *mallocTest >= 0 { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 11371 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 11372 | statusChan <- statusMsg{test: test, started: true} |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11373 | if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 11374 | if err != nil { |
| 11375 | fmt.Printf("\n\nmalloc test failed at %d: %s\n", mallocNumToFail, err) |
| 11376 | } |
| 11377 | break |
| 11378 | } |
| 11379 | } |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 11380 | } else if *repeatUntilFailure { |
| 11381 | for err == nil { |
| 11382 | statusChan <- statusMsg{test: test, started: true} |
| 11383 | err = runTest(test, shimPath, -1) |
| 11384 | } |
| 11385 | } else { |
| 11386 | statusChan <- statusMsg{test: test, started: true} |
| 11387 | err = runTest(test, shimPath, -1) |
Adam Langley | 69a0160 | 2014-11-17 17:26:55 -0800 | [diff] [blame] | 11388 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11389 | statusChan <- statusMsg{test: test, err: err} |
| 11390 | } |
| 11391 | } |
| 11392 | |
| 11393 | type statusMsg struct { |
| 11394 | test *testCase |
| 11395 | started bool |
| 11396 | err error |
| 11397 | } |
| 11398 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11399 | func statusPrinter(doneChan chan *testOutput, statusChan chan statusMsg, total int) { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 11400 | var started, done, failed, unimplemented, lineLen int |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11401 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11402 | testOutput := newTestOutput() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11403 | for msg := range statusChan { |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11404 | if !*pipe { |
| 11405 | // Erase the previous status line. |
David Benjamin | 87c8a64 | 2015-02-21 01:54:29 -0500 | [diff] [blame] | 11406 | var erase string |
| 11407 | for i := 0; i < lineLen; i++ { |
| 11408 | erase += "\b \b" |
| 11409 | } |
| 11410 | fmt.Print(erase) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11411 | } |
| 11412 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11413 | if msg.started { |
| 11414 | started++ |
| 11415 | } else { |
| 11416 | done++ |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11417 | |
| 11418 | if msg.err != nil { |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 11419 | if msg.err == errUnimplemented { |
| 11420 | if *pipe { |
| 11421 | // Print each test instead of a status line. |
| 11422 | fmt.Printf("UNIMPLEMENTED (%s)\n", msg.test.name) |
| 11423 | } |
| 11424 | unimplemented++ |
| 11425 | testOutput.addResult(msg.test.name, "UNIMPLEMENTED") |
| 11426 | } else { |
| 11427 | fmt.Printf("FAILED (%s)\n%s\n", msg.test.name, msg.err) |
| 11428 | failed++ |
| 11429 | testOutput.addResult(msg.test.name, "FAIL") |
| 11430 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11431 | } else { |
| 11432 | if *pipe { |
| 11433 | // Print each test instead of a status line. |
| 11434 | fmt.Printf("PASSED (%s)\n", msg.test.name) |
| 11435 | } |
| 11436 | testOutput.addResult(msg.test.name, "PASS") |
| 11437 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11438 | } |
| 11439 | |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11440 | if !*pipe { |
| 11441 | // Print a new status line. |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 11442 | 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] | 11443 | lineLen = len(line) |
| 11444 | os.Stdout.WriteString(line) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11445 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11446 | } |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11447 | |
| 11448 | doneChan <- testOutput |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11449 | } |
| 11450 | |
| 11451 | func main() { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11452 | flag.Parse() |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11453 | *resourceDir = path.Clean(*resourceDir) |
David Benjamin | 3386326 | 2016-07-08 17:20:12 -0700 | [diff] [blame] | 11454 | initCertificates() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11455 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11456 | addBasicTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11457 | addCipherSuiteTests() |
| 11458 | addBadECDSASignatureTests() |
Adam Langley | 80842bd | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11459 | addCBCPaddingTests() |
Kenny Root | 7fdeaf1 | 2014-08-05 15:23:37 -0700 | [diff] [blame] | 11460 | addCBCSplittingTests() |
David Benjamin | 636293b | 2014-07-08 17:59:18 -0400 | [diff] [blame] | 11461 | addClientAuthTests() |
Adam Langley | 524e717 | 2015-02-20 16:04:00 -0800 | [diff] [blame] | 11462 | addDDoSCallbackTests() |
David Benjamin | 7e2e6cf | 2014-08-07 17:44:24 -0400 | [diff] [blame] | 11463 | addVersionNegotiationTests() |
David Benjamin | accb454 | 2014-12-12 23:44:33 -0500 | [diff] [blame] | 11464 | addMinimumVersionTests() |
David Benjamin | e78bfde | 2014-09-06 12:45:15 -0400 | [diff] [blame] | 11465 | addExtensionTests() |
David Benjamin | 01fe820 | 2014-09-24 15:21:44 -0400 | [diff] [blame] | 11466 | addResumptionVersionTests() |
Adam Langley | 7571292 | 2014-10-10 16:23:43 -0700 | [diff] [blame] | 11467 | addExtendedMasterSecretTests() |
Adam Langley | 2ae77d2 | 2014-10-28 17:29:33 -0700 | [diff] [blame] | 11468 | addRenegotiationTests() |
David Benjamin | 5e961c1 | 2014-11-07 01:48:35 -0500 | [diff] [blame] | 11469 | addDTLSReplayTests() |
Nick Harper | 60edffd | 2016-06-21 15:19:24 -0700 | [diff] [blame] | 11470 | addSignatureAlgorithmTests() |
David Benjamin | 83f9040 | 2015-01-27 01:09:43 -0500 | [diff] [blame] | 11471 | addDTLSRetransmitTests() |
David Benjamin | c565ebb | 2015-04-03 04:06:36 -0400 | [diff] [blame] | 11472 | addExportKeyingMaterialTests() |
Adam Langley | af0e32c | 2015-06-03 09:57:23 -0700 | [diff] [blame] | 11473 | addTLSUniqueTests() |
Adam Langley | 0950563 | 2015-07-30 18:10:13 -0700 | [diff] [blame] | 11474 | addCustomExtensionTests() |
David Benjamin | b36a395 | 2015-12-01 18:53:13 -0500 | [diff] [blame] | 11475 | addRSAClientKeyExchangeTests() |
David Benjamin | 8c2b3bf | 2015-12-18 20:55:44 -0500 | [diff] [blame] | 11476 | addCurveTests() |
Steven Valdez | 5b98608 | 2016-09-01 12:29:49 -0400 | [diff] [blame] | 11477 | addSessionTicketTests() |
David Benjamin | c9ae27c | 2016-06-24 22:56:37 -0400 | [diff] [blame] | 11478 | addTLS13RecordTests() |
David Benjamin | 582ba04 | 2016-07-07 12:33:25 -0700 | [diff] [blame] | 11479 | addAllStateMachineCoverageTests() |
David Benjamin | 82261be | 2016-07-07 14:32:50 -0700 | [diff] [blame] | 11480 | addChangeCipherSpecTests() |
David Benjamin | 0b8d5da | 2016-07-15 00:39:56 -0400 | [diff] [blame] | 11481 | addWrongMessageTypeTests() |
David Benjamin | 639846e | 2016-09-09 11:41:18 -0400 | [diff] [blame] | 11482 | addTrailingMessageDataTests() |
Steven Valdez | 143e8b3 | 2016-07-11 13:19:03 -0400 | [diff] [blame] | 11483 | addTLS13HandshakeTests() |
David Benjamin | abbbee1 | 2016-10-31 19:20:42 -0400 | [diff] [blame] | 11484 | addTLS13CipherPreferenceTests() |
David Benjamin | f3fbade | 2016-09-19 13:08:16 -0400 | [diff] [blame] | 11485 | addPeekTests() |
David Benjamin | e6f2221 | 2016-11-08 14:28:24 -0500 | [diff] [blame] | 11486 | addRecordVersionTests() |
David Benjamin | 2c51645 | 2016-11-15 10:16:54 +0900 | [diff] [blame] | 11487 | addCertificateTests() |
David Benjamin | bbaf367 | 2016-11-17 10:53:09 +0900 | [diff] [blame] | 11488 | addRetainOnlySHA256ClientCertTests() |
Adam Langley | a4b9198 | 2016-12-12 12:05:53 -0800 | [diff] [blame] | 11489 | addECDSAKeyUsageTests() |
David Benjamin | 8c26d75 | 2017-03-26 15:13:51 -0500 | [diff] [blame] | 11490 | addExtraHandshakeTests() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11491 | |
| 11492 | var wg sync.WaitGroup |
| 11493 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11494 | statusChan := make(chan statusMsg, *numWorkers) |
| 11495 | testChan := make(chan *testCase, *numWorkers) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11496 | doneChan := make(chan *testOutput) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11497 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 11498 | if len(*shimConfigFile) != 0 { |
| 11499 | encoded, err := ioutil.ReadFile(*shimConfigFile) |
| 11500 | if err != nil { |
| 11501 | fmt.Fprintf(os.Stderr, "Couldn't read config file %q: %s\n", *shimConfigFile, err) |
| 11502 | os.Exit(1) |
| 11503 | } |
| 11504 | |
| 11505 | if err := json.Unmarshal(encoded, &shimConfig); err != nil { |
| 11506 | fmt.Fprintf(os.Stderr, "Couldn't decode config file %q: %s\n", *shimConfigFile, err) |
| 11507 | os.Exit(1) |
| 11508 | } |
| 11509 | } |
| 11510 | |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 11511 | go statusPrinter(doneChan, statusChan, len(testCases)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11512 | |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11513 | for i := 0; i < *numWorkers; i++ { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11514 | wg.Add(1) |
Adam Langley | 7c803a6 | 2015-06-15 15:35:05 -0700 | [diff] [blame] | 11515 | go worker(statusChan, testChan, *shimPath, &wg) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11516 | } |
| 11517 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 11518 | var foundTest bool |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 11519 | for i := range testCases { |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 11520 | matched := true |
| 11521 | if len(*testToRun) != 0 { |
| 11522 | var err error |
| 11523 | matched, err = filepath.Match(*testToRun, testCases[i].name) |
| 11524 | if err != nil { |
| 11525 | fmt.Fprintf(os.Stderr, "Error matching pattern: %s\n", err) |
| 11526 | os.Exit(1) |
| 11527 | } |
| 11528 | } |
| 11529 | |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 11530 | if !*includeDisabled { |
| 11531 | for pattern := range shimConfig.DisabledTests { |
| 11532 | isDisabled, err := filepath.Match(pattern, testCases[i].name) |
| 11533 | if err != nil { |
| 11534 | fmt.Fprintf(os.Stderr, "Error matching pattern %q from config file: %s\n", pattern, err) |
| 11535 | os.Exit(1) |
| 11536 | } |
| 11537 | |
| 11538 | if isDisabled { |
| 11539 | matched = false |
| 11540 | break |
| 11541 | } |
| 11542 | } |
| 11543 | } |
| 11544 | |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 11545 | if matched { |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 11546 | foundTest = true |
David Benjamin | 025b3d3 | 2014-07-01 19:53:04 -0400 | [diff] [blame] | 11547 | testChan <- &testCases[i] |
David Benjamin | ba28dfc | 2016-11-15 17:47:21 +0900 | [diff] [blame] | 11548 | |
| 11549 | // Only run one test if repeating until failure. |
| 11550 | if *repeatUntilFailure { |
| 11551 | break |
| 11552 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11553 | } |
| 11554 | } |
David Benjamin | 17e1292 | 2016-07-28 18:04:43 -0400 | [diff] [blame] | 11555 | |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 11556 | if !foundTest { |
EKR | f71d7ed | 2016-08-06 13:25:12 -0700 | [diff] [blame] | 11557 | fmt.Fprintf(os.Stderr, "No tests run\n") |
David Benjamin | 270f0a7 | 2016-03-17 14:41:36 -0400 | [diff] [blame] | 11558 | os.Exit(1) |
| 11559 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11560 | |
| 11561 | close(testChan) |
| 11562 | wg.Wait() |
| 11563 | close(statusChan) |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11564 | testOutput := <-doneChan |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11565 | |
| 11566 | fmt.Printf("\n") |
David Benjamin | 5f237bc | 2015-02-11 17:14:15 -0500 | [diff] [blame] | 11567 | |
| 11568 | if *jsonOutput != "" { |
| 11569 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 11570 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 11571 | } |
| 11572 | } |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 11573 | |
EKR | 842ae6c | 2016-07-27 09:22:05 +0200 | [diff] [blame] | 11574 | if !*allowUnimplemented && testOutput.NumFailuresByType["UNIMPLEMENTED"] > 0 { |
| 11575 | os.Exit(1) |
| 11576 | } |
| 11577 | |
| 11578 | if !testOutput.noneFailed { |
David Benjamin | 2ab7a86 | 2015-04-04 17:02:18 -0400 | [diff] [blame] | 11579 | os.Exit(1) |
| 11580 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 11581 | } |